From 8b9dbb86133ff0fd6002a391268383d1593918ca Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 29 Sep 2017 11:45:59 -0400 Subject: PLT-7404 Return viewed at times in view channel API response (#7428) * Return viewed at times in view channel API response * Updated transaction to read and write once * Remove transaction and only update if new value greater than older --- api4/channel.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'api4/channel.go') diff --git a/api4/channel.go b/api4/channel.go index 9eaa6ec8a..74eb1a972 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -709,12 +709,20 @@ func viewChannel(c *Context, w http.ResponseWriter, r *http.Request) { return } - if err := c.App.ViewChannel(view, c.Params.UserId, !c.Session.IsMobileApp()); err != nil { + times, err := c.App.ViewChannel(view, c.Params.UserId, !c.Session.IsMobileApp()) + + if err != nil { c.Err = err return } - ReturnStatusOK(w) + // Returning {"status": "OK", ...} for backwards compatability + resp := &model.ChannelViewResponse{ + Status: "OK", + LastViewedAtTimes: times, + } + + w.Write([]byte(resp.ToJson())) } func updateChannelMemberRoles(c *Context, w http.ResponseWriter, r *http.Request) { -- cgit v1.2.3-1-g7c22