From 9a35e861ce0418552e0ea926b065ba36fecf63a9 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 12 Apr 2015 11:40:38 +0200 Subject: [PATCH] New field in the contact table to better detect "dead profiles" --- boot.php | 2 +- database.sql | 5 +++-- include/dbstructure.php | 1 + include/items.php | 20 ++++++++++++++++---- update.php | 2 +- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/boot.php b/boot.php index cb380ed995..5e0a70db1f 100644 --- a/boot.php +++ b/boot.php @@ -18,7 +18,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Lily of the valley'); define ( 'FRIENDICA_VERSION', '3.4.0' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1182 ); +define ( 'DB_UPDATE_VERSION', 1183 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index 8babeb4d4f..ab597825cd 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ --- Friendica 3.4.0 (Ginger) --- DB_UPDATE_VERSION 1182 +-- Friendica 3.4.0 (Lily of the valley) +-- DB_UPDATE_VERSION 1183 -- ------------------------------------------ @@ -140,6 +140,7 @@ CREATE TABLE IF NOT EXISTS `contact` ( `uri-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `avatar-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `term-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `last-item` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `priority` tinyint(3) NOT NULL DEFAULT 0, `blocked` tinyint(1) NOT NULL DEFAULT 1, `readonly` tinyint(1) NOT NULL DEFAULT 0, diff --git a/include/dbstructure.php b/include/dbstructure.php index f131abe64f..d25834edff 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -453,6 +453,7 @@ function db_definition() { "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"), "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"), "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), diff --git a/include/items.php b/include/items.php index 3832b80b31..8a0deb437b 100644 --- a/include/items.php +++ b/include/items.php @@ -1391,12 +1391,24 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa $current_post = $r[0]['id']; logger('item_store: created item ' . $current_post); - // Set "success_update" to the date of the last time we heard from this contact - // This can be used to filter for inactive contacts and poco. + // Set "success_update" and "last-item" to the date of the last time we heard from this contact + // This can be used to filter for inactive contacts. // Only do this for public postings to avoid privacy problems, since poco data is public. // Don't set this value if it isn't from the owner (could be an author that we don't know) - if (!$arr['private'] AND (($arr["author-link"] === $arr["owner-link"]) OR ($arr["parent-uri"] === $arr["uri"]))) - q("UPDATE `contact` SET `success_update` = '%s' WHERE `id` = %d", + + $update = (!$arr['private'] AND (($arr["author-link"] === $arr["owner-link"]) OR ($arr["parent-uri"] === $arr["uri"]))); + + // Is it a forum? Then we don't care about the rules from above + if (!$update AND ($arr["network"] == NETWORK_DFRN) AND ($arr["parent-uri"] === $arr["uri"])) { + $isforum = q("SELECT `forum` FROM `contact` WHERE `id` = %d AND `forum`", + intval($arr['contact-id'])); + if ($isforum) + $update = true; + } + + if ($update) + q("UPDATE `contact` SET `success_update` = '%s', `last-item` = '%s' WHERE `id` = %d", + dbesc($arr['received']), dbesc($arr['received']), intval($arr['contact-id']) ); diff --git a/update.php b/update.php index 5b0b4cd251..35aaff2c06 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@