[MM-37772] Idiomatic naming (URL, URI, API) (#18128)
* s/Url/URL/g & s/Uri/URI/g * s/Api/API/g
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a7f5512ff3
Коммит
757dc96461
@@ -288,13 +288,13 @@ func (a *App) notifyAdminsOfWarnMetricStatus(c *request.Context, warnMetricId st
|
||||
actionId := "contactUs"
|
||||
actionName := T("api.server.warn_metric.contact_us")
|
||||
postActionValue := T("api.server.warn_metric.contacting_us")
|
||||
postActionUrl := fmt.Sprintf("/warn_metrics/ack/%s", warnMetricId)
|
||||
postActionURL := fmt.Sprintf("/warn_metrics/ack/%s", warnMetricId)
|
||||
|
||||
if isE0Edition {
|
||||
actionId = "startTrial"
|
||||
actionName = T("api.server.warn_metric.start_trial")
|
||||
postActionValue = T("api.server.warn_metric.starting_trial")
|
||||
postActionUrl = fmt.Sprintf("/warn_metrics/trial-license-ack/%s", warnMetricId)
|
||||
postActionURL = fmt.Sprintf("/warn_metrics/trial-license-ack/%s", warnMetricId)
|
||||
}
|
||||
|
||||
actions := []*model.PostAction{}
|
||||
@@ -318,7 +318,7 @@ func (a *App) notifyAdminsOfWarnMetricStatus(c *request.Context, warnMetricId st
|
||||
"bot_user_id": warnMetricsBot.UserId,
|
||||
"force_ack": false,
|
||||
},
|
||||
URL: postActionUrl,
|
||||
URL: postActionURL,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -162,9 +162,9 @@ type AppIface interface {
|
||||
GetClusterPluginStatuses() (model.PluginStatuses, *model.AppError)
|
||||
// GetConfigFile proxies access to the given configuration file to the underlying config store.
|
||||
GetConfigFile(name string) ([]byte, error)
|
||||
// GetEmojiStaticUrl returns a relative static URL for system default emojis,
|
||||
// GetEmojiStaticURL returns a relative static URL for system default emojis,
|
||||
// and the API route for custom ones. Errors if not found or if custom and deleted.
|
||||
GetEmojiStaticUrl(emojiName string) (string, *model.AppError)
|
||||
GetEmojiStaticURL(emojiName string) (string, *model.AppError)
|
||||
// GetEnvironmentConfig returns a map of configuration keys whose values have been overridden by an environment variable.
|
||||
// If filter is not nil and returns false for a struct field, that field will be omitted.
|
||||
GetEnvironmentConfig(filter func(reflect.StructField) bool) map[string]interface{}
|
||||
@@ -409,7 +409,7 @@ type AppIface interface {
|
||||
AttachDeviceId(sessionID string, deviceID string, expiresAt int64) *model.AppError
|
||||
AttachSessionCookies(c *request.Context, w http.ResponseWriter, r *http.Request)
|
||||
AuthenticateUserForLogin(c *request.Context, id, loginId, password, mfaToken, cwsToken string, ldapOnly bool) (user *model.User, err *model.AppError)
|
||||
AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, state, redirectUri string) (io.ReadCloser, string, map[string]string, *model.User, *model.AppError)
|
||||
AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, state, redirectURI string) (io.ReadCloser, string, map[string]string, *model.User, *model.AppError)
|
||||
AutocompleteChannels(teamID string, term string) (*model.ChannelList, *model.AppError)
|
||||
AutocompleteChannelsForSearch(teamID string, userID string, term string) (*model.ChannelList, *model.AppError)
|
||||
AutocompleteUsersInChannel(teamID string, channelID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError)
|
||||
@@ -650,7 +650,7 @@ type AppIface interface {
|
||||
GetNextPostIdFromPostList(postList *model.PostList, collapsedThreads bool) string
|
||||
GetNotificationNameFormat(user *model.User) string
|
||||
GetNumberOfChannelsOnTeam(teamID string) (int, *model.AppError)
|
||||
GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, code, secret, refreshToken string) (*model.AccessResponse, *model.AppError)
|
||||
GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectURI, code, secret, refreshToken string) (*model.AccessResponse, *model.AppError)
|
||||
GetOAuthAccessTokenForImplicitFlow(userID string, authRequest *model.AuthorizeRequest) (*model.Session, *model.AppError)
|
||||
GetOAuthApp(appID string) (*model.OAuthApp, *model.AppError)
|
||||
GetOAuthApps(page, perPage int) ([]*model.OAuthApp, *model.AppError)
|
||||
@@ -709,7 +709,7 @@ type AppIface interface {
|
||||
GetRolesByNames(names []string) ([]*model.Role, *model.AppError)
|
||||
GetSamlCertificateStatus() *model.SamlCertificateStatus
|
||||
GetSamlMetadata() (string, *model.AppError)
|
||||
GetSamlMetadataFromIdp(idpMetadataUrl string) (*model.SamlMetadataResponse, *model.AppError)
|
||||
GetSamlMetadataFromIdp(idpMetadataURL string) (*model.SamlMetadataResponse, *model.AppError)
|
||||
GetSanitizeOptions(asAdmin bool) map[string]bool
|
||||
GetScheme(id string) (*model.Scheme, *model.AppError)
|
||||
GetSchemeByName(name string) (*model.Scheme, *model.AppError)
|
||||
|
||||
@@ -27,7 +27,7 @@ func (a *App) DownloadFromURL(downloadURL string) ([]byte, error) {
|
||||
}
|
||||
|
||||
func (s *Server) downloadFromURL(downloadURL string) ([]byte, error) {
|
||||
if !model.IsValidHTTPUrl(downloadURL) {
|
||||
if !model.IsValidHTTPURL(downloadURL) {
|
||||
return nil, errors.Errorf("invalid url %s", downloadURL)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func (s *Server) downloadFromURL(downloadURL string) ([]byte, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("failed to parse url %s", downloadURL)
|
||||
}
|
||||
if !*s.Config().PluginSettings.AllowInsecureDownloadUrl && u.Scheme != "https" {
|
||||
if !*s.Config().PluginSettings.AllowInsecureDownloadURL && u.Scheme != "https" {
|
||||
return nil, errors.Errorf("insecure url not allowed %s", downloadURL)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestDownloadFromURL(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
app := th.App
|
||||
app.Config().PluginSettings.AllowInsecureDownloadUrl = model.NewBool(true)
|
||||
app.Config().PluginSettings.AllowInsecureDownloadURL = model.NewBool(true)
|
||||
|
||||
// To keep track of how many times an endpoint is retried. This needs to be reset
|
||||
// for each test run.
|
||||
|
||||
@@ -274,9 +274,9 @@ func (a *App) SearchEmoji(name string, prefixOnly bool, limit int) ([]*model.Emo
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// GetEmojiStaticUrl returns a relative static URL for system default emojis,
|
||||
// GetEmojiStaticURL returns a relative static URL for system default emojis,
|
||||
// and the API route for custom ones. Errors if not found or if custom and deleted.
|
||||
func (a *App) GetEmojiStaticUrl(emojiName string) (string, *model.AppError) {
|
||||
func (a *App) GetEmojiStaticURL(emojiName string) (string, *model.AppError) {
|
||||
subPath, _ := utils.GetSubpathFromConfig(a.Config())
|
||||
|
||||
if id, found := model.GetSystemEmojiId(emojiName); found {
|
||||
@@ -290,9 +290,9 @@ func (a *App) GetEmojiStaticUrl(emojiName string) (string, *model.AppError) {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return "", model.NewAppError("GetEmojiStaticUrl", "app.emoji.get_by_name.no_result", nil, err.Error(), http.StatusNotFound)
|
||||
return "", model.NewAppError("GetEmojiStaticURL", "app.emoji.get_by_name.no_result", nil, err.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return "", model.NewAppError("GetEmojiStaticUrl", "app.emoji.get_by_name.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return "", model.NewAppError("GetEmojiStaticURL", "app.emoji.get_by_name.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -530,7 +530,7 @@ func TestSubmitInteractiveDialog(t *testing.T) {
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
setupPluginApiTest(t,
|
||||
setupPluginAPITest(t,
|
||||
`
|
||||
package main
|
||||
|
||||
@@ -818,7 +818,7 @@ func TestPostActionRelativePluginURL(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
setupPluginApiTest(t,
|
||||
setupPluginAPITest(t,
|
||||
`
|
||||
package main
|
||||
|
||||
@@ -1016,7 +1016,7 @@ func TestDoPluginRequest(t *testing.T) {
|
||||
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost,127.0.0.1"
|
||||
})
|
||||
|
||||
setupPluginApiTest(t,
|
||||
setupPluginAPITest(t,
|
||||
`
|
||||
package main
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@ func (a *App) sendToPushProxy(msg *model.PushNotification, session *model.Sessio
|
||||
mlog.String("status", model.PushSendPrepare),
|
||||
)
|
||||
|
||||
url := strings.TrimRight(*a.Config().EmailSettings.PushNotificationServer, "/") + model.ApiUrlSuffixV1 + "/send_push"
|
||||
url := strings.TrimRight(*a.Config().EmailSettings.PushNotificationServer, "/") + model.APIURLSuffixV1 + "/send_push"
|
||||
request, err := http.NewRequest("POST", url, strings.NewReader(msg.ToJson()))
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -403,7 +403,7 @@ func (a *App) SendAckToPushProxy(ack *model.PushNotificationAck) error {
|
||||
|
||||
request, err := http.NewRequest(
|
||||
"POST",
|
||||
strings.TrimRight(*a.Config().EmailSettings.PushNotificationServer, "/")+model.ApiUrlSuffixV1+"/ack",
|
||||
strings.TrimRight(*a.Config().EmailSettings.PushNotificationServer, "/")+model.APIURLSuffixV1+"/ack",
|
||||
strings.NewReader(ack.ToJson()),
|
||||
)
|
||||
|
||||
@@ -571,7 +571,7 @@ func (a *App) buildFullPushNotificationMessage(contentsConfig string, post *mode
|
||||
}
|
||||
|
||||
if oi, ok := post.GetProp("override_icon_url").(string); ok && *cfg.ServiceSettings.EnablePostIconOverride {
|
||||
msg.OverrideIconUrl = oi
|
||||
msg.OverrideIconURL = oi
|
||||
}
|
||||
|
||||
if fw, ok := post.GetProp("from_webhook").(string); ok {
|
||||
|
||||
58
app/oauth.go
58
app/oauth.go
@@ -159,18 +159,18 @@ func (a *App) GetOAuthImplicitRedirect(userID string, authRequest *model.Authori
|
||||
values.Add("scope", authRequest.Scope)
|
||||
values.Add("state", authRequest.State)
|
||||
|
||||
return fmt.Sprintf("%s#%s", authRequest.RedirectUri, values.Encode()), nil
|
||||
return fmt.Sprintf("%s#%s", authRequest.RedirectURI, values.Encode()), nil
|
||||
}
|
||||
|
||||
func (a *App) GetOAuthCodeRedirect(userID string, authRequest *model.AuthorizeRequest) (string, *model.AppError) {
|
||||
authData := &model.AuthData{UserId: userID, ClientId: authRequest.ClientId, CreateAt: model.GetMillis(), RedirectUri: authRequest.RedirectUri, State: authRequest.State, Scope: authRequest.Scope}
|
||||
authData := &model.AuthData{UserId: userID, ClientId: authRequest.ClientId, CreateAt: model.GetMillis(), RedirectUri: authRequest.RedirectURI, State: authRequest.State, Scope: authRequest.Scope}
|
||||
authData.Code = model.NewId() + model.NewId()
|
||||
|
||||
if _, err := a.Srv().Store.OAuth().SaveAuthData(authData); err != nil {
|
||||
return authRequest.RedirectUri + "?error=server_error&state=" + authRequest.State, nil
|
||||
return authRequest.RedirectURI + "?error=server_error&state=" + authRequest.State, nil
|
||||
}
|
||||
|
||||
return authRequest.RedirectUri + "?code=" + url.QueryEscape(authData.Code) + "&state=" + url.QueryEscape(authData.State), nil
|
||||
return authRequest.RedirectURI + "?code=" + url.QueryEscape(authData.Code) + "&state=" + url.QueryEscape(authData.State), nil
|
||||
}
|
||||
|
||||
func (a *App) AllowOAuthAppAccessToUser(userID string, authRequest *model.AuthorizeRequest) (string, *model.AppError) {
|
||||
@@ -193,7 +193,7 @@ func (a *App) AllowOAuthAppAccessToUser(userID string, authRequest *model.Author
|
||||
}
|
||||
}
|
||||
|
||||
if !oauthApp.IsValidRedirectURL(authRequest.RedirectUri) {
|
||||
if !oauthApp.IsValidRedirectURL(authRequest.RedirectURI) {
|
||||
return "", model.NewAppError("AllowOAuthAppAccessToUser", "api.oauth.allow_oauth.redirect_callback.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -205,12 +205,12 @@ func (a *App) AllowOAuthAppAccessToUser(userID string, authRequest *model.Author
|
||||
case model.ImplicitResponseType:
|
||||
redirectURI, err = a.GetOAuthImplicitRedirect(userID, authRequest)
|
||||
default:
|
||||
return authRequest.RedirectUri + "?error=unsupported_response_type&state=" + authRequest.State, nil
|
||||
return authRequest.RedirectURI + "?error=unsupported_response_type&state=" + authRequest.State, nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
mlog.Warn("error getting oauth redirect uri", mlog.Err(err))
|
||||
return authRequest.RedirectUri + "?error=server_error&state=" + authRequest.State, nil
|
||||
return authRequest.RedirectURI + "?error=server_error&state=" + authRequest.State, nil
|
||||
}
|
||||
|
||||
// This saves the OAuth2 app as authorized
|
||||
@@ -223,7 +223,7 @@ func (a *App) AllowOAuthAppAccessToUser(userID string, authRequest *model.Author
|
||||
|
||||
if nErr := a.Srv().Store.Preference().Save(&model.Preferences{authorizedApp}); nErr != nil {
|
||||
mlog.Warn("error saving store preference", mlog.Err(nErr))
|
||||
return authRequest.RedirectUri + "?error=server_error&state=" + authRequest.State, nil
|
||||
return authRequest.RedirectURI + "?error=server_error&state=" + authRequest.State, nil
|
||||
}
|
||||
|
||||
return redirectURI, nil
|
||||
@@ -249,7 +249,7 @@ func (a *App) GetOAuthAccessTokenForImplicitFlow(userID string, authRequest *mod
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accessData := &model.AccessData{ClientId: authRequest.ClientId, UserId: user.Id, Token: session.Token, RefreshToken: "", RedirectUri: authRequest.RedirectUri, ExpiresAt: session.ExpiresAt, Scope: authRequest.Scope}
|
||||
accessData := &model.AccessData{ClientId: authRequest.ClientId, UserId: user.Id, Token: session.Token, RefreshToken: "", RedirectUri: authRequest.RedirectURI, ExpiresAt: session.ExpiresAt, Scope: authRequest.Scope}
|
||||
|
||||
if _, err := a.Srv().Store.OAuth().SaveAccessData(accessData); err != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_saving.app_error", nil, "", http.StatusInternalServerError)
|
||||
@@ -258,7 +258,7 @@ func (a *App) GetOAuthAccessTokenForImplicitFlow(userID string, authRequest *mod
|
||||
return session, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, code, secret, refreshToken string) (*model.AccessResponse, *model.AppError) {
|
||||
func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectURI, code, secret, refreshToken string) (*model.AccessResponse, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableOAuthServiceProvider {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
@@ -289,7 +289,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.expired_code.app_error", nil, "", http.StatusForbidden)
|
||||
}
|
||||
|
||||
if authData.RedirectUri != redirectUri {
|
||||
if authData.RedirectUri != redirectURI {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.redirect_uri.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accessData = &model.AccessData{ClientId: clientId, UserId: user.Id, Token: session.Token, RefreshToken: model.NewId(), RedirectUri: redirectUri, ExpiresAt: session.ExpiresAt, Scope: authData.Scope}
|
||||
accessData = &model.AccessData{ClientId: clientId, UserId: user.Id, Token: session.Token, RefreshToken: model.NewId(), RedirectUri: redirectURI, ExpiresAt: session.ExpiresAt, Scope: authData.Scope}
|
||||
|
||||
if _, nErr = a.Srv().Store.OAuth().SaveAccessData(accessData); nErr != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_saving.app_error", nil, "", http.StatusInternalServerError)
|
||||
@@ -427,12 +427,12 @@ func (a *App) GetOAuthLoginEndpoint(w http.ResponseWriter, r *http.Request, serv
|
||||
|
||||
stateProps[model.UserAuthServiceIsMobile] = strconv.FormatBool(isMobile)
|
||||
|
||||
authUrl, err := a.GetAuthorizationCode(w, r, service, stateProps, loginHint)
|
||||
authURL, err := a.GetAuthorizationCode(w, r, service, stateProps, loginHint)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return authUrl, nil
|
||||
return authURL, nil
|
||||
}
|
||||
|
||||
func (a *App) GetOAuthSignupEndpoint(w http.ResponseWriter, r *http.Request, service, teamID string) (string, *model.AppError) {
|
||||
@@ -442,12 +442,12 @@ func (a *App) GetOAuthSignupEndpoint(w http.ResponseWriter, r *http.Request, ser
|
||||
stateProps["team_id"] = teamID
|
||||
}
|
||||
|
||||
authUrl, err := a.GetAuthorizationCode(w, r, service, stateProps, "")
|
||||
authURL, err := a.GetAuthorizationCode(w, r, service, stateProps, "")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return authUrl, nil
|
||||
return authURL, nil
|
||||
}
|
||||
|
||||
func (a *App) GetAuthorizedAppsForUser(userID string, page, perPage int) ([]*model.OAuthApp, *model.AppError) {
|
||||
@@ -746,27 +746,27 @@ func (a *App) GetAuthorizationCode(w http.ResponseWriter, r *http.Request, servi
|
||||
props["token"] = stateToken.Token
|
||||
state := b64.StdEncoding.EncodeToString([]byte(model.MapToJson(props)))
|
||||
|
||||
siteUrl := a.GetSiteURL()
|
||||
if strings.TrimSpace(siteUrl) == "" {
|
||||
siteUrl = GetProtocol(r) + "://" + r.Host
|
||||
siteURL := a.GetSiteURL()
|
||||
if strings.TrimSpace(siteURL) == "" {
|
||||
siteURL = GetProtocol(r) + "://" + r.Host
|
||||
}
|
||||
|
||||
redirectUri := siteUrl + "/signup/" + service + "/complete"
|
||||
redirectURI := siteURL + "/signup/" + service + "/complete"
|
||||
|
||||
authUrl := endpoint + "?response_type=code&client_id=" + clientId + "&redirect_uri=" + url.QueryEscape(redirectUri) + "&state=" + url.QueryEscape(state)
|
||||
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
|
||||
return authURL, nil
|
||||
}
|
||||
|
||||
func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, state, redirectUri string) (io.ReadCloser, string, map[string]string, *model.User, *model.AppError) {
|
||||
func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, state, redirectURI string) (io.ReadCloser, string, map[string]string, *model.User, *model.AppError) {
|
||||
provider, e := a.getSSOProvider(service)
|
||||
if e != nil {
|
||||
return nil, "", nil, nil, e
|
||||
@@ -830,7 +830,7 @@ func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service
|
||||
p.Set("client_secret", *sso.Secret)
|
||||
p.Set("code", code)
|
||||
p.Set("grant_type", model.AccessTokenGrantType)
|
||||
p.Set("redirect_uri", redirectUri)
|
||||
p.Set("redirect_uri", redirectURI)
|
||||
|
||||
req, requestErr := http.NewRequest("POST", *sso.TokenEndpoint, strings.NewReader(p.Encode()))
|
||||
if requestErr != nil {
|
||||
@@ -873,7 +873,7 @@ func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service
|
||||
}
|
||||
}
|
||||
|
||||
req, requestErr = http.NewRequest("GET", *sso.UserApiEndpoint, strings.NewReader(""))
|
||||
req, requestErr = http.NewRequest("GET", *sso.UserAPIEndpoint, strings.NewReader(""))
|
||||
if requestErr != nil {
|
||||
return nil, "", stateProps, nil, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.service.app_error", map[string]interface{}{"Service": service}, requestErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -928,12 +928,12 @@ func (a *App) SwitchEmailToOAuth(w http.ResponseWriter, r *http.Request, email,
|
||||
return a.GetSiteURL() + "/login/sso/saml?action=" + model.OAuthActionEmailToSSO + "&email=" + utils.URLEncode(email), nil
|
||||
}
|
||||
|
||||
authUrl, err := a.GetAuthorizationCode(w, r, service, stateProps, "")
|
||||
authURL, err := a.GetAuthorizationCode(w, r, service, stateProps, "")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return authUrl, nil
|
||||
return authURL, nil
|
||||
}
|
||||
|
||||
func (a *App) SwitchOAuthToEmail(email, password, requesterId string) (string, *model.AppError) {
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestGetOAuthAccessTokenForImplicitFlow(t *testing.T) {
|
||||
authRequest := &model.AuthorizeRequest{
|
||||
ResponseType: model.ImplicitResponseType,
|
||||
ClientId: oapp.Id,
|
||||
RedirectUri: oapp.CallbackUrls[0],
|
||||
RedirectURI: oapp.CallbackUrls[0],
|
||||
Scope: "",
|
||||
State: "123",
|
||||
}
|
||||
@@ -142,9 +142,9 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}
|
||||
|
||||
if userEndpoint {
|
||||
*cfg.GitLabSettings.UserApiEndpoint = serverURL + "/user"
|
||||
*cfg.GitLabSettings.UserAPIEndpoint = serverURL + "/user"
|
||||
} else {
|
||||
*cfg.GitLabSettings.UserApiEndpoint = ""
|
||||
*cfg.GitLabSettings.UserAPIEndpoint = ""
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -746,7 +746,7 @@ func (a *OpenTracingAppLayer) AuthenticateUserForLogin(c *request.Context, id st
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service string, code string, state string, redirectUri string) (io.ReadCloser, string, map[string]string, *model.User, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service string, code string, state string, redirectURI string) (io.ReadCloser, string, map[string]string, *model.User, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AuthorizeOAuthUser")
|
||||
|
||||
@@ -758,7 +758,7 @@ func (a *OpenTracingAppLayer) AuthorizeOAuthUser(w http.ResponseWriter, r *http.
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1, resultVar2, resultVar3, resultVar4 := a.app.AuthorizeOAuthUser(w, r, service, code, state, redirectUri)
|
||||
resultVar0, resultVar1, resultVar2, resultVar3, resultVar4 := a.app.AuthorizeOAuthUser(w, r, service, code, state, redirectURI)
|
||||
|
||||
if resultVar4 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar4))
|
||||
@@ -5568,9 +5568,9 @@ func (a *OpenTracingAppLayer) GetEmojiList(page int, perPage int, sort string) (
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetEmojiStaticUrl(emojiName string) (string, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetEmojiStaticURL(emojiName string) (string, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetEmojiStaticUrl")
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetEmojiStaticURL")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store.SetContext(newCtx)
|
||||
@@ -5580,7 +5580,7 @@ func (a *OpenTracingAppLayer) GetEmojiStaticUrl(emojiName string) (string, *mode
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetEmojiStaticUrl(emojiName)
|
||||
resultVar0, resultVar1 := a.app.GetEmojiStaticURL(emojiName)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -6753,7 +6753,7 @@ func (a *OpenTracingAppLayer) GetNumberOfChannelsOnTeam(teamID string) (int, *mo
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetOAuthAccessTokenForCodeFlow(clientId string, grantType string, redirectUri string, code string, secret string, refreshToken string) (*model.AccessResponse, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetOAuthAccessTokenForCodeFlow(clientId string, grantType string, redirectURI string, code string, secret string, refreshToken string) (*model.AccessResponse, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetOAuthAccessTokenForCodeFlow")
|
||||
|
||||
@@ -6765,7 +6765,7 @@ func (a *OpenTracingAppLayer) GetOAuthAccessTokenForCodeFlow(clientId string, gr
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, code, secret, refreshToken)
|
||||
resultVar0, resultVar1 := a.app.GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectURI, code, secret, refreshToken)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -8158,7 +8158,7 @@ func (a *OpenTracingAppLayer) GetSamlMetadata() (string, *model.AppError) {
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetSamlMetadataFromIdp(idpMetadataUrl string) (*model.SamlMetadataResponse, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetSamlMetadataFromIdp(idpMetadataURL string) (*model.SamlMetadataResponse, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetSamlMetadataFromIdp")
|
||||
|
||||
@@ -8170,7 +8170,7 @@ func (a *OpenTracingAppLayer) GetSamlMetadataFromIdp(idpMetadataUrl string) (*mo
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetSamlMetadataFromIdp(idpMetadataUrl)
|
||||
resultVar0, resultVar1 := a.app.GetSamlMetadataFromIdp(idpMetadataURL)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
|
||||
@@ -755,7 +755,7 @@ func (a *App) getAddEnvironmentSubsectionPermissions() (permissionsMap, error) {
|
||||
transformations = append(transformations, permissionTransformation{
|
||||
On: permissionExists(model.PermissionSysconsoleWriteEnvironmentWebServer.Id),
|
||||
Add: []string{
|
||||
model.PermissionTestSiteUrl.Id,
|
||||
model.PermissionTestSiteURL.Id,
|
||||
model.PermissionReloadConfig.Id,
|
||||
model.PermissionInvalidateCaches.Id,
|
||||
},
|
||||
|
||||
@@ -195,11 +195,11 @@ func (s *Server) initPlugins(c *request.Context, pluginDir, webappPluginDir stri
|
||||
return
|
||||
}
|
||||
|
||||
newApiFunc := func(manifest *model.Manifest) plugin.API {
|
||||
newAPIFunc := func(manifest *model.Manifest) plugin.API {
|
||||
return New(ServerConnector(s)).NewPluginAPI(c, manifest)
|
||||
}
|
||||
|
||||
env, err := plugin.NewEnvironment(newApiFunc, NewDriverImpl(s), pluginDir, webappPluginDir, s.Log, s.Metrics)
|
||||
env, err := plugin.NewEnvironment(newAPIFunc, NewDriverImpl(s), pluginDir, webappPluginDir, s.Log, s.Metrics)
|
||||
if err != nil {
|
||||
mlog.Error("Failed to start up plugins", mlog.Err(err))
|
||||
return
|
||||
@@ -553,7 +553,7 @@ func (s *Server) getPrepackagedPlugin(pluginID, version string) (*plugin.Prepack
|
||||
// getRemoteMarketplacePlugin returns plugin from marketplace-server.
|
||||
func (s *Server) getRemoteMarketplacePlugin(pluginID, version string) (*model.BaseMarketplacePlugin, *model.AppError) {
|
||||
marketplaceClient, err := marketplace.NewClient(
|
||||
*s.Config().PluginSettings.MarketplaceUrl,
|
||||
*s.Config().PluginSettings.MarketplaceURL,
|
||||
s.HTTPService(),
|
||||
)
|
||||
if err != nil {
|
||||
@@ -581,7 +581,7 @@ func (a *App) getRemotePlugins() (map[string]*model.MarketplacePlugin, *model.Ap
|
||||
}
|
||||
|
||||
marketplaceClient, err := marketplace.NewClient(
|
||||
*a.Config().PluginSettings.MarketplaceUrl,
|
||||
*a.Config().PluginSettings.MarketplaceURL,
|
||||
a.HTTPService(),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -69,7 +69,7 @@ func setDefaultPluginConfig(th *TestHelper, pluginID string) {
|
||||
})
|
||||
}
|
||||
|
||||
func setupMultiPluginApiTest(t *testing.T, pluginCodes []string, pluginManifests []string, pluginIDs []string, asMain bool, app *App, c *request.Context) string {
|
||||
func setupMultiPluginAPITest(t *testing.T, pluginCodes []string, pluginManifests []string, pluginIDs []string, asMain bool, app *App, c *request.Context) string {
|
||||
pluginDir, err := ioutil.TempDir("", "")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
@@ -124,10 +124,10 @@ func setupMultiPluginApiTest(t *testing.T, pluginCodes []string, pluginManifests
|
||||
return pluginDir
|
||||
}
|
||||
|
||||
func setupPluginApiTest(t *testing.T, pluginCode string, pluginManifest string, pluginID string, app *App, c *request.Context) string {
|
||||
func setupPluginAPITest(t *testing.T, pluginCode string, pluginManifest string, pluginID string, app *App, c *request.Context) string {
|
||||
|
||||
asMain := pluginID != "test_db_driver"
|
||||
return setupMultiPluginApiTest(t,
|
||||
return setupMultiPluginAPITest(t,
|
||||
[]string{pluginCode}, []string{pluginManifest}, []string{pluginID},
|
||||
asMain, app, c)
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func TestPublicFilesPathConfiguration(t *testing.T) {
|
||||
|
||||
pluginID := "com.mattermost.sample"
|
||||
|
||||
pluginDir := setupPluginApiTest(t,
|
||||
pluginDir := setupPluginAPITest(t,
|
||||
`
|
||||
package main
|
||||
|
||||
@@ -847,9 +847,9 @@ func TestPluginAPIInstallPlugin(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInstallPlugin(t *testing.T) {
|
||||
// TODO(ilgooz): remove this setup func to use existent setupPluginApiTest().
|
||||
// following setupTest() func is a modified version of setupPluginApiTest().
|
||||
// we need a modified version of setupPluginApiTest() because it wasn't possible to use it directly here
|
||||
// TODO(ilgooz): remove this setup func to use existent setupPluginAPITest().
|
||||
// following setupTest() func is a modified version of setupPluginAPITest().
|
||||
// we need a modified version of setupPluginAPITest() because it wasn't possible to use it directly here
|
||||
// since it removes plugin dirs right after it returns, does not update App configs with the plugin
|
||||
// dirs and this behavior tends to break this test as a result.
|
||||
setupTest := func(t *testing.T, pluginCode string, pluginManifest string, pluginID string, app *App, c *request.Context) (func(), string) {
|
||||
@@ -1067,7 +1067,7 @@ func pluginAPIHookTest(t *testing.T, th *TestHelper, fileName string, id string,
|
||||
schema = settingsSchema
|
||||
}
|
||||
th.App.srv.sqlStore = th.GetSqlStore()
|
||||
setupPluginApiTest(t, code,
|
||||
setupPluginAPITest(t, code,
|
||||
fmt.Sprintf(`{"id": "%v", "server": {"executable": "backend.exe"}, "settings_schema": %v}`, id, schema),
|
||||
id, th.App, th.Context)
|
||||
hooks, err := th.App.GetPluginsEnvironment().HooksForPlugin(id)
|
||||
@@ -1404,7 +1404,7 @@ func TestInterpluginPluginHTTP(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
setupMultiPluginApiTest(t,
|
||||
setupMultiPluginAPITest(t,
|
||||
[]string{`
|
||||
package main
|
||||
|
||||
@@ -1529,7 +1529,7 @@ func TestInterpluginPluginHTTP(t *testing.T) {
|
||||
assert.Equal(t, "ok", ret)
|
||||
}
|
||||
|
||||
func TestApiMetrics(t *testing.T) {
|
||||
func TestAPIMetrics(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1581,7 +1581,7 @@ func TestApiMetrics(t *testing.T) {
|
||||
metricsMock.On("ObservePluginMultiHookDuration", mock.Anything).Return()
|
||||
|
||||
// Setup mocks
|
||||
metricsMock.On("ObservePluginApiDuration", pluginID, "UpdateUser", true, mock.Anything).Return()
|
||||
metricsMock.On("ObservePluginAPIDuration", pluginID, "UpdateUser", true, mock.Anything).Return()
|
||||
|
||||
_, _, activationErr := env.Activate(pluginID)
|
||||
require.NoError(t, activationErr)
|
||||
|
||||
@@ -1093,7 +1093,7 @@ func TestHookMetrics(t *testing.T) {
|
||||
metricsMock.On("ObservePluginHookDuration", pluginID, "UserHasBeenCreated", true, mock.Anything).Return()
|
||||
|
||||
// Don't care about these calls.
|
||||
metricsMock.On("ObservePluginApiDuration", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
metricsMock.On("ObservePluginAPIDuration", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
metricsMock.On("ObservePluginMultiHookIterationDuration", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
metricsMock.On("ObservePluginMultiHookDuration", mock.Anything).Return()
|
||||
|
||||
|
||||
@@ -87,8 +87,8 @@ func (a *App) OverrideIconURLIfEmoji(post *model.Post) {
|
||||
|
||||
emojiName = strings.ReplaceAll(emojiName, ":", "")
|
||||
|
||||
if emojiUrl, err := a.GetEmojiStaticUrl(emojiName); err == nil {
|
||||
post.AddProp(model.PostPropsOverrideIconUrl, emojiUrl)
|
||||
if emojiURL, err := a.GetEmojiStaticURL(emojiName); err == nil {
|
||||
post.AddProp(model.PostPropsOverrideIconURL, emojiURL)
|
||||
} else {
|
||||
mlog.Warn("Failed to retrieve URL for overridden profile icon (emoji)", mlog.String("emojiName", emojiName), mlog.Err(err))
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
|
||||
require.Nil(t, err)
|
||||
|
||||
post.AddProp(model.PostPropsOverrideIconUrl, url)
|
||||
post.AddProp(model.PostPropsOverrideIconURL, url)
|
||||
post.AddProp(model.PostPropsOverrideIconEmoji, emoji)
|
||||
|
||||
return th.App.PreparePostForClient(post, false, false)
|
||||
@@ -309,12 +309,12 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
|
||||
emoji := "basketball"
|
||||
url := "http://host.com/image.png"
|
||||
overridenUrl := "/static/emoji/1f3c0.png"
|
||||
overridenURL := "/static/emoji/1f3c0.png"
|
||||
|
||||
t.Run("does not override icon URL", func(t *testing.T) {
|
||||
clientPost := prepare(false, url, emoji)
|
||||
|
||||
s, ok := clientPost.GetProps()[model.PostPropsOverrideIconUrl]
|
||||
s, ok := clientPost.GetProps()[model.PostPropsOverrideIconURL]
|
||||
assert.True(t, ok)
|
||||
assert.EqualValues(t, url, s)
|
||||
s, ok = clientPost.GetProps()[model.PostPropsOverrideIconEmoji]
|
||||
@@ -325,9 +325,9 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
t.Run("overrides icon URL", func(t *testing.T) {
|
||||
clientPost := prepare(true, url, emoji)
|
||||
|
||||
s, ok := clientPost.GetProps()[model.PostPropsOverrideIconUrl]
|
||||
s, ok := clientPost.GetProps()[model.PostPropsOverrideIconURL]
|
||||
assert.True(t, ok)
|
||||
assert.EqualValues(t, overridenUrl, s)
|
||||
assert.EqualValues(t, overridenURL, s)
|
||||
s, ok = clientPost.GetProps()[model.PostPropsOverrideIconEmoji]
|
||||
assert.True(t, ok)
|
||||
assert.EqualValues(t, emoji, s)
|
||||
@@ -337,9 +337,9 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
colonEmoji := ":basketball:"
|
||||
clientPost := prepare(true, url, colonEmoji)
|
||||
|
||||
s, ok := clientPost.GetProps()[model.PostPropsOverrideIconUrl]
|
||||
s, ok := clientPost.GetProps()[model.PostPropsOverrideIconURL]
|
||||
assert.True(t, ok)
|
||||
assert.EqualValues(t, overridenUrl, s)
|
||||
assert.EqualValues(t, overridenURL, s)
|
||||
s, ok = clientPost.GetProps()[model.PostPropsOverrideIconEmoji]
|
||||
assert.True(t, ok)
|
||||
assert.EqualValues(t, colonEmoji, s)
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestCreatePostDeduplicate(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("post rejected by plugin leaves cache ready for non-deduplicated try", func(t *testing.T) {
|
||||
setupPluginApiTest(t, `
|
||||
setupPluginAPITest(t, `
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -102,7 +102,7 @@ func TestCreatePostDeduplicate(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("slow posting after cache entry blocks duplicate request", func(t *testing.T) {
|
||||
setupPluginApiTest(t, `
|
||||
setupPluginAPITest(t, `
|
||||
package main
|
||||
|
||||
import (
|
||||
|
||||
12
app/saml.go
12
app/saml.go
@@ -178,17 +178,17 @@ func (a *App) GetSamlCertificateStatus() *model.SamlCertificateStatus {
|
||||
return status
|
||||
}
|
||||
|
||||
func (a *App) GetSamlMetadataFromIdp(idpMetadataUrl string) (*model.SamlMetadataResponse, *model.AppError) {
|
||||
func (a *App) GetSamlMetadataFromIdp(idpMetadataURL string) (*model.SamlMetadataResponse, *model.AppError) {
|
||||
if a.Saml() == nil {
|
||||
err := model.NewAppError("GetSamlMetadataFromIdp", "api.admin.saml.not_available.app_error", nil, "", http.StatusNotImplemented)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(idpMetadataUrl, "http://") && !strings.HasPrefix(idpMetadataUrl, "https://") {
|
||||
idpMetadataUrl = "https://" + idpMetadataUrl
|
||||
if !strings.HasPrefix(idpMetadataURL, "http://") && !strings.HasPrefix(idpMetadataURL, "https://") {
|
||||
idpMetadataURL = "https://" + idpMetadataURL
|
||||
}
|
||||
|
||||
idpMetadataRaw, err := a.FetchSamlMetadataFromIdp(idpMetadataUrl)
|
||||
idpMetadataRaw, err := a.FetchSamlMetadataFromIdp(idpMetadataURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -228,7 +228,7 @@ func (a *App) BuildSamlMetadataObject(idpMetadata []byte) (*model.SamlMetadataRe
|
||||
}
|
||||
|
||||
data := &model.SamlMetadataResponse{}
|
||||
data.IdpDescriptorUrl = entityDescriptor.EntityID
|
||||
data.IdpDescriptorURL = entityDescriptor.EntityID
|
||||
|
||||
if entityDescriptor.IDPSSODescriptors == nil || len(entityDescriptor.IDPSSODescriptors) == 0 {
|
||||
err := model.NewAppError("BuildSamlMetadataObject", "api.admin.saml.invalid_xml_missing_idpssodescriptors.app_error", nil, "", http.StatusInternalServerError)
|
||||
@@ -241,7 +241,7 @@ func (a *App) BuildSamlMetadataObject(idpMetadata []byte) (*model.SamlMetadataRe
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data.IdpUrl = idpSSODescriptor.SingleSignOnServices[0].Location
|
||||
data.IdpURL = idpSSODescriptor.SingleSignOnServices[0].Location
|
||||
if idpSSODescriptor.SSODescriptor.RoleDescriptor.KeyDescriptors == nil || len(idpSSODescriptor.SSODescriptor.RoleDescriptor.KeyDescriptors) == 0 {
|
||||
err := model.NewAppError("BuildSamlMetadataObject", "api.admin.saml.invalid_xml_missing_keydescriptor.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, err
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func (a *App) TestElasticsearch(cfg *model.Config) *model.AppError {
|
||||
if *cfg.ElasticsearchSettings.Password == model.FakeSetting {
|
||||
if *cfg.ElasticsearchSettings.ConnectionUrl == *a.Config().ElasticsearchSettings.ConnectionUrl && *cfg.ElasticsearchSettings.Username == *a.Config().ElasticsearchSettings.Username {
|
||||
if *cfg.ElasticsearchSettings.ConnectionURL == *a.Config().ElasticsearchSettings.ConnectionURL && *cfg.ElasticsearchSettings.Username == *a.Config().ElasticsearchSettings.Username {
|
||||
*cfg.ElasticsearchSettings.Password = *a.Config().ElasticsearchSettings.Password
|
||||
} else {
|
||||
return model.NewAppError("TestElasticsearch", "ent.elasticsearch.test_config.reenter_password", nil, "", http.StatusBadRequest)
|
||||
|
||||
@@ -591,7 +591,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
mlog.Info("Printing current working", mlog.String("directory", pwd))
|
||||
mlog.Info("Loaded config", mlog.String("source", s.configStore.String()))
|
||||
|
||||
s.checkPushNotificationServerUrl()
|
||||
s.checkPushNotificationServerURL()
|
||||
|
||||
s.ReloadConfig()
|
||||
|
||||
@@ -1431,7 +1431,7 @@ func (a *App) OriginChecker() func(*http.Request) bool {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) checkPushNotificationServerUrl() {
|
||||
func (s *Server) checkPushNotificationServerURL() {
|
||||
notificationServer := *s.Config().EmailSettings.PushNotificationServer
|
||||
if strings.HasPrefix(notificationServer, "http://") {
|
||||
mlog.Warn("Your push notification server is configured with HTTP. For improved security, update to HTTPS in your configuration.")
|
||||
@@ -1766,7 +1766,7 @@ func (s *Server) StartSearchEngine() (string, string) {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
})
|
||||
} else if s.SearchEngine.ElasticsearchEngine != nil && *oldConfig.ElasticsearchSettings.Password != *newConfig.ElasticsearchSettings.Password || *oldConfig.ElasticsearchSettings.Username != *newConfig.ElasticsearchSettings.Username || *oldConfig.ElasticsearchSettings.ConnectionUrl != *newConfig.ElasticsearchSettings.ConnectionUrl || *oldConfig.ElasticsearchSettings.Sniff != *newConfig.ElasticsearchSettings.Sniff {
|
||||
} else if s.SearchEngine.ElasticsearchEngine != nil && *oldConfig.ElasticsearchSettings.Password != *newConfig.ElasticsearchSettings.Password || *oldConfig.ElasticsearchSettings.Username != *newConfig.ElasticsearchSettings.Username || *oldConfig.ElasticsearchSettings.ConnectionURL != *newConfig.ElasticsearchSettings.ConnectionURL || *oldConfig.ElasticsearchSettings.Sniff != *newConfig.ElasticsearchSettings.Sniff {
|
||||
s.Go(func() {
|
||||
if *oldConfig.ElasticsearchSettings.EnableIndexing {
|
||||
if err := s.SearchEngine.ElasticsearchEngine.Stop(); err != nil {
|
||||
|
||||
@@ -157,7 +157,7 @@ func (lt *LoadTestProvider) doCommand(a *app.App, c *request.Context, args *mode
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "url") {
|
||||
return lt.UrlCommand(a, c, args, message)
|
||||
return lt.URLCommand(a, c, args, message)
|
||||
}
|
||||
|
||||
if strings.HasPrefix(message, "json") {
|
||||
@@ -460,7 +460,7 @@ func (*LoadTestProvider) PostCommand(a *app.App, args *model.CommandArgs, messag
|
||||
return &model.CommandResponse{Text: "Added a post to " + channel.DisplayName, ResponseType: model.CommandResponseTypeEphemeral}, nil
|
||||
}
|
||||
|
||||
func (*LoadTestProvider) UrlCommand(a *app.App, c *request.Context, args *model.CommandArgs, message string) (*model.CommandResponse, error) {
|
||||
func (*LoadTestProvider) URLCommand(a *app.App, c *request.Context, args *model.CommandArgs, message string) (*model.CommandResponse, error) {
|
||||
url := strings.TrimSpace(strings.TrimPrefix(message, "url"))
|
||||
if url == "" {
|
||||
return &model.CommandResponse{Text: "Command must contain a url", ResponseType: model.CommandResponseTypeEphemeral}, nil
|
||||
|
||||
@@ -611,11 +611,11 @@ func TestTriggerOutGoingWebhookWithUsernameAndIconURL(t *testing.T) {
|
||||
WebhookResponse *model.OutgoingWebhookResponse
|
||||
}
|
||||
|
||||
createOutgoingWebhook := func(channel *model.Channel, testCallBackUrl string, th *TestHelper) (*model.OutgoingWebhook, *model.AppError) {
|
||||
createOutgoingWebhook := func(channel *model.Channel, testCallBackURL string, th *TestHelper) (*model.OutgoingWebhook, *model.AppError) {
|
||||
outgoingWebhook := model.OutgoingWebhook{
|
||||
ChannelId: channel.Id,
|
||||
TeamId: channel.TeamId,
|
||||
CallbackURLs: []string{testCallBackUrl},
|
||||
CallbackURLs: []string{testCallBackURL},
|
||||
Username: "some-user-name",
|
||||
IconURL: "http://some-icon/",
|
||||
DisplayName: "some-display-name",
|
||||
|
||||
Ссылка в новой задаче
Block a user