1
0
Fork 0

Mark only globally visible entries when marking all entries from UI

This commit is contained in:
Romain de Laage 2023-05-30 20:29:36 +02:00 committed by Frédéric Guillot
parent 31c4172540
commit 118e18190d
2 changed files with 28 additions and 1 deletions

View file

@ -449,6 +449,33 @@ func (s *Storage) MarkAllAsRead(userID int64) error {
return nil
}
// MarkGloballyVisibleFeedsAsRead updates all user entries to the read status.
func (s *Storage) MarkGloballyVisibleFeedsAsRead(userID int64) error {
query := `
UPDATE
entries
SET
status=$1,
changed_at=now()
FROM
feeds
WHERE
entries.feed_id = feeds.id
AND entries.user_id=$2
AND entries.status=$3
AND feeds.hide_globally=$4
`
result, err := s.db.Exec(query, model.EntryStatusRead, userID, model.EntryStatusUnread, false)
if err != nil {
return fmt.Errorf(`store: unable to mark globally visible feeds as read: %v`, err)
}
count, _ := result.RowsAffected()
logger.Debug("[Storage:MarkGloballyVisibleFeedsAsRead] %d items marked as read", count)
return nil
}
// MarkFeedAsRead updates all feed entries to the read status.
func (s *Storage) MarkFeedAsRead(userID, feedID int64, before time.Time) error {
query := `

View file

@ -12,7 +12,7 @@ import (
)
func (h *handler) markAllAsRead(w http.ResponseWriter, r *http.Request) {
if err := h.store.MarkAllAsRead(request.UserID(r)); err != nil {
if err := h.store.MarkGloballyVisibleFeedsAsRead(request.UserID(r)); err != nil {
json.ServerError(w, r, err)
return
}