Mark only globally visible entries when marking all entries from UI
This commit is contained in:
parent
31c4172540
commit
118e18190d
2 changed files with 28 additions and 1 deletions
|
@ -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 := `
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue