diff options
author | Frédéric Guillot <fred@miniflux.net> | 2017-12-22 11:33:01 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2017-12-22 11:33:01 -0800 |
commit | 9868f900e972edd6d4811b4a93b1955e4222e9b1 (patch) | |
tree | f366decff3a14c58a6869a1993b5698d6acce19a /storage/entry.go | |
parent | b153fa8b3cd2e48bbe13326695f11d2013427ebc (diff) |
Add bookmarks
Diffstat (limited to 'storage/entry.go')
-rw-r--r-- | storage/entry.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/storage/entry.go b/storage/entry.go index 6d67397..8a12f5e 100644 --- a/storage/entry.go +++ b/storage/entry.go @@ -179,11 +179,24 @@ func (s *Storage) SetEntriesStatus(userID int64, entryIDs []int64, status string return nil } +// ToggleBookmark toggles entry bookmark value. +func (s *Storage) ToggleBookmark(userID int64, entryID int64) error { + defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:ToggleBookmark] userID=%d, entryID=%d", userID, entryID)) + + query := `UPDATE entries SET starred = NOT starred WHERE user_id=$1 AND id=$2` + _, err := s.db.Exec(query, userID, entryID) + if err != nil { + return fmt.Errorf("unable to update toggle bookmark: %v", err) + } + + return nil +} + // FlushHistory set all entries with the status "read" to "removed". func (s *Storage) FlushHistory(userID int64) error { defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:FlushHistory] userID=%d", userID)) - query := `UPDATE entries SET status=$1 WHERE user_id=$2 AND status=$3` + query := `UPDATE entries SET status=$1 WHERE user_id=$2 AND status=$3 AND starred='f'` _, err := s.db.Exec(query, model.EntryStatusRemoved, userID, model.EntryStatusRead) if err != nil { return fmt.Errorf("unable to flush history: %v", err) |