[Partial Fix - #16623]: Fix initialism errors in codebase. (#16877)

* Update files in /app

* Update files in /plugin

* Update files in /store

* Update files in /utils

* Update files in /web

* Update store.go

* Update command_response.go

* check-mocks and check-store-layer checks

* Fix build errors

* Revert "Fix build errors"

This reverts commit 4ee38c3d0bf7bd7d8386f46f0985a0d03245a1d4.

* Update .golangci.yml

* make i18n-extract and make i18n-check

* Commit suggestions

* check-mocks and check-store-layers

* Update en.json

* Update product_notices.go

* Update main.go

* Fix translations

* Regenerate mocks

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Claudio Costa <cstcld91@gmail.com>
Этот коммит содержится в:
Haardik Dharma
2021-02-18 20:06:56 +05:30
коммит произвёл GitHub
родитель 5f190b5624
Коммит 6356e906e0
60 изменённых файлов: 2335 добавлений и 2163 удалений

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

@@ -159,7 +159,7 @@ func (s *Server) HTMLTemplates() *template.Template {
}
func (a *App) Handle404(w http.ResponseWriter, r *http.Request) {
ipAddress := utils.GetIpAddress(r, a.Config().ServiceSettings.TrustedProxyIPHeader)
ipAddress := utils.GetIPAddress(r, a.Config().ServiceSettings.TrustedProxyIPHeader)
mlog.Debug("not found handler triggered", mlog.String("path", r.URL.Path), mlog.Int("code", 404), mlog.String("ip", ipAddress))
if *a.Config().ServiceSettings.WebserverMode == "disabled" {

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

@@ -198,7 +198,7 @@ func (a *App) PatchBot(botUserId string, botPatch *model.BotPatch) (*model.Bot,
var appErr *model.AppError
switch {
case errors.As(nErr, &nfErr):
return nil, model.MakeBotNotFoundError(nfErr.Id)
return nil, model.MakeBotNotFoundError(nfErr.ID)
case errors.As(nErr, &appErr): // in case we haven't converted to plain error.
return nil, appErr
default: // last fallback in case it doesn't map to an existing app error.
@@ -215,7 +215,7 @@ func (a *App) GetBot(botUserId string, includeDeleted bool) (*model.Bot, *model.
var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.MakeBotNotFoundError(nfErr.Id)
return nil, model.MakeBotNotFoundError(nfErr.ID)
default: // last fallback in case it doesn't map to an existing app error.
return nil, model.NewAppError("GetBot", "app.bot.getbot.internal_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -254,7 +254,7 @@ func (a *App) UpdateBotActive(botUserId string, active bool) (*model.Bot, *model
var nfErr *store.ErrNotFound
switch {
case errors.As(nErr, &nfErr):
return nil, model.MakeBotNotFoundError(nfErr.Id)
return nil, model.MakeBotNotFoundError(nfErr.ID)
default: // last fallback in case it doesn't map to an existing app error.
return nil, model.NewAppError("UpdateBotActive", "app.bot.getbot.internal_error", nil, nErr.Error(), http.StatusInternalServerError)
}
@@ -276,7 +276,7 @@ func (a *App) UpdateBotActive(botUserId string, active bool) (*model.Bot, *model
var appErr *model.AppError
switch {
case errors.As(nErr, &nfErr):
return nil, model.MakeBotNotFoundError(nfErr.Id)
return nil, model.MakeBotNotFoundError(nfErr.ID)
case errors.As(nErr, &appErr): // in case we haven't converted to plain error.
return nil, appErr
default: // last fallback in case it doesn't map to an existing app error.
@@ -314,7 +314,7 @@ func (a *App) UpdateBotOwner(botUserId, newOwnerId string) (*model.Bot, *model.A
var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.MakeBotNotFoundError(nfErr.Id)
return nil, model.MakeBotNotFoundError(nfErr.ID)
default: // last fallback in case it doesn't map to an existing app error.
return nil, model.NewAppError("UpdateBotOwner", "app.bot.getbot.internal_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -328,7 +328,7 @@ func (a *App) UpdateBotOwner(botUserId, newOwnerId string) (*model.Bot, *model.A
var appErr *model.AppError
switch {
case errors.As(err, &nfErr):
return nil, model.MakeBotNotFoundError(nfErr.Id)
return nil, model.MakeBotNotFoundError(nfErr.ID)
case errors.As(err, &appErr): // in case we haven't converted to plain error.
return nil, appErr
default: // last fallback in case it doesn't map to an existing app error.
@@ -534,7 +534,7 @@ func (a *App) SetBotIconImage(botUserId string, file io.ReadSeeker) *model.AppEr
var appErr *model.AppError
switch {
case errors.As(err, &nfErr):
return model.MakeBotNotFoundError(nfErr.Id)
return model.MakeBotNotFoundError(nfErr.ID)
case errors.As(err, &appErr): // in case we haven't converted to plain error.
return appErr
default: // last fallback in case it doesn't map to an existing app error.
@@ -568,7 +568,7 @@ func (a *App) DeleteBotIconImage(botUserId string) *model.AppError {
var appErr *model.AppError
switch {
case errors.As(err, &nfErr):
return model.MakeBotNotFoundError(nfErr.Id)
return model.MakeBotNotFoundError(nfErr.ID)
case errors.As(err, &appErr): // in case we haven't converted to plain error.
return appErr
default: // last fallback in case it doesn't map to an existing app error.

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

@@ -314,7 +314,7 @@ func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Chan
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.ChannelHasBeenCreated(pluginContext, sc)
return true
}, plugin.ChannelHasBeenCreatedId)
}, plugin.ChannelHasBeenCreatedID)
})
}
@@ -377,7 +377,7 @@ func (a *App) handleCreationEvent(userID, otherUserID string, channel *model.Cha
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.ChannelHasBeenCreated(pluginContext, channel)
return true
}, plugin.ChannelHasBeenCreatedId)
}, plugin.ChannelHasBeenCreatedID)
})
}
@@ -1441,7 +1441,7 @@ func (a *App) AddChannelMember(userID string, channel *model.Channel, userReques
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasJoinedChannel(pluginContext, cm, userRequestor)
return true
}, plugin.UserHasJoinedChannelId)
}, plugin.UserHasJoinedChannelID)
})
}
@@ -1950,7 +1950,7 @@ func (a *App) JoinChannel(channel *model.Channel, userID string) *model.AppError
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasJoinedChannel(pluginContext, cm, nil)
return true
}, plugin.UserHasJoinedChannelId)
}, plugin.UserHasJoinedChannelID)
})
}
@@ -2248,7 +2248,7 @@ func (a *App) removeUserFromChannel(userIDToRemove string, removerUserId string,
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasLeftChannel(pluginContext, cm, actorUser)
return true
}, plugin.UserHasLeftChannelId)
}, plugin.UserHasLeftChannelID)
})
}

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

@@ -298,7 +298,7 @@ func (es *EmailService) SendPasswordResetEmail(email string, token *model.Token,
bodyPage := es.newEmailTemplate("reset_body", locale)
bodyPage.Props["SiteURL"] = siteURL
bodyPage.Props["Title"] = T("api.templates.reset_body.title")
bodyPage.Props["Info1"] = utils.TranslateAsHtml(T, "api.templates.reset_body.info1", nil)
bodyPage.Props["Info1"] = utils.TranslateAsHTML(T, "api.templates.reset_body.info1", nil)
bodyPage.Props["Info2"] = T("api.templates.reset_body.info2")
bodyPage.Props["ResetUrl"] = link
bodyPage.Props["Button"] = T("api.templates.reset_body.button")
@@ -362,10 +362,10 @@ func (es *EmailService) SendInviteEmails(team *model.Team, senderName string, se
bodyPage := es.newEmailTemplate("invite_body", "")
bodyPage.Props["SiteURL"] = siteURL
bodyPage.Props["Title"] = utils.T("api.templates.invite_body.title")
bodyPage.Html["Info"] = utils.TranslateAsHtml(utils.T, "api.templates.invite_body.info",
bodyPage.HTML["Info"] = utils.TranslateAsHTML(utils.T, "api.templates.invite_body.info",
map[string]interface{}{"SenderName": senderName, "TeamDisplayName": team.DisplayName})
bodyPage.Props["Button"] = utils.T("api.templates.invite_body.button")
bodyPage.Html["ExtraInfo"] = utils.TranslateAsHtml(utils.T, "api.templates.invite_body.extra_info",
bodyPage.HTML["ExtraInfo"] = utils.TranslateAsHTML(utils.T, "api.templates.invite_body.extra_info",
map[string]interface{}{"TeamDisplayName": team.DisplayName})
bodyPage.Props["TeamURL"] = siteURL + "/" + team.Name
@@ -421,7 +421,7 @@ func (es *EmailService) sendGuestInviteEmails(team *model.Team, channels []*mode
bodyPage := es.newEmailTemplate("invite_body", "")
bodyPage.Props["SiteURL"] = siteURL
bodyPage.Props["Title"] = utils.T("api.templates.invite_body.title")
bodyPage.Html["Info"] = utils.TranslateAsHtml(utils.T, "api.templates.invite_body_guest.info",
bodyPage.HTML["Info"] = utils.TranslateAsHTML(utils.T, "api.templates.invite_body_guest.info",
map[string]interface{}{"SenderName": senderName, "TeamDisplayName": team.DisplayName})
bodyPage.Props["Button"] = utils.T("api.templates.invite_body.button")
bodyPage.Props["SenderName"] = senderName
@@ -430,7 +430,7 @@ func (es *EmailService) sendGuestInviteEmails(team *model.Team, channels []*mode
if message != "" {
bodyPage.Props["Message"] = message
}
bodyPage.Html["ExtraInfo"] = utils.TranslateAsHtml(utils.T, "api.templates.invite_body.extra_info",
bodyPage.HTML["ExtraInfo"] = utils.TranslateAsHTML(utils.T, "api.templates.invite_body.extra_info",
map[string]interface{}{"TeamDisplayName": team.DisplayName})
bodyPage.Props["TeamURL"] = siteURL + "/" + team.Name

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

@@ -1000,7 +1000,7 @@ func (a *App) DoUploadFileExpectModification(now time.Time, rawTeamId string, ra
}
return true
}, plugin.FileWillBeUploadedId)
}, plugin.FileWillBeUploadedID)
if rejectionError != nil {
return nil, data, rejectionError
}

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

@@ -161,7 +161,7 @@ func (a *App) DoLogin(w http.ResponseWriter, r *http.Request, user *model.User,
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
rejectionReason = hooks.UserWillLogIn(pluginContext, user)
return rejectionReason == ""
}, plugin.UserWillLogInId)
}, plugin.UserWillLogInID)
if rejectionReason != "" {
return model.NewAppError("DoLogin", "Login rejected by plugin: "+rejectionReason, nil, "", http.StatusBadRequest)
@@ -231,7 +231,7 @@ func (a *App) DoLogin(w http.ResponseWriter, r *http.Request, user *model.User,
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasLoggedIn(pluginContext, user)
return true
}, plugin.UserHasLoggedInId)
}, plugin.UserHasLoggedInID)
})
}

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

@@ -767,11 +767,11 @@ func (a *App) GetAuthorizationCode(w http.ResponseWriter, r *http.Request, servi
authUrl := endpoint + "?response_type=code&client_id=" + clientId + "&redirect_uri=" + url.QueryEscape(redirectUri) + "&state=" + url.QueryEscape(state)
if scope != "" {
authUrl += "&scope=" + utils.UrlEncode(scope)
authUrl += "&scope=" + utils.URLEncode(scope)
}
if loginHint != "" {
authUrl += "&login_hint=" + utils.UrlEncode(loginHint)
authUrl += "&login_hint=" + utils.URLEncode(loginHint)
}
return authUrl, nil
@@ -935,7 +935,7 @@ func (a *App) SwitchEmailToOAuth(w http.ResponseWriter, r *http.Request, email,
stateProps["email"] = email
if service == model.USER_AUTH_SERVICE_SAML {
return a.GetSiteURL() + "/login/sso/saml?action=" + model.OAUTH_ACTION_EMAIL_TO_SSO + "&email=" + utils.UrlEncode(email), nil
return a.GetSiteURL() + "/login/sso/saml?action=" + model.OAUTH_ACTION_EMAIL_TO_SSO + "&email=" + utils.URLEncode(email), nil
}
authUrl, err := a.GetAuthorizationCode(w, r, service, stateProps, "")

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

@@ -212,7 +212,7 @@ func (a *App) InitPlugins(pluginDir, webappPluginDir string) {
a.Log().Error("Plugin OnConfigurationChange hook failed", mlog.Err(err))
}
return true
}, plugin.OnConfigurationChangeId)
}, plugin.OnConfigurationChangeID)
}
})
a.Srv().PluginsLock.Unlock()

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

@@ -117,7 +117,7 @@ func (a *App) servePluginRequest(w http.ResponseWriter, r *http.Request, handler
token := ""
context := &plugin.Context{
RequestId: model.NewId(),
IpAddress: utils.GetIpAddress(r, a.Config().ServiceSettings.TrustedProxyIPHeader),
IpAddress: utils.GetIPAddress(r, a.Config().ServiceSettings.TrustedProxyIPHeader),
AcceptLanguage: r.Header.Get("Accept-Language"),
UserAgent: r.UserAgent(),
}

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

@@ -296,7 +296,7 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
}
return true
}, plugin.MessageWillBePostedId)
}, plugin.MessageWillBePostedID)
if rejectionError != nil {
return nil, rejectionError
@@ -329,7 +329,7 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.MessageHasBeenPosted(pluginContext, rPostCopy)
return true
}, plugin.MessageHasBeenPostedId)
}, plugin.MessageHasBeenPostedID)
})
}
@@ -621,7 +621,7 @@ func (a *App) UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
newPost, rejectionReason = hooks.MessageWillBeUpdated(pluginContext, newPost, oldPost)
return post != nil
}, plugin.MessageWillBeUpdatedId)
}, plugin.MessageWillBeUpdatedID)
if newPost == nil {
return nil, model.NewAppError("UpdatePost", "Post rejected by plugin. "+rejectionReason, nil, "", http.StatusBadRequest)
}
@@ -644,7 +644,7 @@ func (a *App) UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.MessageHasBeenUpdated(pluginContext, newPost, oldPost)
return true
}, plugin.MessageHasBeenUpdatedId)
}, plugin.MessageHasBeenUpdatedID)
})
}

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

@@ -350,7 +350,7 @@ func (a *App) UpdateProductNotices() *model.AppError {
cachedDBMSVersion = strings.Split(cachedDBMSVersion, " ")[0] // get rid of trailing strings attached to the version
data, err := utils.GetUrlWithCache(url, &noticesCache, skip)
data, err := utils.GetURLWithCache(url, &noticesCache, skip)
if err != nil {
return model.NewAppError("UpdateProductNotices", "api.system.update_notices.fetch_failed", nil, err.Error(), http.StatusBadRequest)
}

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

@@ -59,10 +59,10 @@ func (rl *RateLimiter) GenerateKey(r *http.Request) string {
if tokenLocation != TokenLocationNotFound {
key += token
} else if rl.useIP { // If we don't find an authentication token and IP based is enabled, fall back to IP
key += utils.GetIpAddress(r, rl.trustedProxyIPHeader)
key += utils.GetIPAddress(r, rl.trustedProxyIPHeader)
}
} else if rl.useIP { // Only if Auth based is not enabed do we use a plain IP based
key += utils.GetIpAddress(r, rl.trustedProxyIPHeader)
key += utils.GetIPAddress(r, rl.trustedProxyIPHeader)
}
// Note that most of the time the user won't have to set this because the utils.GetIpAddress above tries the

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

@@ -58,7 +58,7 @@ func (a *App) SaveReactionForPost(reaction *model.Reaction) (*model.Reaction, *m
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.ReactionHasBeenAdded(pluginContext, reaction)
return true
}, plugin.ReactionHasBeenAddedId)
}, plugin.ReactionHasBeenAddedID)
})
}
@@ -144,7 +144,7 @@ func (a *App) DeleteReactionForPost(reaction *model.Reaction) *model.AppError {
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.ReactionHasBeenRemoved(pluginContext, reaction)
return true
}, plugin.ReactionHasBeenRemovedId)
}, plugin.ReactionHasBeenRemovedID)
})
}

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

@@ -775,7 +775,7 @@ func (a *App) JoinUserToTeam(team *model.Team, user *model.User, userRequestorId
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasJoinedTeam(pluginContext, tm, actor)
return true
}, plugin.UserHasJoinedTeamId)
}, plugin.UserHasJoinedTeamID)
})
}
@@ -1241,7 +1241,7 @@ func (a *App) RemoveTeamMemberFromTeam(teamMember *model.TeamMember, requestorId
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasLeftTeam(pluginContext, teamMember, actor)
return true
}, plugin.UserHasLeftTeamId)
}, plugin.UserHasLeftTeamID)
})
}

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

@@ -54,7 +54,7 @@ func (a *App) runPluginsHook(info *model.FileInfo, file io.Reader) *model.AppErr
info = newInfo
}
return true
}, plugin.FileWillBeUploadedId)
}, plugin.FileWillBeUploadedID)
if rejErr != nil {
errChan <- rejErr
}

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

@@ -285,7 +285,7 @@ func (a *App) createUserOrGuest(user *model.User, guest bool) (*model.User, *mod
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasBeenCreated(pluginContext, user)
return true
}, plugin.UserHasBeenCreatedId)
}, plugin.UserHasBeenCreatedID)
})
}