[MM-23279] Idiomatic naming (IP) (#18152)

Этот коммит содержится в:
Ben Schumacher
2021-08-19 10:33:29 +02:00
коммит произвёл GitHub
родитель 8f01a1b5a1
Коммит e0f51f54e1
21 изменённых файлов: 36 добавлений и 36 удалений

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

@@ -259,7 +259,7 @@ func (a *App) getDynamicListArgument(c *request.Context, commandArgs *model.Comm
pluginContext := pluginContext(c)
params.Add("request_id", pluginContext.RequestId)
params.Add("session_id", pluginContext.SessionId)
params.Add("ip_address", pluginContext.IpAddress)
params.Add("ip_address", pluginContext.IPAddress)
params.Add("accept_language", pluginContext.AcceptLanguage)
params.Add("user_agent", pluginContext.UserAgent)

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

@@ -20,7 +20,7 @@ func pluginContext(c *request.Context) *plugin.Context {
context := &plugin.Context{
RequestId: c.RequestId(),
SessionId: c.Session().Id,
IpAddress: c.IpAddress(),
IPAddress: c.IPAddress(),
AcceptLanguage: c.AcceptLanguage(),
UserAgent: c.UserAgent(),
}

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

@@ -918,7 +918,7 @@ func TestHookContext(t *testing.T) {
mockAPI.On("LoadPluginConfiguration", mock.Anything).Return(nil)
mockAPI.On("LogDebug", ctx.Session().Id).Return(nil)
mockAPI.On("LogInfo", ctx.RequestId()).Return(nil)
mockAPI.On("LogError", ctx.IpAddress()).Return(nil)
mockAPI.On("LogError", ctx.IPAddress()).Return(nil)
mockAPI.On("LogWarn", ctx.AcceptLanguage()).Return(nil)
mockAPI.On("DeleteTeam", ctx.UserAgent()).Return(nil)
@@ -939,7 +939,7 @@ func TestHookContext(t *testing.T) {
func (p *MyPlugin) MessageHasBeenPosted(c *plugin.Context, post *model.Post) {
p.API.LogDebug(c.SessionId)
p.API.LogInfo(c.RequestId)
p.API.LogError(c.IpAddress)
p.API.LogError(c.IPAddress)
p.API.LogWarn(c.AcceptLanguage)
p.API.DeleteTeam(c.UserAgent)
}

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

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

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

@@ -66,7 +66,7 @@ func (rl *RateLimiter) GenerateKey(r *http.Request) string {
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
// Note that most of the time the user won't have to set this because the utils.GetIPAddress above tries the
// most common headers anyway.
if rl.header != "" {
key += strings.ToLower(r.Header.Get(rl.header))

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

@@ -51,7 +51,7 @@ func (c *Context) Session() *model.Session {
func (c *Context) RequestId() string {
return c.requestId
}
func (c *Context) IpAddress() string {
func (c *Context) IPAddress() string {
return c.ipAddress
}
func (c *Context) Path() string {
@@ -78,7 +78,7 @@ func (c *Context) SetT(t i18n.TranslateFunc) {
func (c *Context) SetRequestId(s string) {
c.requestId = s
}
func (c *Context) SetIpAddress(s string) {
func (c *Context) SetIPAddress(s string) {
c.ipAddress = s
}
func (c *Context) SetUserAgent(s string) {