From e27867cec7d860d7ee92c538c83ea00fddd07a08 Mon Sep 17 00:00:00 2001 From: Rohan Sharma <117426013+RS-labhub@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:22:03 +0530 Subject: [PATCH] fix: status errcheck issues (#28540) Co-authored-by: Ben Schumacher --- server/.golangci.yml | 1 - server/channels/api4/status.go | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server/.golangci.yml b/server/.golangci.yml index 22cd2bb6e5..25a824ec56 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -87,7 +87,6 @@ issues: channels/api4/scheme.go|\ channels/api4/scheme_test.go|\ channels/api4/shared_channel.go|\ - channels/api4/status.go|\ channels/api4/system.go|\ channels/api4/system_local.go|\ channels/api4/team_local.go|\ diff --git a/server/channels/api4/status.go b/server/channels/api4/status.go index 6468b2cf9b..089f3cefb7 100644 --- a/server/channels/api4/status.go +++ b/server/channels/api4/status.go @@ -78,7 +78,9 @@ func getUserStatusesByIds(c *Context, w http.ResponseWriter, r *http.Request) { return } - w.Write(js) + if _, err := w.Write(js); err != nil { + c.Logger.Warn("Error while writing response", mlog.Err(err)) + } } func updateUserStatus(c *Context, w http.ResponseWriter, r *http.Request) { @@ -105,8 +107,13 @@ func updateUserStatus(c *Context, w http.ResponseWriter, r *http.Request) { } currentStatus, err := c.App.GetStatus(c.Params.UserId) - if err == nil && currentStatus.Status == model.StatusOutOfOffice && status.Status != model.StatusOutOfOffice { - c.App.DisableAutoResponder(c.AppContext, c.Params.UserId, c.IsSystemAdmin()) + if err != nil { + c.Logger.Warn("Failed to get current status", mlog.Err(err)) + } else if currentStatus.Status == model.StatusOutOfOffice && status.Status != model.StatusOutOfOffice { + err = c.App.DisableAutoResponder(c.AppContext, c.Params.UserId, c.IsSystemAdmin()) + if err != nil { + c.Logger.Warn("Failed to disable auto-responder", mlog.Err(err)) + } } switch status.Status {