From c480e571619c2e68000d85b866ef23c89ad83ddf Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 16 Aug 2024 22:40:56 +0200 Subject: Fix HTTP cache of user queries (#6718) fix https://github.com/FreshRSS/FreshRSS/issues/6717 --- app/Models/UserDAO.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'app/Models') diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 9ce0d7bd7..5ae57dd65 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -45,14 +45,33 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { return is_dir(USERS_PATH . '/' . $username); } + /** Update time of the last modification action by the user (e.g., mark an article as read) */ public static function touch(string $username = ''): bool { - if (!FreshRSS_user_Controller::checkUsername($username)) { + if ($username === '') { $username = Minz_User::name() ?? Minz_User::INTERNAL_USER; + } elseif (!FreshRSS_user_Controller::checkUsername($username)) { + return false; } return touch(USERS_PATH . '/' . $username . '/config.php'); } + /** Time of the last modification action by the user (e.g., mark an article as read) */ public static function mtime(string $username): int { - return @(int)filemtime(USERS_PATH . '/' . $username . '/config.php'); + return @filemtime(USERS_PATH . '/' . $username . '/config.php') ?: 0; + } + + /** Update time of the last new content automatically received by the user (e.g., cron job, WebSub) */ + public static function ctouch(string $username = ''): bool { + if ($username === '') { + $username = Minz_User::name() ?? Minz_User::INTERNAL_USER; + } elseif (!FreshRSS_user_Controller::checkUsername($username)) { + return false; + } + return touch(USERS_PATH . '/' . $username . '/' . LOG_FILENAME); + } + + /** Time of the last new content automatically received by the user (e.g., cron job, WebSub) */ + public static function ctime(string $username): int { + return @filemtime(USERS_PATH . '/' . $username . '/' . LOG_FILENAME) ?: 0; } } -- cgit v1.2.3