aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Entry.php
diff options
context:
space:
mode:
authorGravatar Federico Scodelaro <federicoscodelaro@gmail.com> 2025-10-10 19:43:38 -0300
committerGravatar GitHub <noreply@github.com> 2025-10-11 00:43:38 +0200
commit673067a52d44cbfc14327d226f4f1c4ce66f737a (patch)
tree649f9617a56593b2d95bd45498b1d69738fe4985 /app/Models/Entry.php
parentec1f5ee61bfeb9e8ed6a3c1e069b82d9f26f64e6 (diff)
Last user modified (#7886)
* feat: Add user modified functionality Closes https://github.com/FreshRSS/FreshRSS/issues/7862 Changes proposed in this pull request: This is an implementation of the proposed feature. It allows entries to have a new field that will be updated whenever an item is marked as read/unread or bookmark/removed from bookmarks. And a new sort criteria to sort by it. How to test the feature manually: 1. Mark items from a feed as read/unread 2. Mark items from a feed as bookmark / remove bookmark 3. Sort by the new criteria * feat: Add sort functionality * feat: Add sort nav button * fix: Use correct migrations * fix: Add internationalization * fix: Linter errors * chore: PR comments * Update app/i18n/fr/index.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * Update app/i18n/pl/index.php Co-authored-by: Inverle <inverle@proton.me> * Update app/i18n/nl/index.php Co-authored-by: Frans de Jonge <fransdejonge@gmail.com> * make fix-all * Fixes * More fixes sort * Fix wrong index * Fix unneeded column * Fix auto-create indexes * Some copilot suggestions * One more fix Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> Co-authored-by: Inverle <inverle@proton.me> Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
Diffstat (limited to 'app/Models/Entry.php')
-rw-r--r--app/Models/Entry.php29
1 files changed, 24 insertions, 5 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index 54516ca58..1f99a8345 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -24,6 +24,7 @@ class FreshRSS_Entry extends Minz_Model {
private string $link;
private int $date;
private int $lastSeen = 0;
+ private int $lastUserModified = 0;
/** In microseconds */
private string $date_added = '0';
private string $hash = '';
@@ -53,7 +54,8 @@ class FreshRSS_Entry extends Minz_Model {
$this->_guid($guid);
}
- /** @param array{id?:string,id_feed?:int,guid?:string,title?:string,author?:string,content?:string,link?:string,date?:int|string,lastSeen?:int,
+ /** @param array{id?:string,id_feed?:int,guid?:string,title?:string,author?:string,content?:string,link?:string,
+ * date?:int|string,lastSeen?:int,lastUserModified?:int,
* hash?:string,is_read?:bool|int,is_favorite?:bool|int,tags?:string|array<string>,attributes?:?string,thumbnail?:string,timestamp?:string} $dao */
public static function fromArray(array $dao): FreshRSS_Entry {
if (empty($dao['content']) || !is_string($dao['content'])) {
@@ -97,6 +99,9 @@ class FreshRSS_Entry extends Minz_Model {
if (isset($dao['lastSeen'])) {
$entry->_lastSeen($dao['lastSeen']);
}
+ if (isset($dao['lastUserModified'])) {
+ $entry->_lastUserModified($dao['lastUserModified']);
+ }
if (!empty($dao['attributes'])) {
$entry->_attributes($dao['attributes']);
}
@@ -107,8 +112,11 @@ class FreshRSS_Entry extends Minz_Model {
}
/**
- * @param Traversable<array{'id'?:string,'id_feed'?:int,'guid'?:string,'title'?:string,'author'?:string,'content'?:string,'link'?:string,'date'?:int|string,'lastSeen'?:int,
- * 'hash'?:string,'is_read'?:bool|int,'is_favorite'?:bool|int,'tags'?:string|array<string>,'attributes'?:?string,'thumbnail'?:string,'timestamp'?:string}> $daos
+ * @param Traversable<array{id?:string,id_feed?:int,guid?:string,
+ * title?:string,author?:string,content?:string,link?:string,
+ * date?:int|string,lastSeen?:int,lastUserModified?:int,hash?:string,is_read?:bool|int,
+ * is_favorite?:bool|int,tags?:string|array<string>,attributes?:?string,
+ * thumbnail?:string,timestamp?:string}> $daos
* @return Traversable<FreshRSS_Entry>
*/
public static function fromTraversable(Traversable $daos): Traversable {
@@ -421,6 +429,10 @@ HTML;
return $this->lastSeen;
}
+ public function lastUserModified(): int {
+ return $this->lastUserModified;
+ }
+
/**
* @phpstan-return ($raw is false ? string : ($microsecond is true ? string : int))
*/
@@ -556,6 +568,11 @@ HTML;
$this->lastSeen = $value > 0 ? $value : 0;
}
+ public function _lastUserModified(int|string $value): void {
+ $value = (int)$value;
+ $this->lastUserModified = $value > 0 ? $value : 0;
+ }
+
/** @param int|numeric-string $value */
public function _dateAdded(int|string $value, bool $microsecond = false): void {
if ($microsecond) {
@@ -1046,8 +1063,9 @@ HTML;
}
/**
- * @return array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'lastSeen':int,
- * 'hash':string,'is_read':?bool,'is_favorite':?bool,'id_feed':int,'tags':string,'attributes':array<string,mixed>}
+ * @return array{id:string,guid:string,title:string,author:string,content:string,link:string,date:int,
+ * lastSeen:int,lastUserModified:int,
+ * hash:string,is_read:?bool,is_favorite:?bool,id_feed:int,tags:string,attributes:array<string,mixed>}
*/
public function toArray(): array {
return [
@@ -1059,6 +1077,7 @@ HTML;
'link' => $this->link(raw: true),
'date' => $this->date(true),
'lastSeen' => $this->lastSeen(),
+ 'lastUserModified' => $this->lastUserModified(),
'hash' => $this->hash(),
'is_read' => $this->isRead(),
'is_favorite' => $this->isFavorite(),