mirror of
https://github.com/miniflux/v2.git
synced 2025-08-16 18:01:37 +00:00
feat(storage): make removed entries' status immutable
This is a first step towards "keeping only metadata for removed entries" #3524.
This commit is contained in:
parent
93fc206f42
commit
eb6f7f30bb
2 changed files with 71 additions and 2 deletions
|
@ -378,8 +378,19 @@ func (s *Storage) ArchiveEntries(status string, days, limit int) (int64, error)
|
|||
|
||||
// SetEntriesStatus update the status of the given list of entries.
|
||||
func (s *Storage) SetEntriesStatus(userID int64, entryIDs []int64, status string) error {
|
||||
query := `UPDATE entries SET status=$1, changed_at=now() WHERE user_id=$2 AND id=ANY($3)`
|
||||
if _, err := s.db.Exec(query, status, userID, pq.Array(entryIDs)); err != nil {
|
||||
// Entries that have the model.EntryStatusRemoved status are immutable.
|
||||
query := `
|
||||
UPDATE
|
||||
entries
|
||||
SET
|
||||
status=$1,
|
||||
changed_at=now()
|
||||
WHERE
|
||||
user_id=$2 AND
|
||||
id=ANY($3) AND
|
||||
status!=$4
|
||||
`
|
||||
if _, err := s.db.Exec(query, status, userID, pq.Array(entryIDs), model.EntryStatusRemoved); err != nil {
|
||||
return fmt.Errorf(`store: unable to update entries statuses %v: %v`, entryIDs, err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue