diff --git a/database.sql b/database.sql index 830eff9914..bbe1e65572 100644 --- a/database.sql +++ b/database.sql @@ -2693,7 +2693,7 @@ CREATE VIEW `owner-view` AS SELECT `user`.`language` AS `language`, `user`.`register_date` AS `register_date`, `user`.`login_date` AS `login_date`, - IF (`user`.`last-activity` IS NULL, DATE(`user`.`login_date`), `user`.`last-activity`) AS `last-activity`, + `user`.`last-activity` AS `last-activity`, `user`.`default-location` AS `default-location`, `user`.`allow_location` AS `allow_location`, `user`.`theme` AS `theme`, diff --git a/src/Module/NoScrape.php b/src/Module/NoScrape.php index bf57ec7765..718c95c107 100644 --- a/src/Module/NoScrape.php +++ b/src/Module/NoScrape.php @@ -94,18 +94,9 @@ class NoScrape extends BaseModule } // We display the last activity (post or login), reduced to year and week number - $last_active = 0; - $condition = ['uid' => $owner['uid'], 'self' => true]; - $contact = DBA::selectFirst('contact', ['last-item'], $condition); - if (DBA::isResult($contact)) { - $last_active = strtotime($contact['last-item']); - } - - $user = User::getOwnerDataById($owner['uid']); - if (DBA::isResult($user)) { - if ($last_active < strtotime($user['last-activity'])) { - $last_active = strtotime($user['last-activity']); - } + $last_active = strtotime($owner['last-item']); + if ($last_active < strtotime($owner['last-activity'])) { + $last_active = strtotime($owner['last-activity']); } $json_info['last-activity'] = date('o-W', $last_active); diff --git a/src/Worker/PollContacts.php b/src/Worker/PollContacts.php index 9aea20e5df..eb092fe2cd 100644 --- a/src/Worker/PollContacts.php +++ b/src/Worker/PollContacts.php @@ -45,7 +45,7 @@ class PollContacts if (!empty($abandon_days)) { $condition = DBA::mergeConditions($condition, - ["`uid` != ? AND `uid` IN (SELECT `uid` FROM `owner-view` WHERE NOT `account_expired` AND NOT `account_removed` AND `last-activity` > ?)", 0, DateTimeFormat::utc('now - ' . $abandon_days . ' days')]); + ["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE NOT `account_expired` AND NOT `account_removed` AND `last-activity` > ?)", 0, DateTimeFormat::utc('now - ' . $abandon_days . ' days')]); } else { $condition = DBA::mergeConditions($condition, ["`uid` != ? AND `uid` IN (SELECT `uid` FROM `user` WHERE NOT `account_expired` AND NOT `account_removed`)", 0]); diff --git a/static/dbview.config.php b/static/dbview.config.php index 09566a7fd0..66f3de3b63 100644 --- a/static/dbview.config.php +++ b/static/dbview.config.php @@ -889,7 +889,7 @@ "language" => ["user", "language"], "register_date" => ["user", "register_date"], "login_date" => ["user", "login_date"], - "last-activity" => "IF (`user`.`last-activity` IS NULL, DATE(`user`.`login_date`), `user`.`last-activity`)", + "last-activity" => ["user", "last-activity"], "default-location" => ["user", "default-location"], "allow_location" => ["user", "allow_location"], "theme" => ["user", "theme"], diff --git a/update.php b/update.php index 2ee753ead2..1767470571 100644 --- a/update.php +++ b/update.php @@ -1126,4 +1126,10 @@ function update_1491() { DBA::update('contact', ['remote_self' => Contact::MIRROR_OWN_POST], ['remote_self' => Contact::MIRROR_FORWARDED]); return Update::SUCCESS; +} + +function update_1497() +{ + DBA::e("UPDATE `user` SET `last-activity` = DATE(`login_date`) WHERE `last-activity` IS NULL"); + return Update::SUCCESS; } \ No newline at end of file