summaryrefslogtreecommitdiffstats
path: root/models/notification.go
diff options
context:
space:
mode:
authorSasha Varlamov <sasha@sashavarlamov.com>2017-12-07 12:52:57 +0700
committerLunny Xiao <xiaolunwen@gmail.com>2017-12-07 13:52:57 +0800
commit7ec6cddd27f36f50f06669b208674feb0dc19535 (patch)
treed29dbb6b7fc8f956a9745d5610a9228231759d66 /models/notification.go
parent1ed7f1881589b3831b2fe36fa9228f82c1b9b83e (diff)
downloadgitea-7ec6cddd27f36f50f06669b208674feb0dc19535.tar.gz
gitea-7ec6cddd27f36f50f06669b208674feb0dc19535.zip
Add 'mark all read' option to notifications (#3097)
* Add 'mark all read' option to notifications Signed-off-by: Sasha Varlamov <sasha@sashavarlamov.com> * Fix exported comment Signed-off-by: Sasha Varlamov <sasha@sashavarlamov.com> * Format method comments Signed-off-by: Sasha Varlamov <sasha@sashavarlamov.com> * Fix exported comment Signed-off-by: Sasha Varlamov <sasha@sashavarlamov.com> Format method comments Signed-off-by: Sasha Varlamov <sasha@sashavarlamov.com> Tests for reactions (#3083) * Unit tests for reactions * Fix import order Signed-off-by: Lauris Bukšis-Haberkorns <lauris@nix.lv> Fix reaction possition when there is attachments (#3099) Refactor notifications swap function * Accept change to drop beforeupdate call * Update purge notifications error message for consistency * Drop unnecessary check for mark all as read button * Remove debugging comment
Diffstat (limited to 'models/notification.go')
-rw-r--r--models/notification.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/models/notification.go b/models/notification.go
index 46da059852..dcd624e514 100644
--- a/models/notification.go
+++ b/models/notification.go
@@ -311,3 +311,13 @@ func getNotificationByID(notificationID int64) (*Notification, error) {
return notification, nil
}
+
+// UpdateNotificationStatuses updates the statuses of all of a user's notifications that are of the currentStatus type to the desiredStatus
+func UpdateNotificationStatuses(user *User, currentStatus NotificationStatus, desiredStatus NotificationStatus) error {
+ n := &Notification{Status: desiredStatus, UpdatedBy: user.ID}
+ _, err := x.
+ Where("user_id = ? AND status = ?", user.ID, currentStatus).
+ Cols("status", "updated_by", "updated_unix").
+ Update(n)
+ return err
+}