From 3e144f82e29e566b3cf1615c19b4ddc6dc7e4694 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Tue, 3 Oct 2017 14:16:33 -0400 Subject: Only update session activity on specific endpoints (#7549) --- api4/channel.go | 2 ++ api4/context.go | 1 - api4/post.go | 1 + api4/user.go | 2 ++ 4 files changed, 5 insertions(+), 1 deletion(-) (limited to 'api4') diff --git a/api4/channel.go b/api4/channel.go index 74eb1a972..7a1324883 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -716,6 +716,8 @@ func viewChannel(c *Context, w http.ResponseWriter, r *http.Request) { return } + c.App.UpdateLastActivityAtIfNeeded(c.Session) + // Returning {"status": "OK", ...} for backwards compatability resp := &model.ChannelViewResponse{ Status: "OK", diff --git a/api4/context.go b/api4/context.go index 9af15d72b..c526f38bb 100644 --- a/api4/context.go +++ b/api4/context.go @@ -157,7 +157,6 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { c.Err = model.NewAppError("ServeHTTP", "api.context.token_provided.app_error", nil, "token="+token, http.StatusUnauthorized) } else { c.Session = *session - c.App.UpdateLastActivityAtIfNeeded(*session) } } diff --git a/api4/post.go b/api4/post.go index 0cd791c6f..3a957a26f 100644 --- a/api4/post.go +++ b/api4/post.go @@ -69,6 +69,7 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) { } c.App.SetStatusOnline(c.Session.UserId, c.Session.Id, false) + c.App.UpdateLastActivityAtIfNeeded(c.Session) w.WriteHeader(http.StatusCreated) w.Write([]byte(rp.ToJson())) diff --git a/api4/user.go b/api4/user.go index ea5c0f738..97f79cf6f 100644 --- a/api4/user.go +++ b/api4/user.go @@ -121,6 +121,7 @@ func getUser(c *Context, w http.ResponseWriter, r *http.Request) { } else { app.SanitizeProfile(user, c.IsSystemAdmin()) } + c.App.UpdateLastActivityAtIfNeeded(c.Session) w.Header().Set(model.HEADER_ETAG_SERVER, etag) w.Write([]byte(user.ToJson())) return @@ -369,6 +370,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) { if len(etag) > 0 { w.Header().Set(model.HEADER_ETAG_SERVER, etag) } + c.App.UpdateLastActivityAtIfNeeded(c.Session) w.Write([]byte(model.UserListToJson(profiles))) } } -- cgit v1.2.3-1-g7c22