[GH-28396] Fixed errcheck issues in server/channels/api4/ip_filtering.go (#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 <ben.schumacher@mattermost.com>
Этот коммит содержится в:
CarlssonFilip
2024-10-07 21:03:12 +02:00
коммит произвёл GitHub
родитель 7af408679e
Коммит b8b3f9b012
2 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@@ -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|\

Просмотреть файл

@@ -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"
@@ -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)
@@ -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))
}
}