diff options
author | Sasha Varlamov <sasha@sashavarlamov.com> | 2017-12-07 12:52:57 +0700 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-07 13:52:57 +0800 |
commit | 7ec6cddd27f36f50f06669b208674feb0dc19535 (patch) | |
tree | d29dbb6b7fc8f956a9745d5610a9228231759d66 /routers | |
parent | 1ed7f1881589b3831b2fe36fa9228f82c1b9b83e (diff) | |
download | gitea-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 'routers')
-rw-r--r-- | routers/routes/routes.go | 1 | ||||
-rw-r--r-- | routers/user/notification.go | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/routers/routes/routes.go b/routers/routes/routes.go index f4fb135629..cdbbd22801 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -706,6 +706,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/notifications", func() { m.Get("", user.Notifications) m.Post("/status", user.NotificationStatusPost) + m.Post("/purge", user.NotificationPurgePost) }, reqSignIn) m.Group("/api", func() { diff --git a/routers/user/notification.go b/routers/user/notification.go index 77a4a59dc8..c7f23afe69 100644 --- a/routers/user/notification.go +++ b/routers/user/notification.go @@ -112,3 +112,15 @@ func NotificationStatusPost(c *context.Context) { url := fmt.Sprintf("%s/notifications", setting.AppSubURL) c.Redirect(url, 303) } + +// NotificationPurgePost is a route for 'purging' the list of notifications - marking all unread as read +func NotificationPurgePost(c *context.Context) { + err := models.UpdateNotificationStatuses(c.User, models.NotificationStatusUnread, models.NotificationStatusRead) + if err != nil { + c.Handle(500, "ErrUpdateNotificationStatuses", err) + return + } + + url := fmt.Sprintf("%s/notifications", setting.AppSubURL) + c.Redirect(url, 303) +} |