From 7ec6cddd27f36f50f06669b208674feb0dc19535 Mon Sep 17 00:00:00 2001 From: Sasha Varlamov Date: Thu, 7 Dec 2017 12:52:57 +0700 Subject: Add 'mark all read' option to notifications (#3097) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add 'mark all read' option to notifications Signed-off-by: Sasha Varlamov * Fix exported comment Signed-off-by: Sasha Varlamov * Format method comments Signed-off-by: Sasha Varlamov * Fix exported comment Signed-off-by: Sasha Varlamov Format method comments Signed-off-by: Sasha Varlamov Tests for reactions (#3083) * Unit tests for reactions * Fix import order Signed-off-by: Lauris Bukšis-Haberkorns 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 --- routers/routes/routes.go | 1 + routers/user/notification.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) (limited to 'routers') 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) +} -- cgit v1.2.3