aboutsummaryrefslogtreecommitdiff
path: root/app/Models/UserDAO.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-08-16 22:40:56 +0200
committerGravatar GitHub <noreply@github.com> 2024-08-16 22:40:56 +0200
commitc480e571619c2e68000d85b866ef23c89ad83ddf (patch)
tree00fb41a714775cd111eb0d72161e691a81520284 /app/Models/UserDAO.php
parent1fad724b951d1f804be03362a855f9d50ab4acc9 (diff)
Fix HTTP cache of user queries (#6718)
fix https://github.com/FreshRSS/FreshRSS/issues/6717
Diffstat (limited to 'app/Models/UserDAO.php')
-rw-r--r--app/Models/UserDAO.php23
1 files changed, 21 insertions, 2 deletions
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;
}
}