Skip to content

Commit

Permalink
[mattermostGH-28396] Fixed errcheck issues in server/channels/api4/ip…
Browse files Browse the repository at this point in the history
…_filtering.go (mattermost#28441)

* Fixed errcheck issues in server/channels/api4/ip_filtering.go

* Added separate go routine to SendIPFiltersChangedEmail and removed redundant return

* Added import for mlog

* Changed from returning error to logging it

---------

Co-authored-by: Ben Schumacher <[email protected]>
  • Loading branch information
CarlssonFilip and hanzei authored Oct 7, 2024
1 parent 7af4086 commit b8b3f9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion server/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ issues:
channels/api4/handlers_test.go|\
channels/api4/import_test.go|\
channels/api4/integration_action_test.go|\
channels/api4/ip_filtering.go|\
channels/api4/ip_filtering_test.go|\
channels/api4/job_test.go|\
channels/api4/license.go|\
Expand Down
11 changes: 9 additions & 2 deletions server/channels/api4/ip_filtering.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"

"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/mlog"
"github.com/mattermost/mattermost/server/v8/channels/app"
"github.com/mattermost/mattermost/server/v8/channels/audit"
"github.com/mattermost/mattermost/server/v8/einterfaces"
Expand Down Expand Up @@ -81,7 +82,11 @@ func applyIPFilters(c *Context, w http.ResponseWriter, r *http.Request) {

auditRec.Success()

go c.App.SendIPFiltersChangedEmail(c.AppContext, c.AppContext.Session().UserId)
go func() {
if err := c.App.SendIPFiltersChangedEmail(c.AppContext, c.AppContext.Session().UserId); err != nil {
c.Logger.Warn("Failed to send IP filters changed email", mlog.Err(err))
}
}()

if err := json.NewEncoder(w).Encode(updatedAllowedRanges); err != nil {
c.Err = model.NewAppError("getIPFilters", "api.context.ip_filtering.get_ip_filters.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
Expand All @@ -106,5 +111,7 @@ func myIP(c *Context, w http.ResponseWriter, r *http.Request) {
return
}

w.Write(json)
if _, err := w.Write(json); err != nil {
c.Logger.Warn("Error while writing response", mlog.Err(err))
}
}

0 comments on commit b8b3f9b

Please sign in to comment.