* replace interface{} with any
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-07-05 09:46:50 +03:00
коммит произвёл GitHub
родитель b45ff0be5d
Коммит 717a4d04a9
258 изменённых файлов: 1286 добавлений и 1286 удалений

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

@@ -209,7 +209,7 @@ func (a *App) TestSiteURL(siteURL string) *model.AppError {
func (a *App) TestEmail(userID string, cfg *model.Config) *model.AppError {
if *cfg.EmailSettings.SMTPServer == "" {
return model.NewAppError("testEmail", "api.admin.test_email.missing_server", nil, i18n.T("api.context.invalid_param.app_error", map[string]interface{}{"Name": "SMTPServer"}), http.StatusBadRequest)
return model.NewAppError("testEmail", "api.admin.test_email.missing_server", nil, i18n.T("api.context.invalid_param.app_error", map[string]any{"Name": "SMTPServer"}), http.StatusBadRequest)
}
// if the user hasn't changed their email settings, fill in the actual SMTP password so that
@@ -232,7 +232,7 @@ func (a *App) TestEmail(userID string, cfg *model.Config) *model.AppError {
license := a.Srv().License()
mailConfig := a.Srv().MailServiceConfig()
if err := mail.SendMailUsingConfig(user.Email, T("api.admin.test_email.subject"), T("api.admin.test_email.body"), mailConfig, license != nil && *license.Features.Compliance, "", "", "", ""); err != nil {
return model.NewAppError("testEmail", "app.admin.test_email.failure", map[string]interface{}{"Error": err.Error()}, "", http.StatusInternalServerError)
return model.NewAppError("testEmail", "app.admin.test_email.failure", map[string]any{"Error": err.Error()}, "", http.StatusInternalServerError)
}
return nil

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

@@ -156,7 +156,7 @@ func (a *App) NotifyAndSetWarnMetricAck(warnMetricId string, sender *model.User,
if !forceAck {
if *a.Config().EmailSettings.SMTPServer == "" {
return model.NewAppError("NotifyAndSetWarnMetricAck", "api.email.send_warn_metric_ack.missing_server.app_error", nil, i18n.T("api.context.invalid_param.app_error", map[string]interface{}{"Name": "SMTPServer"}), http.StatusInternalServerError)
return model.NewAppError("NotifyAndSetWarnMetricAck", "api.email.send_warn_metric_ack.missing_server.app_error", nil, i18n.T("api.context.invalid_param.app_error", map[string]any{"Name": "SMTPServer"}), http.StatusInternalServerError)
}
T := i18n.GetUserTranslations(sender.Locale)
data := a.Srv().EmailService.NewEmailTemplateData(sender.Locale)
@@ -191,11 +191,11 @@ func (a *App) NotifyAndSetWarnMetricAck(warnMetricId string, sender *model.User,
body, err := a.Srv().TemplatesContainer().RenderToString("warn_metric_ack", data)
if err != nil {
return model.NewAppError("NotifyAndSetWarnMetricAck", "api.email.send_warn_metric_ack.failure.app_error", map[string]interface{}{"Error": err.Error()}, "", http.StatusInternalServerError)
return model.NewAppError("NotifyAndSetWarnMetricAck", "api.email.send_warn_metric_ack.failure.app_error", map[string]any{"Error": err.Error()}, "", http.StatusInternalServerError)
}
if err := mail.SendMailUsingConfig(model.MmSupportAdvisorAddress, subject, body, mailConfig, false, "", "", "", sender.Email); err != nil {
return model.NewAppError("NotifyAndSetWarnMetricAck", "api.email.send_warn_metric_ack.failure.app_error", map[string]interface{}{"Error": err.Error()}, "", http.StatusInternalServerError)
return model.NewAppError("NotifyAndSetWarnMetricAck", "api.email.send_warn_metric_ack.failure.app_error", map[string]any{"Error": err.Error()}, "", http.StatusInternalServerError)
}
}
@@ -236,7 +236,7 @@ func (a *App) setWarnMetricsStatusForId(warnMetricId string, status string) *mod
Name: warnMetricId,
Value: status,
}); err != nil {
return model.NewAppError("setWarnMetricsStatusForId", "app.system.warn_metric.store.app_error", map[string]interface{}{"WarnMetricName": warnMetricId}, err.Error(), http.StatusInternalServerError)
return model.NewAppError("setWarnMetricsStatusForId", "app.system.warn_metric.store.app_error", map[string]any{"WarnMetricName": warnMetricId}, err.Error(), http.StatusInternalServerError)
}
return nil
}

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

@@ -170,7 +170,7 @@ type AppIface interface {
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{}
GetEnvironmentConfig(filter func(reflect.StructField) bool) map[string]any
// GetFilteredUsersStats is used to get a count of users based on the set of filters supported by UserCountOptions.
GetFilteredUsersStats(options *model.UserCountOptions) (*model.UsersStats, *model.AppError)
// GetGroupsByTeam returns the paged list and the total count of group associated to the given team.
@@ -540,7 +540,7 @@ type AppIface interface {
DoUploadFileExpectModification(c *request.Context, now time.Time, rawTeamId string, rawChannelId string, rawUserId string, rawFilename string, data []byte) (*model.FileInfo, []byte, *model.AppError)
DownloadFromURL(downloadURL string) ([]byte, error)
EnableUserAccessToken(token *model.UserAccessToken) *model.AppError
EnvironmentConfig(filter func(reflect.StructField) bool) map[string]interface{}
EnvironmentConfig(filter func(reflect.StructField) bool) map[string]any
ExportPermissions(w io.Writer) error
ExtractContentFromFileInfo(fileInfo *model.FileInfo) error
FetchSamlMetadataFromIdp(url string) ([]byte, *model.AppError)
@@ -751,7 +751,7 @@ type AppIface interface {
GetSiteURL() string
GetStatus(userID string) (*model.Status, *model.AppError)
GetStatusFromCache(userID string) *model.Status
GetStatusesByIds(userIDs []string) (map[string]interface{}, *model.AppError)
GetStatusesByIds(userIDs []string) (map[string]any, *model.AppError)
GetSystemBot() (*model.Bot, *model.AppError)
GetTeam(teamID string) (*model.Team, *model.AppError)
GetTeamByInviteId(inviteId string) (*model.Team, *model.AppError)

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

@@ -50,7 +50,7 @@ func (a *App) IsPasswordValid(password string) *model.AppError {
var invErr *users.ErrInvalidPassword
switch {
case errors.As(err, &invErr):
return model.NewAppError("User.IsValid", invErr.Id(), map[string]interface{}{"Min": *a.Config().PasswordSettings.MinimumLength}, "", http.StatusBadRequest)
return model.NewAppError("User.IsValid", invErr.Id(), map[string]any{"Min": *a.Config().PasswordSettings.MinimumLength}, "", http.StatusBadRequest)
default:
return model.NewAppError("User.IsValid", "app.valid_password_generic.app_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -266,7 +266,7 @@ func (a *App) authenticateUser(c *request.Context, user *model.User, password, m
if authService == model.UserAuthServiceSaml {
authService = strings.ToUpper(authService)
}
err := model.NewAppError("login", "api.user.login.use_auth_service.app_error", map[string]interface{}{"AuthService": authService}, "", http.StatusBadRequest)
err := model.NewAppError("login", "api.user.login.use_auth_service.app_error", map[string]any{"AuthService": authService}, "", http.StatusBadRequest)
return user, err
}

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

@@ -447,7 +447,7 @@ func (a *App) PermanentDeleteBot(botUserId string) *model.AppError {
var invErr *store.ErrInvalidInput
switch {
case errors.As(err, &invErr):
return model.NewAppError("PermanentDeleteBot", "app.bot.permenent_delete.bad_id", map[string]interface{}{"user_id": invErr.Value}, invErr.Error(), http.StatusBadRequest)
return model.NewAppError("PermanentDeleteBot", "app.bot.permenent_delete.bad_id", map[string]any{"user_id": invErr.Value}, invErr.Error(), http.StatusBadRequest)
default: // last fallback in case it doesn't map to an existing app error.
return model.NewAppError("PatchBot", "app.bot.permanent_delete.internal_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -626,7 +626,7 @@ func (a *App) getDisableBotSysadminMessage(user *model.User, userBots model.BotL
T := i18n.GetUserTranslations(user.Locale)
message = T("app.bot.get_disable_bot_sysadmin_message",
map[string]interface{}{
map[string]any{
"UserName": user.Username,
"NumBots": len(userBots),
"BotNames": botList,

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

@@ -188,7 +188,7 @@ func (a *App) CreateChannelWithUser(c *request.Context, channel *model.Channel,
}
if int64(count+1) > *a.Config().TeamSettings.MaxChannelsPerTeam {
return nil, model.NewAppError("CreateChannelWithUser", "api.channel.create_channel.max_channel_limit.app_error", map[string]interface{}{"MaxChannelsPerTeam": *a.Config().TeamSettings.MaxChannelsPerTeam}, "", http.StatusBadRequest)
return nil, model.NewAppError("CreateChannelWithUser", "api.channel.create_channel.max_channel_limit.app_error", map[string]any{"MaxChannelsPerTeam": *a.Config().TeamSettings.MaxChannelsPerTeam}, "", http.StatusBadRequest)
}
channel.CreatorId = userID
@@ -799,7 +799,7 @@ func (a *App) RestoreChannel(c *request.Context, channel *model.Channel, userID
post := &model.Post{
ChannelId: channel.Id,
Message: T("api.channel.restore_channel.unarchived", map[string]interface{}{"Username": user.Username}),
Message: T("api.channel.restore_channel.unarchived", map[string]any{"Username": user.Username}),
Type: model.PostTypeChannelRestored,
UserId: userID,
Props: model.StringInterface{
@@ -820,7 +820,7 @@ func (a *App) RestoreChannel(c *request.Context, channel *model.Channel, userID
post := &model.Post{
ChannelId: channel.Id,
Message: i18n.T("api.channel.restore_channel.unarchived", map[string]interface{}{"Username": systemBot.Username}),
Message: i18n.T("api.channel.restore_channel.unarchived", map[string]any{"Username": systemBot.Username}),
Type: model.PostTypeChannelRestored,
UserId: systemBot.UserId,
Props: model.StringInterface{
@@ -1363,7 +1363,7 @@ func (a *App) DeleteChannel(c *request.Context, channel *model.Channel, userID s
}
if channel.Name == model.DefaultChannelName {
err := model.NewAppError("deleteChannel", "api.channel.delete_channel.cannot.app_error", map[string]interface{}{"Channel": model.DefaultChannelName}, "", http.StatusBadRequest)
err := model.NewAppError("deleteChannel", "api.channel.delete_channel.cannot.app_error", map[string]any{"Channel": model.DefaultChannelName}, "", http.StatusBadRequest)
return err
}
@@ -1457,7 +1457,7 @@ func (a *App) addUserToChannel(user *model.User, channel *model.Channel) (*model
return nil, model.NewAppError("addUserToChannel", "api.channel.add_user_to_channel.type.app_error", nil, "", http.StatusInternalServerError)
}
if len(nonMembers) > 0 {
return nil, model.NewAppError("addUserToChannel", "api.channel.add_members.user_denied", map[string]interface{}{"UserIDs": nonMembers}, "", http.StatusBadRequest)
return nil, model.NewAppError("addUserToChannel", "api.channel.add_members.user_denied", map[string]any{"UserIDs": nonMembers}, "", http.StatusBadRequest)
}
}
@@ -1594,7 +1594,7 @@ func (a *App) AddDirectChannels(teamID string, user *model.User) *model.AppError
options := &model.UserGetOptions{InTeamId: teamID, Page: 0, PerPage: 100}
profiles, err := a.Srv().Store.User().GetProfiles(options)
if err != nil {
return model.NewAppError("AddDirectChannels", "api.user.add_direct_channels_and_forget.failed.error", map[string]interface{}{"UserId": user.Id, "TeamId": teamID, "Error": err.Error()}, "", http.StatusInternalServerError)
return model.NewAppError("AddDirectChannels", "api.user.add_direct_channels_and_forget.failed.error", map[string]any{"UserId": user.Id, "TeamId": teamID, "Error": err.Error()}, "", http.StatusInternalServerError)
}
var preferences model.Preferences
@@ -1619,7 +1619,7 @@ func (a *App) AddDirectChannels(teamID string, user *model.User) *model.AppError
}
if err := a.Srv().Store.Preference().Save(preferences); err != nil {
return model.NewAppError("AddDirectChannels", "api.user.add_direct_channels_and_forget.failed.error", map[string]interface{}{"UserId": user.Id, "TeamId": teamID, "Error": err.Error()}, "", http.StatusInternalServerError)
return model.NewAppError("AddDirectChannels", "api.user.add_direct_channels_and_forget.failed.error", map[string]any{"UserId": user.Id, "TeamId": teamID, "Error": err.Error()}, "", http.StatusInternalServerError)
}
return nil
@@ -2404,7 +2404,7 @@ func (a *App) removeUserFromChannel(c *request.Context, userIDToRemove string, r
if channel.Name == model.DefaultChannelName {
if !isGuest {
return model.NewAppError("RemoveUserFromChannel", "api.channel.remove.default.app_error", map[string]interface{}{"Channel": model.DefaultChannelName}, "", http.StatusBadRequest)
return model.NewAppError("RemoveUserFromChannel", "api.channel.remove.default.app_error", map[string]any{"Channel": model.DefaultChannelName}, "", http.StatusBadRequest)
}
}
@@ -2414,7 +2414,7 @@ func (a *App) removeUserFromChannel(c *request.Context, userIDToRemove string, r
return model.NewAppError("removeUserFromChannel", "api.channel.remove_user_from_channel.app_error", nil, err.Error(), http.StatusInternalServerError)
}
if len(nonMembers) == 0 {
return model.NewAppError("removeUserFromChannel", "api.channel.remove_members.denied", map[string]interface{}{"UserIDs": nonMembers}, "", http.StatusBadRequest)
return model.NewAppError("removeUserFromChannel", "api.channel.remove_members.denied", map[string]any{"UserIDs": nonMembers}, "", http.StatusBadRequest)
}
}
@@ -3302,11 +3302,11 @@ func (a *App) FillInChannelsProps(channelList model.ChannelList) *model.AppError
}
for _, channel := range channelList {
channelMentionsProp := make(map[string]interface{}, len(channelMentions[channel]))
channelMentionsProp := make(map[string]any, len(channelMentions[channel]))
for _, channelMention := range channelMentions[channel] {
if mentioned, ok := mentionedChannelsByName[channelMention]; ok {
if mentioned.Type == model.ChannelTypeOpen {
channelMentionsProp[mentioned.Name] = map[string]interface{}{
channelMentionsProp[mentioned.Name] = map[string]any{
"display_name": mentioned.DisplayName,
}
}

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

@@ -759,7 +759,7 @@ func TestFillInChannelProps(t *testing.T) {
testCases := []struct {
Description string
Channel *model.Channel
ExpectedChannelProps map[string]interface{}
ExpectedChannelProps map[string]any
}{
{
"channel on basic team without references",
@@ -777,9 +777,9 @@ func TestFillInChannelProps(t *testing.T) {
Header: "~public1, ~private, ~other-team",
Purpose: "~public2, ~private, ~other-team",
},
map[string]interface{}{
"channel_mentions": map[string]interface{}{
"public1": map[string]interface{}{
map[string]any{
"channel_mentions": map[string]any{
"public1": map[string]any{
"display_name": "Public 1",
},
},
@@ -792,9 +792,9 @@ func TestFillInChannelProps(t *testing.T) {
Header: "~public1, ~private, ~other-team",
Purpose: "~public2, ~private, ~other-team",
},
map[string]interface{}{
"channel_mentions": map[string]interface{}{
"other-team": map[string]interface{}{
map[string]any{
"channel_mentions": map[string]any{
"other-team": map[string]any{
"display_name": "Other Team Channel",
},
},
@@ -816,7 +816,7 @@ func TestFillInChannelProps(t *testing.T) {
testCases := []struct {
Description string
Channels model.ChannelList
ExpectedChannelProps map[string]interface{}
ExpectedChannelProps map[string]any
}{
{
"single channel on basic team",
@@ -828,10 +828,10 @@ func TestFillInChannelProps(t *testing.T) {
Purpose: "~public2, ~private, ~other-team",
},
},
map[string]interface{}{
"test": map[string]interface{}{
"channel_mentions": map[string]interface{}{
"public1": map[string]interface{}{
map[string]any{
"test": map[string]any{
"channel_mentions": map[string]any{
"public1": map[string]any{
"display_name": "Public 1",
},
},
@@ -860,16 +860,16 @@ func TestFillInChannelProps(t *testing.T) {
Purpose: "No references",
},
},
map[string]interface{}{
"test": map[string]interface{}{
"channel_mentions": map[string]interface{}{
"public1": map[string]interface{}{
map[string]any{
"test": map[string]any{
"channel_mentions": map[string]any{
"public1": map[string]any{
"display_name": "Public 1",
},
},
},
"test2": map[string]interface{}(nil),
"test3": map[string]interface{}(nil),
"test2": map[string]any(nil),
"test3": map[string]any(nil),
},
},
{
@@ -894,22 +894,22 @@ func TestFillInChannelProps(t *testing.T) {
Purpose: "No references",
},
},
map[string]interface{}{
"test": map[string]interface{}{
"channel_mentions": map[string]interface{}{
"public1": map[string]interface{}{
map[string]any{
"test": map[string]any{
"channel_mentions": map[string]any{
"public1": map[string]any{
"display_name": "Public 1",
},
},
},
"test2": map[string]interface{}{
"channel_mentions": map[string]interface{}{
"other-team": map[string]interface{}{
"test2": map[string]any{
"channel_mentions": map[string]any{
"other-team": map[string]any{
"display_name": "Other Team Channel",
},
},
},
"test3": map[string]interface{}(nil),
"test3": map[string]any(nil),
},
},
}

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

@@ -90,7 +90,7 @@ type Channels struct {
func init() {
RegisterProduct("channels", ProductManifest{
Initializer: func(s *Server, services map[ServiceKey]interface{}) (Product, error) {
Initializer: func(s *Server, services map[ServiceKey]any) (Product, error) {
return NewChannels(s, services)
},
Dependencies: map[ServiceKey]struct{}{
@@ -101,7 +101,7 @@ func init() {
})
}
func NewChannels(s *Server, services map[ServiceKey]interface{}) (*Channels, error) {
func NewChannels(s *Server, services map[ServiceKey]any) (*Channels, error) {
ch := &Channels{
srv: s,
imageProxy: imageproxy.MakeImageProxy(s, s.httpService, s.Log),

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

@@ -70,7 +70,7 @@ func (a *App) NotifySystemAdminsToUpgrade(c *request.Context, currentUserTeamID
}
post := &model.Post{
Message: T("api.cloud.upgrade_plan_bot_message", map[string]interface{}{"TeamName": team.Name}),
Message: T("api.cloud.upgrade_plan_bot_message", map[string]any{"TeamName": team.Name}),
UserId: systemBot.UserId,
ChannelId: channel.Id,
Type: fmt.Sprintf("%sup_notification", model.PostCustomTypePrefix), // webapp will have to create renderer for this custom post type

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

@@ -42,7 +42,7 @@ func (s *clusterWrapper) PublishPluginClusterEvent(productID string, ev model.Pl
return nil
}
func (s *clusterWrapper) PublishWebSocketEvent(productID string, event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast) {
func (s *clusterWrapper) PublishWebSocketEvent(productID string, event string, payload map[string]any, broadcast *model.WebsocketBroadcast) {
ev := model.NewWebSocketEvent(fmt.Sprintf("custom_%v_%v", productID, event), "", "", "", nil)
ev = ev.SetBroadcast(broadcast).SetData(payload)
s.srv.Publish(ev)
@@ -85,7 +85,7 @@ func (s *Server) InvokeClusterLeaderChangedListeners() {
// Fixing this would require the changed event to pass the leader directly, but that
// requires a lot of work.
s.Go(func() {
s.clusterLeaderListeners.Range(func(_, listener interface{}) bool {
s.clusterLeaderListeners.Range(func(_, listener any) bool {
listener.(func())()
return true
})

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

@@ -62,7 +62,7 @@ func (a *App) CreateCommandPost(c *request.Context, post *model.Post, teamID str
post.CreateAt = model.GetMillis()
if strings.HasPrefix(post.Type, model.PostSystemMessagePrefix) {
err := model.NewAppError("CreateCommandPost", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "post.type"}, "", http.StatusBadRequest)
err := model.NewAppError("CreateCommandPost", "api.context.invalid_param.app_error", map[string]any{"Name": "post.type"}, "", http.StatusBadRequest)
return nil, err
}
@@ -192,7 +192,7 @@ func (a *App) ExecuteCommand(c *request.Context, args *model.CommandArgs) (*mode
}
trigger = strings.ToLower(trigger)
if !strings.HasPrefix(trigger, "/") {
return nil, model.NewAppError("command", "api.command.execute_command.format.app_error", map[string]interface{}{"Trigger": trigger}, "", http.StatusBadRequest)
return nil, model.NewAppError("command", "api.command.execute_command.format.app_error", map[string]any{"Trigger": trigger}, "", http.StatusBadRequest)
}
trigger = strings.TrimPrefix(trigger, "/")
@@ -230,7 +230,7 @@ func (a *App) ExecuteCommand(c *request.Context, args *model.CommandArgs) (*mode
trigger = trigger[:maxTriggerLen]
trigger += "..."
}
return nil, model.NewAppError("command", "api.command.execute_command.not_found.app_error", map[string]interface{}{"Trigger": trigger}, "", http.StatusNotFound)
return nil, model.NewAppError("command", "api.command.execute_command.not_found.app_error", map[string]any{"Trigger": trigger}, "", http.StatusNotFound)
}
// MentionsToTeamMembers returns all the @ mentions found in message that
@@ -474,7 +474,7 @@ func (a *App) tryExecuteCustomCommand(args *model.CommandArgs, trigger string, m
hook, appErr := a.CreateCommandWebhook(cmd.Id, args)
if appErr != nil {
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]interface{}{"Trigger": trigger}, appErr.Error(), http.StatusInternalServerError)
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]any{"Trigger": trigger}, appErr.Error(), http.StatusInternalServerError)
}
p.Set("response_url", args.SiteURL+"/hooks/commands/"+hook.Id)
@@ -492,7 +492,7 @@ func (a *App) DoCommandRequest(cmd *model.Command, p url.Values) (*model.Command
}
if err != nil {
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]interface{}{"Trigger": cmd.Trigger}, err.Error(), http.StatusInternalServerError)
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]any{"Trigger": cmd.Trigger}, err.Error(), http.StatusInternalServerError)
}
if cmd.Method == model.CommandMethodGet {
@@ -511,7 +511,7 @@ func (a *App) DoCommandRequest(cmd *model.Command, p url.Values) (*model.Command
// Send the request
resp, err := a.HTTPService().MakeClient(false).Do(req)
if err != nil {
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]interface{}{"Trigger": cmd.Trigger}, err.Error(), http.StatusInternalServerError)
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]any{"Trigger": cmd.Trigger}, err.Error(), http.StatusInternalServerError)
}
defer resp.Body.Close()
@@ -523,14 +523,14 @@ func (a *App) DoCommandRequest(cmd *model.Command, p url.Values) (*model.Command
// Ignore the error below because the resulting string will just be the empty string if bodyBytes is nil
bodyBytes, _ := ioutil.ReadAll(body)
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed_resp.app_error", map[string]interface{}{"Trigger": cmd.Trigger, "Status": resp.Status}, string(bodyBytes), http.StatusInternalServerError)
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed_resp.app_error", map[string]any{"Trigger": cmd.Trigger, "Status": resp.Status}, string(bodyBytes), http.StatusInternalServerError)
}
response, err := model.CommandResponseFromHTTPBody(resp.Header.Get("Content-Type"), body)
if err != nil {
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]interface{}{"Trigger": cmd.Trigger}, err.Error(), http.StatusInternalServerError)
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed.app_error", map[string]any{"Trigger": cmd.Trigger}, err.Error(), http.StatusInternalServerError)
} else if response == nil {
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed_empty.app_error", map[string]interface{}{"Trigger": cmd.Trigger}, "", http.StatusInternalServerError)
return cmd, nil, model.NewAppError("command", "api.command.execute_command.failed_empty.app_error", map[string]any{"Trigger": cmd.Trigger}, "", http.StatusInternalServerError)
}
return cmd, response, nil
@@ -564,7 +564,7 @@ func (a *App) HandleCommandResponse(c *request.Context, command *model.Command,
}
if lastError != nil {
return response, model.NewAppError("command", "api.command.execute_command.create_post_failed.app_error", map[string]interface{}{"Trigger": trigger}, "", http.StatusInternalServerError)
return response, model.NewAppError("command", "api.command.execute_command.create_post_failed.app_error", map[string]any{"Trigger": trigger}, "", http.StatusInternalServerError)
}
return response, nil
@@ -681,7 +681,7 @@ func (a *App) GetCommand(commandID string) (*model.Command, *model.AppError) {
var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("SqlCommandStore.Get", "store.sql_command.get.missing.app_error", map[string]interface{}{"command_id": commandID}, "", http.StatusNotFound)
return nil, model.NewAppError("SqlCommandStore.Get", "store.sql_command.get.missing.app_error", map[string]any{"command_id": commandID}, "", http.StatusNotFound)
default:
return nil, model.NewAppError("GetCommand", "app.command.getcommand.internal_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -710,7 +710,7 @@ func (a *App) UpdateCommand(oldCmd, updatedCmd *model.Command) (*model.Command,
var appErr *model.AppError
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("SqlCommandStore.Update", "store.sql_command.update.missing.app_error", map[string]interface{}{"command_id": updatedCmd.Id}, "", http.StatusNotFound)
return nil, model.NewAppError("SqlCommandStore.Update", "store.sql_command.update.missing.app_error", map[string]any{"command_id": updatedCmd.Id}, "", http.StatusNotFound)
case errors.As(err, &appErr):
return nil, appErr
default:
@@ -730,7 +730,7 @@ func (a *App) MoveCommand(team *model.Team, command *model.Command) *model.AppEr
var appErr *model.AppError
switch {
case errors.As(err, &nfErr):
return model.NewAppError("SqlCommandStore.Update", "store.sql_command.update.missing.app_error", map[string]interface{}{"command_id": command.Id}, "", http.StatusNotFound)
return model.NewAppError("SqlCommandStore.Update", "store.sql_command.update.missing.app_error", map[string]any{"command_id": command.Id}, "", http.StatusNotFound)
case errors.As(err, &appErr):
return appErr
default:
@@ -754,7 +754,7 @@ func (a *App) RegenCommandToken(cmd *model.Command) (*model.Command, *model.AppE
var appErr *model.AppError
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("SqlCommandStore.Update", "store.sql_command.update.missing.app_error", map[string]interface{}{"command_id": cmd.Id}, "", http.StatusNotFound)
return nil, model.NewAppError("SqlCommandStore.Update", "store.sql_command.update.missing.app_error", map[string]any{"command_id": cmd.Id}, "", http.StatusNotFound)
case errors.As(err, &appErr):
return nil, appErr
default:

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

@@ -113,11 +113,11 @@ func (a *App) Config() *model.Config {
return a.ch.cfgSvc.Config()
}
func (s *Server) EnvironmentConfig(filter func(reflect.StructField) bool) map[string]interface{} {
func (s *Server) EnvironmentConfig(filter func(reflect.StructField) bool) map[string]any {
return s.configStore.GetEnvironmentOverridesWithFilter(filter)
}
func (a *App) EnvironmentConfig(filter func(reflect.StructField) bool) map[string]interface{} {
func (a *App) EnvironmentConfig(filter func(reflect.StructField) bool) map[string]any {
return a.Srv().EnvironmentConfig(filter)
}
@@ -463,7 +463,7 @@ func (a *App) GetSanitizedConfig() *model.Config {
// 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.
func (a *App) GetEnvironmentConfig(filter func(reflect.StructField) bool) map[string]interface{} {
func (a *App) GetEnvironmentConfig(filter func(reflect.StructField) bool) map[string]any {
return a.EnvironmentConfig(filter)
}

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

@@ -31,14 +31,14 @@ func (es *Service) SendChangeUsernameEmail(newUsername, email, locale, siteURL s
T := i18n.GetUserTranslations(locale)
subject := T("api.templates.username_change_subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName,
map[string]any{"SiteName": es.config().TeamSettings.SiteName,
"TeamDisplayName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.username_change_body.title")
data.Props["Info"] = T("api.templates.username_change_body.info",
map[string]interface{}{"TeamDisplayName": es.config().TeamSettings.SiteName, "NewUsername": newUsername})
map[string]any{"TeamDisplayName": es.config().TeamSettings.SiteName, "NewUsername": newUsername})
data.Props["Warning"] = T("api.templates.email_warning")
body, err := es.templatesContainer.RenderToString("email_change_body", data)
@@ -59,14 +59,14 @@ func (es *Service) SendEmailChangeVerifyEmail(newUserEmail, locale, siteURL, tok
link := fmt.Sprintf("%s/do_verify_email?token=%s&email=%s", siteURL, token, url.QueryEscape(newUserEmail))
subject := T("api.templates.email_change_verify_subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName,
map[string]any{"SiteName": es.config().TeamSettings.SiteName,
"TeamDisplayName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.email_change_verify_body.title")
data.Props["Info"] = T("api.templates.email_change_verify_body.info",
map[string]interface{}{"TeamDisplayName": es.config().TeamSettings.SiteName})
map[string]any{"TeamDisplayName": es.config().TeamSettings.SiteName})
data.Props["VerifyUrl"] = link
data.Props["VerifyButton"] = T("api.templates.email_change_verify_body.button")
@@ -86,14 +86,14 @@ func (es *Service) SendEmailChangeEmail(oldEmail, newEmail, locale, siteURL stri
T := i18n.GetUserTranslations(locale)
subject := T("api.templates.email_change_subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName,
map[string]any{"SiteName": es.config().TeamSettings.SiteName,
"TeamDisplayName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.email_change_body.title")
data.Props["Info"] = T("api.templates.email_change_body.info",
map[string]interface{}{"TeamDisplayName": es.config().TeamSettings.SiteName, "NewEmail": newEmail})
map[string]any{"TeamDisplayName": es.config().TeamSettings.SiteName, "NewEmail": newEmail})
data.Props["Warning"] = T("api.templates.email_warning")
body, err := es.templatesContainer.RenderToString("email_change_body", data)
@@ -119,13 +119,13 @@ func (es *Service) SendVerifyEmail(userEmail, locale, siteURL, token, redirect s
serverURL := condenseSiteURL(siteURL)
subject := T("api.templates.verify_subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName})
map[string]any{"SiteName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.verify_body.title")
data.Props["SubTitle1"] = T("api.templates.verify_body.subTitle1")
data.Props["ServerURL"] = T("api.templates.verify_body.serverURL", map[string]interface{}{"ServerURL": serverURL})
data.Props["ServerURL"] = T("api.templates.verify_body.serverURL", map[string]any{"ServerURL": serverURL})
data.Props["SubTitle2"] = T("api.templates.verify_body.subTitle2")
data.Props["ButtonURL"] = link
data.Props["Button"] = T("api.templates.verify_body.button")
@@ -150,13 +150,13 @@ func (es *Service) SendSignInChangeEmail(email, method, locale, siteURL string)
T := i18n.GetUserTranslations(locale)
subject := T("api.templates.signin_change_email.subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName})
map[string]any{"SiteName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.signin_change_email.body.title")
data.Props["Info"] = T("api.templates.signin_change_email.body.info",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName, "Method": method})
map[string]any{"SiteName": es.config().TeamSettings.SiteName, "Method": method})
data.Props["Warning"] = T("api.templates.email_warning")
body, err := es.templatesContainer.RenderToString("signin_change_body", data)
@@ -184,14 +184,14 @@ func (es *Service) SendWelcomeEmail(userID string, email string, verified bool,
serverURL := condenseSiteURL(siteURL)
subject := T("api.templates.welcome_subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName,
map[string]any{"SiteName": es.config().TeamSettings.SiteName,
"ServerURL": serverURL})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.welcome_body.title")
data.Props["SubTitle1"] = T("api.templates.welcome_body.subTitle1")
data.Props["ServerURL"] = T("api.templates.welcome_body.serverURL", map[string]interface{}{"ServerURL": serverURL})
data.Props["ServerURL"] = T("api.templates.welcome_body.serverURL", map[string]any{"ServerURL": serverURL})
data.Props["SubTitle2"] = T("api.templates.welcome_body.subTitle2")
data.Props["Button"] = T("api.templates.welcome_body.button")
data.Props["Info"] = T("api.templates.welcome_body.info")
@@ -235,7 +235,7 @@ func (es *Service) SendCloudUpgradeConfirmationEmail(userEmail, name, date, loca
data := es.NewEmailTemplateData(locale)
data.Props["Title"] = T("api.templates.cloud_upgrade_confirmation.title")
data.Props["SubTitle"] = T("api.templates.cloud_upgrade_confirmation.subtitle", map[string]interface{}{"WorkspaceName": workspaceName, "Date": date})
data.Props["SubTitle"] = T("api.templates.cloud_upgrade_confirmation.subtitle", map[string]any{"WorkspaceName": workspaceName, "Date": date})
data.Props["SiteURL"] = siteURL
data.Props["ButtonURL"] = siteURL
data.Props["Button"] = T("api.templates.cloud_welcome_email.button")
@@ -269,7 +269,7 @@ func (es *Service) SendCloudWelcomeEmail(userEmail, locale, teamInviteID, workSp
data.Props["WorkSpacePath"] = siteURL
data.Props["DNS"] = dns
data.Props["InviteInfo"] = T("api.templates.cloud_welcome_email.invite_info")
data.Props["InviteSubInfo"] = T("api.templates.cloud_welcome_email.invite_sub_info", map[string]interface{}{"WorkSpace": workSpaceName})
data.Props["InviteSubInfo"] = T("api.templates.cloud_welcome_email.invite_sub_info", map[string]any{"WorkSpace": workSpaceName})
data.Props["InviteSubInfoLink"] = fmt.Sprintf("%s/signup_user_complete/?id=%s", siteURL, teamInviteID)
data.Props["AddAppsInfo"] = T("api.templates.cloud_welcome_email.add_apps_info")
data.Props["AddAppsSubInfo"] = T("api.templates.cloud_welcome_email.add_apps_sub_info")
@@ -299,14 +299,14 @@ func (es *Service) SendPasswordChangeEmail(email, method, locale, siteURL string
T := i18n.GetUserTranslations(locale)
subject := T("api.templates.password_change_subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName,
map[string]any{"SiteName": es.config().TeamSettings.SiteName,
"TeamDisplayName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.password_change_body.title")
data.Props["Info"] = T("api.templates.password_change_body.info",
map[string]interface{}{"TeamDisplayName": es.config().TeamSettings.SiteName, "TeamURL": siteURL, "Method": method})
map[string]any{"TeamDisplayName": es.config().TeamSettings.SiteName, "TeamURL": siteURL, "Method": method})
data.Props["Warning"] = T("api.templates.email_warning")
body, err := es.templatesContainer.RenderToString("password_change_body", data)
@@ -325,13 +325,13 @@ func (es *Service) SendUserAccessTokenAddedEmail(email, locale, siteURL string)
T := i18n.GetUserTranslations(locale)
subject := T("api.templates.user_access_token_subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName})
map[string]any{"SiteName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.user_access_token_body.title")
data.Props["Info"] = T("api.templates.user_access_token_body.info",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName, "SiteURL": siteURL})
map[string]any{"SiteName": es.config().TeamSettings.SiteName, "SiteURL": siteURL})
data.Props["Warning"] = T("api.templates.email_warning")
body, err := es.templatesContainer.RenderToString("password_change_body", data)
@@ -352,7 +352,7 @@ func (es *Service) SendPasswordResetEmail(email string, token *model.Token, loca
link := fmt.Sprintf("%s/reset_password_complete?token=%s", siteURL, url.QueryEscape(token.Token))
subject := T("api.templates.reset_subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName})
map[string]any{"SiteName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
@@ -380,16 +380,16 @@ func (es *Service) SendMfaChangeEmail(email string, activated bool, locale, site
T := i18n.GetUserTranslations(locale)
subject := T("api.templates.mfa_change_subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName})
map[string]any{"SiteName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
if activated {
data.Props["Info"] = T("api.templates.mfa_activated_body.info", map[string]interface{}{"SiteURL": siteURL})
data.Props["Info"] = T("api.templates.mfa_activated_body.info", map[string]any{"SiteURL": siteURL})
data.Props["Title"] = T("api.templates.mfa_activated_body.title")
} else {
data.Props["Info"] = T("api.templates.mfa_deactivated_body.info", map[string]interface{}{"SiteURL": siteURL})
data.Props["Info"] = T("api.templates.mfa_deactivated_body.info", map[string]any{"SiteURL": siteURL})
data.Props["Title"] = T("api.templates.mfa_deactivated_body.title")
}
data.Props["Warning"] = T("api.templates.email_warning")
@@ -424,7 +424,7 @@ func (es *Service) SendInviteEmails(team *model.Team, senderName string, senderU
for _, invite := range invites {
if invite != "" {
subject := i18n.T("api.templates.invite_subject",
map[string]interface{}{"SenderName": senderName,
map[string]any{"SenderName": senderName,
"TeamDisplayName": team.DisplayName,
"SiteName": es.config().TeamSettings.SiteName})
@@ -447,7 +447,7 @@ func (es *Service) SendInviteEmails(team *model.Team, senderName string, senderU
tokenProps["display_name"] = team.DisplayName
tokenProps["name"] = team.Name
title := i18n.T("api.templates.invite_body.title", map[string]interface{}{"SenderName": senderName, "TeamDisplayName": team.DisplayName})
title := i18n.T("api.templates.invite_body.title", map[string]any{"SenderName": senderName, "TeamDisplayName": team.DisplayName})
if reminderData != nil {
reminder := i18n.T("api.templates.invite_body.title.reminder")
title = fmt.Sprintf("%s: %s", reminder, title)
@@ -498,13 +498,13 @@ func (es *Service) SendGuestInviteEmails(team *model.Team, channels []*model.Cha
for _, invite := range invites {
if invite != "" {
subject := i18n.T("api.templates.invite_guest_subject",
map[string]interface{}{"SenderName": senderName,
map[string]any{"SenderName": senderName,
"TeamDisplayName": team.DisplayName,
"SiteName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData("")
data.Props["SiteURL"] = siteURL
data.Props["Title"] = i18n.T("api.templates.invite_body.title", map[string]interface{}{"SenderName": senderName, "TeamDisplayName": team.DisplayName})
data.Props["Title"] = i18n.T("api.templates.invite_body.title", map[string]any{"SenderName": senderName, "TeamDisplayName": team.DisplayName})
data.Props["SubTitle"] = i18n.T("api.templates.invite_body_guest.subTitle")
data.Props["Button"] = i18n.T("api.templates.invite_body.button")
data.Props["SenderName"] = senderName
@@ -610,13 +610,13 @@ func (es *Service) SendInviteEmailsToTeamAndChannels(
channelsLen := len(channels)
subject := i18n.T("api.templates.invite_team_and_channels_subject", map[string]interface{}{
subject := i18n.T("api.templates.invite_team_and_channels_subject", map[string]any{
"SenderName": senderName,
"TeamDisplayName": team.DisplayName,
"ChannelsLen": channelsLen,
"SiteName": es.config().TeamSettings.SiteName})
title := i18n.T("api.templates.invite_team_and_channels_body.title", map[string]interface{}{
title := i18n.T("api.templates.invite_team_and_channels_body.title", map[string]any{
"SenderName": senderName,
"ChannelsLen": channelsLen,
"TeamDisplayName": team.DisplayName})
@@ -625,13 +625,13 @@ func (es *Service) SendInviteEmailsToTeamAndChannels(
channelName := channels[0].DisplayName
subject = i18n.T("api.templates.invite_team_and_channel_subject",
map[string]interface{}{"SenderName": senderName,
map[string]any{"SenderName": senderName,
"TeamDisplayName": team.DisplayName,
"ChannelName": channelName,
"SiteName": es.config().TeamSettings.SiteName},
)
title = i18n.T("api.templates.invite_team_and_channel_body.title", map[string]interface{}{
title = i18n.T("api.templates.invite_team_and_channel_body.title", map[string]any{
"SenderName": senderName,
"ChannelName": channelName,
"TeamDisplayName": team.DisplayName,
@@ -743,11 +743,11 @@ func (es *Service) NewEmailTemplateData(locale string) templates.Data {
}
return templates.Data{
Props: map[string]interface{}{
Props: map[string]any{
"EmailInfo1": localT("api.templates.email_info1"),
"EmailInfo2": localT("api.templates.email_info2"),
"EmailInfo3": localT("api.templates.email_info3",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName}),
map[string]any{"SiteName": es.config().TeamSettings.SiteName}),
"SupportEmail": *es.config().SupportSettings.SupportEmail,
"Footer": localT("api.templates.email_footer"),
"FooterV2": localT("api.templates.email_footer_v2"),
@@ -763,14 +763,14 @@ func (es *Service) SendDeactivateAccountEmail(email string, locale, siteURL stri
serverURL := condenseSiteURL(siteURL)
subject := T("api.templates.deactivate_subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName,
map[string]any{"SiteName": es.config().TeamSettings.SiteName,
"ServerURL": serverURL})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.deactivate_body.title", map[string]interface{}{"ServerURL": serverURL})
data.Props["Title"] = T("api.templates.deactivate_body.title", map[string]any{"ServerURL": serverURL})
data.Props["Info"] = T("api.templates.deactivate_body.info",
map[string]interface{}{"SiteURL": siteURL})
map[string]any{"SiteURL": siteURL})
data.Props["Warning"] = T("api.templates.deactivate_body.warning")
body, err := es.templatesContainer.RenderToString("deactivate_body", data)
@@ -879,7 +879,7 @@ func (es *Service) SendLicenseInactivityEmail(email, name, locale, siteURL strin
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.server_inactivity_title")
data.Props["SubTitle"] = T("api.templates.server_inactivity_subtitle", map[string]interface{}{"Name": name})
data.Props["SubTitle"] = T("api.templates.server_inactivity_subtitle", map[string]any{"Name": name})
data.Props["InfoBullet"] = T("api.templates.server_inactivity_info_bullet")
data.Props["InfoBullet1"] = T("api.templates.server_inactivity_info_bullet1")
data.Props["InfoBullet2"] = T("api.templates.server_inactivity_info_bullet2")
@@ -901,7 +901,7 @@ func (es *Service) SendLicenseInactivityEmail(email, name, locale, siteURL strin
inactivityDurationHours = serverInactivityHours
}
data.Props["FooterDisclaimer"] = T("api.templates.server_inactivity_footer_disclaimer", map[string]interface{}{"Hours": inactivityDurationHours})
data.Props["FooterDisclaimer"] = T("api.templates.server_inactivity_footer_disclaimer", map[string]any{"Hours": inactivityDurationHours})
body, err := es.templatesContainer.RenderToString("inactivity_body", data)
if err != nil {
@@ -922,7 +922,7 @@ func (es *Service) SendLicenseUpForRenewalEmail(email, name, locale, siteURL, re
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.license_up_for_renewal_title")
data.Props["SubTitle"] = T("api.templates.license_up_for_renewal_subtitle", map[string]interface{}{"UserName": name, "Days": daysToExpiration})
data.Props["SubTitle"] = T("api.templates.license_up_for_renewal_subtitle", map[string]any{"UserName": name, "Days": daysToExpiration})
data.Props["SubTitleTwo"] = T("api.templates.license_up_for_renewal_subtitle_two")
data.Props["EmailUs"] = T("api.templates.email_us_anytime_at")
data.Props["Button"] = T("api.templates.license_up_for_renewal_renew_now")
@@ -951,7 +951,7 @@ func (es *Service) SendPaymentFailedEmail(email string, locale string, failedPay
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL
data.Props["Title"] = T("api.templates.payment_failed.title")
data.Props["Info1"] = T("api.templates.payment_failed.info1", map[string]interface{}{"CardBrand": failedPayment.CardBrand, "LastFour": failedPayment.LastFour})
data.Props["Info1"] = T("api.templates.payment_failed.info1", map[string]any{"CardBrand": failedPayment.CardBrand, "LastFour": failedPayment.LastFour})
data.Props["Info2"] = T("api.templates.payment_failed.info2")
data.Props["Info3"] = T("api.templates.payment_failed.info3")
data.Props["Button"] = T("api.templates.over_limit_fix_now")
@@ -1005,7 +1005,7 @@ func (es *Service) SendNoCardPaymentFailedEmail(email string, locale string, sit
func (es *Service) SendRemoveExpiredLicenseEmail(renewalLink, email string, locale, siteURL string) error {
T := i18n.GetUserTranslations(locale)
subject := T("api.templates.remove_expired_license.subject",
map[string]interface{}{"SiteName": es.config().TeamSettings.SiteName})
map[string]any{"SiteName": es.config().TeamSettings.SiteName})
data := es.NewEmailTemplateData(locale)
data.Props["SiteURL"] = siteURL

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

@@ -276,7 +276,7 @@ func (es *Service) sendBatchedEmailNotification(userID string, notifications []*
tm := time.Unix(notification.post.CreateAt/1000, 0)
timezone, _ := tm.Zone()
t := translateFunc("api.email_batching.send_batched_email_notification.time", map[string]interface{}{
t := translateFunc("api.email_batching.send_batched_email_notification.time", map[string]any{
"Hour": tm.Hour(),
"Minute": fmt.Sprintf("%02d", tm.Minute()),
"Month": translateFunc(tm.Month().String()),
@@ -292,7 +292,7 @@ func (es *Service) sendBatchedEmailNotification(userID string, notifications []*
otherChannelMembersCount := 0
if threadsEnabled && notification.post.RootId != "" {
props := map[string]interface{}{"channelName": channelDisplayName}
props := map[string]any{"channelName": channelDisplayName}
channelDisplayName = translateFunc("api.push_notification.title.collapsed_threads", props)
if channel.Type == model.ChannelTypeDirect {
channelDisplayName = translateFunc("api.push_notification.title.collapsed_threads_dm")
@@ -320,7 +320,7 @@ func (es *Service) sendBatchedEmailNotification(userID string, notifications []*
tm := time.Unix(notifications[0].post.CreateAt/1000, 0)
subject := translateFunc("api.email_batching.send_batched_email_notification.subject", len(notifications), map[string]interface{}{
subject := translateFunc("api.email_batching.send_batched_email_notification.subject", len(notifications), map[string]any{
"SiteName": es.config().TeamSettings.SiteName,
"Year": tm.Year(),
"Month": translateFunc(tm.Month().String()),

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

@@ -37,7 +37,7 @@ func (es *Service) GetMessageForNotification(post *model.Post, translateFunc i18
onlyImages = onlyImages && info.IsImage()
}
props := map[string]interface{}{"Filenames": strings.Join(filenames, ", ")}
props := map[string]any{"Filenames": strings.Join(filenames, ", ")}
if onlyImages {
return translateFunc("api.post.get_message_for_notification.images_sent", len(filenames), props)

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

@@ -66,7 +66,7 @@ func (a *App) CreateEmoji(sessionUserId string, emoji *model.Emoji, multiPartIma
imageData := multiPartImageData.File["image"]
if len(imageData) == 0 {
err := model.NewAppError("Context", "api.context.invalid_body_param.app_error", map[string]interface{}{"Name": "createEmoji"}, "", http.StatusBadRequest)
err := model.NewAppError("Context", "api.context.invalid_body_param.app_error", map[string]any{"Name": "createEmoji"}, "", http.StatusBadRequest)
return nil, err
}
@@ -123,7 +123,7 @@ func (a *App) UploadEmojiImage(id string, imageData *multipart.FileHeader) *mode
}
if config.Width > MaxEmojiOriginalWidth || config.Height > MaxEmojiOriginalHeight {
return model.NewAppError("uploadEmojiImage", "api.emoji.upload.large_image.too_large.app_error", map[string]interface{}{
return model.NewAppError("uploadEmojiImage", "api.emoji.upload.large_image.too_large.app_error", map[string]any{
"MaxWidth": MaxEmojiOriginalWidth,
"MaxHeight": MaxEmojiOriginalHeight,
}, "", http.StatusBadRequest)

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

@@ -79,7 +79,7 @@ func (a *App) getSessionExpiredPushMessage(session *model.Session) string {
T := i18n.GetUserTranslations(locale)
siteName := *a.Config().TeamSettings.SiteName
props := map[string]interface{}{"siteName": siteName, "hoursCount": *a.Config().ServiceSettings.SessionLengthMobileInHours}
props := map[string]any{"siteName": siteName, "hoursCount": *a.Config().ServiceSettings.SessionLengthMobileInHours}
return T("api.push_notifications.session.expired", props)
}

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

@@ -496,7 +496,7 @@ func TestExportPostWithProps(t *testing.T) {
p1 := &model.Post{
ChannelId: dmChannel.Id,
Message: "aa" + model.NewId() + "a",
Props: map[string]interface{}{
Props: map[string]any{
"attachments": attachments,
},
UserId: th1.BasicUser.Id,
@@ -506,7 +506,7 @@ func TestExportPostWithProps(t *testing.T) {
p2 := &model.Post{
ChannelId: gmChannel.Id,
Message: "dd" + model.NewId() + "a",
Props: map[string]interface{}{
Props: map[string]any{
"attachments": attachments,
},
UserId: th1.BasicUser.Id,
@@ -545,8 +545,8 @@ func TestExportPostWithProps(t *testing.T) {
assert.Len(t, posts, 2)
assert.ElementsMatch(t, gmMembers, *posts[0].ChannelMembers)
assert.ElementsMatch(t, dmMembers, *posts[1].ChannelMembers)
assert.Contains(t, posts[0].Props["attachments"].([]interface{})[0], "footer")
assert.Contains(t, posts[1].Props["attachments"].([]interface{})[0], "footer")
assert.Contains(t, posts[0].Props["attachments"].([]any)[0], "footer")
assert.Contains(t, posts[1].Props["attachments"].([]any)[0], "footer")
}
func TestExportDMPostWithSelf(t *testing.T) {

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

@@ -61,7 +61,7 @@ func (s *Server) startFeatureFlagUpdateJob() error {
log = s.Log
}
attributes := map[string]interface{}{}
attributes := map[string]any{}
// if we are part of a cloud installation, add its installation and group id
if installationId := os.Getenv("MM_CLOUD_INSTALLATION_ID"); installationId != "" {

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

@@ -22,7 +22,7 @@ type SyncParams struct {
SplitKey string
SyncIntervalSeconds int
Log *mlog.Logger
Attributes map[string]interface{}
Attributes map[string]any
}
type Synchronizer struct {
@@ -100,7 +100,7 @@ func featureFlagsFromMap(featuresMap map[string]string, baseFeatureFlags model.F
return baseFeatureFlags
}
func getStructFields(s interface{}) []string {
func getStructFields(s any) []string {
structType := reflect.TypeOf(s)
fieldNames := make([]string, 0, structType.NumField())
for i := 0; i < structType.NumField(); i++ {

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

@@ -13,23 +13,23 @@ type splitLogger struct {
wrappedLog *mlog.Logger
}
func (s *splitLogger) Error(msg ...interface{}) {
func (s *splitLogger) Error(msg ...any) {
s.wrappedLog.Error(fmt.Sprint(msg...))
}
func (s *splitLogger) Warning(msg ...interface{}) {
func (s *splitLogger) Warning(msg ...any) {
s.wrappedLog.Warn(fmt.Sprint(msg...))
}
// Ignoring more verbose messages from split
func (s *splitLogger) Info(msg ...interface{}) {
func (s *splitLogger) Info(msg ...any) {
//s.wrappedLog.Info(fmt.Sprint(msg...))
}
func (s *splitLogger) Debug(msg ...interface{}) {
func (s *splitLogger) Debug(msg ...any) {
//s.wrappedLog.Debug(fmt.Sprint(msg...))
}
func (s *splitLogger) Verbose(msg ...interface{}) {
func (s *splitLogger) Verbose(msg ...any) {
//s.wrappedLog.Info(fmt.Sprint(msg...))
}

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

@@ -456,7 +456,7 @@ func (a *App) UploadMultipartFiles(c *request.Context, teamID string, channelID
file, fileErr := fileHeader.Open()
if fileErr != nil {
return nil, model.NewAppError("UploadFiles", "api.file.upload_file.read_request.app_error",
map[string]interface{}{"Filename": fileHeader.Filename}, fileErr.Error(), http.StatusBadRequest)
map[string]any{"Filename": fileHeader.Filename}, fileErr.Error(), http.StatusBadRequest)
}
// Will be closed after UploadFiles returns
@@ -523,7 +523,7 @@ func (a *App) UploadFile(c *request.Context, data []byte, channelID string, file
_, err := a.GetChannel(channelID)
if err != nil && channelID != "" {
return nil, model.NewAppError("UploadFile", "api.file.upload_file.incorrect_channelId.app_error",
map[string]interface{}{"channelId": channelID}, "", http.StatusBadRequest)
map[string]any{"channelId": channelID}, "", http.StatusBadRequest)
}
info, _, appError := a.DoUploadFileExpectModification(c, time.Now(), "noteam", channelID, "nouser", filename, data)
@@ -898,8 +898,8 @@ func (t UploadFileTask) pathPrefix() string {
"/" + t.fileinfo.Id + "/"
}
func (t UploadFileTask) newAppError(id string, httpStatus int, extra ...interface{}) *model.AppError {
params := map[string]interface{}{
func (t UploadFileTask) newAppError(id string, httpStatus int, extra ...any) *model.AppError {
params := map[string]any{
"Name": t.Name,
"Filename": t.Name,
"ChannelId": t.ChannelId,
@@ -948,7 +948,7 @@ func (a *App) DoUploadFileExpectModification(c *request.Context, now time.Time,
if info.IsImage() && !info.IsSvg() {
if limitErr := checkImageResolutionLimit(info.Width, info.Height, *a.Config().FileSettings.MaxImageResolution); limitErr != nil {
err := model.NewAppError("uploadFile", "api.file.upload_file.large_image.app_error", map[string]interface{}{"Filename": filename}, limitErr.Error(), http.StatusBadRequest)
err := model.NewAppError("uploadFile", "api.file.upload_file.large_image.app_error", map[string]any{"Filename": filename}, limitErr.Error(), http.StatusBadRequest)
return nil, data, err
}

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

@@ -314,7 +314,7 @@ func (a *App) importLine(c *request.Context, line LineImportData, dryRun bool) *
}
return a.importEmoji(line.Emoji, dryRun)
default:
return model.NewAppError("BulkImport", "app.import.import_line.unknown_line_type.error", map[string]interface{}{"Type": line.Type}, "", http.StatusBadRequest)
return model.NewAppError("BulkImport", "app.import.import_line.unknown_line_type.error", map[string]any{"Type": line.Type}, "", http.StatusBadRequest)
}
}

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

@@ -45,7 +45,7 @@ func (a *App) importScheme(data *SchemeImportData, dryRun bool) *model.AppError
if err != nil {
scheme = new(model.Scheme)
} else if scheme.Scope != *data.Scope {
return model.NewAppError("BulkImport", "app.import.import_scheme.scope_change.error", map[string]interface{}{"SchemeName": scheme.Name}, "", http.StatusBadRequest)
return model.NewAppError("BulkImport", "app.import.import_scheme.scope_change.error", map[string]any{"SchemeName": scheme.Name}, "", http.StatusBadRequest)
}
scheme.Name = *data.Name
@@ -239,7 +239,7 @@ func (a *App) importChannel(c *request.Context, data *ChannelImportData, dryRun
team, err := a.Srv().Store.Team().GetByName(*data.Team)
if err != nil {
return model.NewAppError("BulkImport", "app.import.import_channel.team_not_found.error", map[string]interface{}{"TeamName": *data.Team}, err.Error(), http.StatusBadRequest)
return model.NewAppError("BulkImport", "app.import.import_channel.team_not_found.error", map[string]any{"TeamName": *data.Team}, err.Error(), http.StatusBadRequest)
}
var channel *model.Channel
@@ -1068,7 +1068,7 @@ func (a *App) importReaction(data *ReactionImportData, post *model.Post) *model.
var user *model.User
var nErr error
if user, nErr = a.Srv().Store.User().GetByUsername(*data.User); nErr != nil {
return model.NewAppError("BulkImport", "app.import.import_post.user_not_found.error", map[string]interface{}{"Username": data.User}, nErr.Error(), http.StatusBadRequest)
return model.NewAppError("BulkImport", "app.import.import_post.user_not_found.error", map[string]any{"Username": data.User}, nErr.Error(), http.StatusBadRequest)
}
reaction := &model.Reaction{
@@ -1200,7 +1200,7 @@ func (a *App) importAttachment(c *request.Context, data *AttachmentImportData, p
if data.Data != nil {
zipFile, err := data.Data.Open()
if err != nil {
return nil, model.NewAppError("BulkImport", "app.import.attachment.bad_file.error", map[string]interface{}{"FilePath": *data.Path}, err.Error(), http.StatusBadRequest)
return nil, model.NewAppError("BulkImport", "app.import.attachment.bad_file.error", map[string]any{"FilePath": *data.Path}, err.Error(), http.StatusBadRequest)
}
defer zipFile.Close()
name = data.Data.Name
@@ -1208,7 +1208,7 @@ func (a *App) importAttachment(c *request.Context, data *AttachmentImportData, p
} else {
realFile, err := os.Open(*data.Path)
if err != nil {
return nil, model.NewAppError("BulkImport", "app.import.attachment.bad_file.error", map[string]interface{}{"FilePath": *data.Path}, err.Error(), http.StatusBadRequest)
return nil, model.NewAppError("BulkImport", "app.import.attachment.bad_file.error", map[string]any{"FilePath": *data.Path}, err.Error(), http.StatusBadRequest)
}
defer realFile.Close()
name = realFile.Name()
@@ -1219,14 +1219,14 @@ func (a *App) importAttachment(c *request.Context, data *AttachmentImportData, p
fileData, err := ioutil.ReadAll(file)
if err != nil {
return nil, model.NewAppError("BulkImport", "app.import.attachment.read_file_data.error", map[string]interface{}{"FilePath": *data.Path}, "", http.StatusBadRequest)
return nil, model.NewAppError("BulkImport", "app.import.attachment.read_file_data.error", map[string]any{"FilePath": *data.Path}, "", http.StatusBadRequest)
}
// Go over existing files in the post and see if there already exists a file with the same name, size and hash. If so - skip it
if post.Id != "" {
oldFiles, err := a.GetFileInfosForPost(post.Id, true)
if err != nil {
return nil, model.NewAppError("BulkImport", "app.import.attachment.file_upload.error", map[string]interface{}{"FilePath": *data.Path}, "", http.StatusBadRequest)
return nil, model.NewAppError("BulkImport", "app.import.attachment.file_upload.error", map[string]any{"FilePath": *data.Path}, "", http.StatusBadRequest)
}
for _, oldFile := range oldFiles {
if oldFile.Name != path.Base(name) || oldFile.Size != int64(len(fileData)) {
@@ -1236,7 +1236,7 @@ func (a *App) importAttachment(c *request.Context, data *AttachmentImportData, p
newHash := sha1.Sum(fileData)
oldFileData, err := a.GetFile(oldFile.Id)
if err != nil {
return nil, model.NewAppError("BulkImport", "app.import.attachment.file_upload.error", map[string]interface{}{"FilePath": *data.Path}, "", http.StatusBadRequest)
return nil, model.NewAppError("BulkImport", "app.import.attachment.file_upload.error", map[string]any{"FilePath": *data.Path}, "", http.StatusBadRequest)
}
oldHash := sha1.Sum(oldFileData)
@@ -1327,7 +1327,7 @@ func (a *App) getChannelsForPosts(teams map[string]*model.Team, data []*PostImpo
var err error
channel, err = a.Srv().Store.Channel().GetByName(teams[teamName].Id, *postData.Channel, true)
if err != nil {
return nil, model.NewAppError("BulkImport", "app.import.import_post.channel_not_found.error", map[string]interface{}{"ChannelName": *postData.Channel}, err.Error(), http.StatusBadRequest)
return nil, model.NewAppError("BulkImport", "app.import.import_post.channel_not_found.error", map[string]any{"ChannelName": *postData.Channel}, err.Error(), http.StatusBadRequest)
}
teamChannels[teamName][*postData.Channel] = channel
}
@@ -1881,7 +1881,7 @@ func (a *App) importEmoji(data *EmojiImportData, dryRun bool) *model.AppError {
file, err = os.Open(*data.Image)
}
if err != nil {
return model.NewAppError("BulkImport", "app.import.emoji.bad_file.error", map[string]interface{}{"EmojiName": *data.Name}, "", http.StatusBadRequest)
return model.NewAppError("BulkImport", "app.import.emoji.bad_file.error", map[string]any{"EmojiName": *data.Name}, "", http.StatusBadRequest)
}
defer file.Close()

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

@@ -492,7 +492,7 @@ func validateDirectChannelImportData(data *DirectChannelImportData) *model.AppEr
}
}
if !found {
return model.NewAppError("BulkImport", "app.import.validate_direct_channel_import_data.unknown_favoriter.error", map[string]interface{}{"Username": favoriter}, "", http.StatusBadRequest)
return model.NewAppError("BulkImport", "app.import.validate_direct_channel_import_data.unknown_favoriter.error", map[string]any{"Username": favoriter}, "", http.StatusBadRequest)
}
}
}
@@ -539,7 +539,7 @@ func validateDirectPostImportData(data *DirectPostImportData, maxPostSize int) *
}
}
if !found {
return model.NewAppError("BulkImport", "app.import.validate_direct_post_import_data.unknown_flagger.error", map[string]interface{}{"Username": flagger}, "", http.StatusBadRequest)
return model.NewAppError("BulkImport", "app.import.validate_direct_post_import_data.unknown_flagger.error", map[string]any{"Username": flagger}, "", http.StatusBadRequest)
}
}
}

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

@@ -51,7 +51,7 @@ func (a *App) DoPostActionWithCookie(c *request.Context, postID, actionId, userI
// IsPinned and HasReaction attributes, and preserve its entire
// original Props set unless the plugin returns a replacement value.
// originalXxx variables are used to preserve these values.
var originalProps map[string]interface{}
var originalProps map[string]any
originalIsPinned := false
originalHasReactions := false
@@ -59,7 +59,7 @@ func (a *App) DoPostActionWithCookie(c *request.Context, postID, actionId, userI
// need to preserve some original values, as listed in
// model.PostActionRetainPropKeys. remove and retain track these.
remove := []string{}
retain := map[string]interface{}{}
retain := map[string]any{}
datasource := ""
upstreamURL := ""
@@ -222,7 +222,7 @@ func (a *App) DoPostActionWithCookie(c *request.Context, postID, actionId, userI
if upstreamRequest.Type == model.PostActionTypeSelect {
if selectedOption != "" {
if upstreamRequest.Context == nil {
upstreamRequest.Context = map[string]interface{}{}
upstreamRequest.Context = map[string]any{}
}
upstreamRequest.DataSource = datasource
upstreamRequest.Context["selected_option"] = selectedOption
@@ -548,23 +548,23 @@ func (a *App) buildWarnMetricMailtoLink(warnMetricId string, user *model.User) s
_, warnMetricDisplayTexts := a.getWarnMetricStatusAndDisplayTextsForId(warnMetricId, T, false)
mailBody := warnMetricDisplayTexts.EmailBody
mailBody += T("api.server.warn_metric.bot_response.mailto_contact_header", map[string]interface{}{"Contact": user.GetFullName()})
mailBody += T("api.server.warn_metric.bot_response.mailto_contact_header", map[string]any{"Contact": user.GetFullName()})
mailBody += "\r\n"
mailBody += T("api.server.warn_metric.bot_response.mailto_email_header", map[string]interface{}{"Email": user.Email})
mailBody += T("api.server.warn_metric.bot_response.mailto_email_header", map[string]any{"Email": user.Email})
mailBody += "\r\n"
registeredUsersCount, err := a.Srv().Store.User().Count(model.UserCountOptions{})
if err != nil {
mlog.Warn("Error retrieving the number of registered users", mlog.Err(err))
} else {
mailBody += i18n.T("api.server.warn_metric.bot_response.mailto_registered_users_header", map[string]interface{}{"NoRegisteredUsers": registeredUsersCount})
mailBody += i18n.T("api.server.warn_metric.bot_response.mailto_registered_users_header", map[string]any{"NoRegisteredUsers": registeredUsersCount})
mailBody += "\r\n"
}
mailBody += T("api.server.warn_metric.bot_response.mailto_site_url_header", map[string]interface{}{"SiteUrl": a.GetSiteURL()})
mailBody += T("api.server.warn_metric.bot_response.mailto_site_url_header", map[string]any{"SiteUrl": a.GetSiteURL()})
mailBody += "\r\n"
mailBody += T("api.server.warn_metric.bot_response.mailto_diagnostic_id_header", map[string]interface{}{"DiagnosticId": a.TelemetryId()})
mailBody += T("api.server.warn_metric.bot_response.mailto_diagnostic_id_header", map[string]any{"DiagnosticId": a.TelemetryId()})
mailBody += "\r\n"
mailBody += T("api.server.warn_metric.bot_response.mailto_footer")

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

@@ -501,7 +501,7 @@ func TestSubmitInteractiveDialog(t *testing.T) {
TeamId: th.BasicTeam.Id,
CallbackId: "someid",
State: "somestate",
Submission: map[string]interface{}{
Submission: map[string]any{
"name1": "value1",
},
}

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

@@ -106,7 +106,7 @@ func (a *App) checkIfIntegrationsMeetFreemiumLimits(originalPluginIds []string)
limit := *limits.Integrations.Enabled
if enableCount > limit {
return model.NewAppError("checkIfIntegrationMeetsFreemiumLimits", "app.install_integration.reached_max_limit.error", map[string]interface{}{"NumIntegrations": limit}, "", http.StatusBadRequest)
return model.NewAppError("checkIfIntegrationMeetsFreemiumLimits", "app.install_integration.reached_max_limit.error", map[string]any{"NumIntegrations": limit}, "", http.StatusBadRequest)
}
return nil

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

@@ -85,7 +85,7 @@ func fixTypeName(t string) string {
if t == "...func(*UploadFileTask)" {
t = "...func(*app.UploadFileTask)"
}
if strings.Contains(t, ".") || strings.Contains(t, "{}") {
if strings.Contains(t, ".") || strings.Contains(t, "{}") || t == "map[string]any" {
return t
}
typeOnly := textRegexp.FindString(t)

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

@@ -55,7 +55,7 @@ func (a *App) GetLdapGroup(ldapGroupID string) (*model.Group, *model.AppError) {
return nil, err
}
} else {
ae := model.NewAppError("GetLdapGroup", "ent.ldap.app_error", map[string]interface{}{"ldap_group_id": ldapGroupID}, "", http.StatusNotImplemented)
ae := model.NewAppError("GetLdapGroup", "ent.ldap.app_error", map[string]any{"ldap_group_id": ldapGroupID}, "", http.StatusNotImplemented)
return nil, ae
}
@@ -235,7 +235,7 @@ func (a *App) AddLdapPrivateCertificate(fileData *multipart.FileHeader) *model.A
func (a *App) removeLdapFile(filename string) *model.AppError {
if err := a.Srv().configStore.RemoveFile(filename); err != nil {
return model.NewAppError("RemoveLdapFile", "api.admin.remove_certificate.delete.app_error", map[string]interface{}{"Filename": filename}, err.Error(), http.StatusInternalServerError)
return model.NewAppError("RemoveLdapFile", "api.admin.remove_certificate.delete.app_error", map[string]any{"Filename": filename}, err.Error(), http.StatusInternalServerError)
}
return nil
}

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

@@ -170,7 +170,7 @@ func (s *Server) SaveLicense(licenseBytes []byte) (*model.License, *model.AppErr
}
if uniqueUserCount > int64(*license.Features.Users) {
return nil, model.NewAppError("addLicense", "api.license.add_license.unique_users.app_error", map[string]interface{}{"Users": *license.Features.Users, "Count": uniqueUserCount}, "", http.StatusBadRequest)
return nil, model.NewAppError("addLicense", "api.license.add_license.unique_users.app_error", map[string]any{"Users": *license.Features.Users, "Count": uniqueUserCount}, "", http.StatusBadRequest)
}
if license.IsExpired() {

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

@@ -386,7 +386,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
post.UserId,
&model.Post{
ChannelId: post.ChannelId,
Message: T("api.post.disabled_here", map[string]interface{}{"Users": *a.Config().TeamSettings.MaxNotificationsPerChannel}),
Message: T("api.post.disabled_here", map[string]any{"Users": *a.Config().TeamSettings.MaxNotificationsPerChannel}),
CreateAt: post.CreateAt + 1,
},
)
@@ -397,7 +397,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
post.UserId,
&model.Post{
ChannelId: post.ChannelId,
Message: T("api.post.disabled_channel", map[string]interface{}{"Users": *a.Config().TeamSettings.MaxNotificationsPerChannel}),
Message: T("api.post.disabled_channel", map[string]any{"Users": *a.Config().TeamSettings.MaxNotificationsPerChannel}),
CreateAt: post.CreateAt + 1,
},
)
@@ -408,7 +408,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
post.UserId,
&model.Post{
ChannelId: post.ChannelId,
Message: T("api.post.disabled_all", map[string]interface{}{"Users": *a.Config().TeamSettings.MaxNotificationsPerChannel}),
Message: T("api.post.disabled_all", map[string]any{"Users": *a.Config().TeamSettings.MaxNotificationsPerChannel}),
CreateAt: post.CreateAt + 1,
},
)
@@ -801,13 +801,13 @@ func makeOutOfChannelMentionPost(sender *model.User, post *model.Post, outOfChan
ephemeralPostId := model.NewId()
var message string
if len(outOfChannelUsers) == 1 {
message = T("api.post.check_for_out_of_channel_mentions.message.one", map[string]interface{}{
message = T("api.post.check_for_out_of_channel_mentions.message.one", map[string]any{
"Username": ocUsernames[0],
})
} else if len(outOfChannelUsers) > 1 {
preliminary, final := splitAtFinal(ocUsernames)
message = T("api.post.check_for_out_of_channel_mentions.message.multiple", map[string]interface{}{
message = T("api.post.check_for_out_of_channel_mentions.message.multiple", map[string]any{
"Usernames": strings.Join(preliminary, ", @"),
"LastUsername": final,
})
@@ -818,7 +818,7 @@ func makeOutOfChannelMentionPost(sender *model.User, post *model.Post, outOfChan
message += "\n"
}
message += T("api.post.check_for_out_of_channel_groups_mentions.message.one", map[string]interface{}{
message += T("api.post.check_for_out_of_channel_groups_mentions.message.one", map[string]any{
"Username": ogUsernames[0],
})
} else if len(outOfGroupsUsers) > 1 {
@@ -828,7 +828,7 @@ func makeOutOfChannelMentionPost(sender *model.User, post *model.Post, outOfChan
message += "\n"
}
message += T("api.post.check_for_out_of_channel_groups_mentions.message.multiple", map[string]interface{}{
message += T("api.post.check_for_out_of_channel_groups_mentions.message.multiple", map[string]any{
"Usernames": strings.Join(preliminary, ", @"),
"LastUsername": final,
})
@@ -986,7 +986,7 @@ func getExplicitMentions(post *model.Post, keywords map[string][]string, groups
buf := ""
mentionsEnabledFields := getMentionsEnabledFields(post)
for _, message := range mentionsEnabledFields {
markdown.Inspect(message, func(node interface{}) bool {
markdown.Inspect(message, func(node any) bool {
text, ok := node.(*markdown.Text)
if !ok {
ret.processText(buf, keywords, groups)

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

@@ -145,7 +145,7 @@ func (a *App) sendNotificationEmail(notification *PostNotification, user *model.
*/
func getDirectMessageNotificationEmailSubject(user *model.User, post *model.Post, translateFunc i18n.TranslateFunc, siteName string, senderName string, useMilitaryTime bool) string {
t := getFormattedPostTime(user, post, useMilitaryTime, translateFunc)
var subjectParameters = map[string]interface{}{
var subjectParameters = map[string]any{
"SiteName": siteName,
"SenderDisplayName": senderName,
"Month": t.Month,
@@ -160,7 +160,7 @@ func getDirectMessageNotificationEmailSubject(user *model.User, post *model.Post
*/
func getNotificationEmailSubject(user *model.User, post *model.Post, translateFunc i18n.TranslateFunc, siteName string, teamName string, useMilitaryTime bool) string {
t := getFormattedPostTime(user, post, useMilitaryTime, translateFunc)
var subjectParameters = map[string]interface{}{
var subjectParameters = map[string]any{
"SiteName": siteName,
"TeamName": teamName,
"Month": t.Month,
@@ -175,7 +175,7 @@ func getNotificationEmailSubject(user *model.User, post *model.Post, translateFu
*/
func getGroupMessageNotificationEmailSubject(user *model.User, post *model.Post, translateFunc i18n.TranslateFunc, siteName string, channelName string, emailNotificationContentsType string, useMilitaryTime bool) string {
t := getFormattedPostTime(user, post, useMilitaryTime, translateFunc)
var subjectParameters = map[string]interface{}{
var subjectParameters = map[string]any{
"SiteName": siteName,
"Month": t.Month,
"Day": t.Day,
@@ -222,7 +222,7 @@ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post,
}
t := getFormattedPostTime(recipient, post, useMilitaryTime, translateFunc)
messageTime := map[string]interface{}{
messageTime := map[string]any{
"Hour": t.Hour,
"Minute": t.Minute,
"TimeZone": t.TimeZone,
@@ -262,36 +262,36 @@ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post,
if channel.Type == model.ChannelTypeDirect {
// Direct Messages
data.Props["Title"] = translateFunc("app.notification.body.dm.title", map[string]interface{}{"SenderName": senderName})
data.Props["SubTitle"] = translateFunc("app.notification.body.dm.subTitle", map[string]interface{}{"SenderName": senderName})
data.Props["Title"] = translateFunc("app.notification.body.dm.title", map[string]any{"SenderName": senderName})
data.Props["SubTitle"] = translateFunc("app.notification.body.dm.subTitle", map[string]any{"SenderName": senderName})
} else if channel.Type == model.ChannelTypeGroup {
// Group Messages
data.Props["Title"] = translateFunc("app.notification.body.group.title", map[string]interface{}{"SenderName": senderName})
data.Props["SubTitle"] = translateFunc("app.notification.body.group.subTitle", map[string]interface{}{"SenderName": senderName})
data.Props["Title"] = translateFunc("app.notification.body.group.title", map[string]any{"SenderName": senderName})
data.Props["SubTitle"] = translateFunc("app.notification.body.group.subTitle", map[string]any{"SenderName": senderName})
} else {
// mentions
data.Props["Title"] = translateFunc("app.notification.body.mention.title", map[string]interface{}{"SenderName": senderName})
data.Props["SubTitle"] = translateFunc("app.notification.body.mention.subTitle", map[string]interface{}{"SenderName": senderName, "ChannelName": channelName})
data.Props["Title"] = translateFunc("app.notification.body.mention.title", map[string]any{"SenderName": senderName})
data.Props["SubTitle"] = translateFunc("app.notification.body.mention.subTitle", map[string]any{"SenderName": senderName, "ChannelName": channelName})
pData.ChannelName = channelName
}
// Override title and subtile for replies with CRT enabled
if a.IsCRTEnabledForUser(recipient.Id) && post.RootId != "" {
// Title is the same in all cases
data.Props["Title"] = translateFunc("app.notification.body.thread.title", map[string]interface{}{"SenderName": senderName})
data.Props["Title"] = translateFunc("app.notification.body.thread.title", map[string]any{"SenderName": senderName})
if channel.Type == model.ChannelTypeDirect {
// Direct Reply
data.Props["SubTitle"] = translateFunc("app.notification.body.thread_dm.subTitle", map[string]interface{}{"SenderName": senderName})
data.Props["SubTitle"] = translateFunc("app.notification.body.thread_dm.subTitle", map[string]any{"SenderName": senderName})
} else if channel.Type == model.ChannelTypeGroup {
// Group Reply
data.Props["SubTitle"] = translateFunc("app.notification.body.thread_gm.subTitle", map[string]interface{}{"SenderName": senderName})
data.Props["SubTitle"] = translateFunc("app.notification.body.thread_gm.subTitle", map[string]any{"SenderName": senderName})
} else if emailNotificationContentsType == model.EmailNotificationContentsFull {
// Channel Reply with full content
data.Props["SubTitle"] = translateFunc("app.notification.body.thread_channel_full.subTitle", map[string]interface{}{"SenderName": senderName, "ChannelName": channelName})
data.Props["SubTitle"] = translateFunc("app.notification.body.thread_channel_full.subTitle", map[string]any{"SenderName": senderName, "ChannelName": channelName})
} else {
// Channel Reply with generic content
data.Props["SubTitle"] = translateFunc("app.notification.body.thread_channel.subTitle", map[string]interface{}{"SenderName": senderName})
data.Props["SubTitle"] = translateFunc("app.notification.body.thread_channel.subTitle", map[string]any{"SenderName": senderName})
}
}

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

@@ -660,7 +660,7 @@ func (a *App) buildFullPushNotificationMessage(contentsConfig string, post *mode
msg.IsCRTEnabled = true
if post.RootId != "" {
if contentsConfig != model.GenericNoChannelNotification {
props := map[string]interface{}{"channelName": channelName}
props := map[string]any{"channelName": channelName}
msg.ChannelName = userLocale("api.push_notification.title.collapsed_threads", props)
if channel.Type == model.ChannelTypeDirect {

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

@@ -1441,7 +1441,7 @@ func TestPushNotificationRace(t *testing.T) {
filestore: &fmocks.FileBackend{},
}
s.configStore = &configWrapper{srv: s, Store: memoryStore}
serviceMap := map[ServiceKey]interface{}{
serviceMap := map[ServiceKey]any{
ConfigKey: s.configStore,
LicenseKey: &licenseWrapper{s},
FilestoreKey: s.filestore,
@@ -1481,7 +1481,7 @@ func TestPushNotificationAttachment(t *testing.T) {
originalMessage := "hello world"
post := &model.Post{
Message: originalMessage,
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
AuthorName: "testuser",

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

@@ -41,7 +41,7 @@ func TestSendNotifications(t *testing.T) {
ChannelId: th.BasicChannel.Id,
Message: "@" + th.BasicUser2.Username,
Type: model.PostTypeAddToChannel,
Props: map[string]interface{}{model.PostPropsAddedUserId: "junk"},
Props: map[string]any{model.PostPropsAddedUserId: "junk"},
}, true)
require.Nil(t, appErr)
@@ -181,7 +181,7 @@ func TestSendNotificationsWithManyUsers(t *testing.T) {
ChannelId: th.BasicChannel.Id,
Message: "@channel",
Type: model.PostTypeAddToChannel,
Props: map[string]interface{}{model.PostPropsAddedUserId: "junk"},
Props: map[string]any{model.PostPropsAddedUserId: "junk"},
}, true)
require.Nil(t, appErr1)
@@ -201,7 +201,7 @@ func TestSendNotificationsWithManyUsers(t *testing.T) {
ChannelId: th.BasicChannel.Id,
Message: "@channel",
Type: model.PostTypeAddToChannel,
Props: map[string]interface{}{model.PostPropsAddedUserId: "junk"},
Props: map[string]any{model.PostPropsAddedUserId: "junk"},
}, true)
require.Nil(t, appErr1)

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

@@ -567,7 +567,7 @@ func (a *App) getSSOProvider(service string) (einterfaces.OAuthProvider, *model.
provider := einterfaces.GetOAuthProvider(providerType)
if provider == nil {
return nil, model.NewAppError("getSSOProvider", "api.user.login_by_oauth.not_available.app_error",
map[string]interface{}{"Service": strings.Title(service)}, "", http.StatusNotImplemented)
map[string]any{"Service": strings.Title(service)}, "", http.StatusNotImplemented)
}
return provider, nil
}
@@ -581,18 +581,18 @@ func (a *App) LoginByOAuth(c *request.Context, service string, userData io.Reade
buf := bytes.Buffer{}
if _, err := buf.ReadFrom(userData); err != nil {
return nil, model.NewAppError("LoginByOAuth2", "api.user.login_by_oauth.parse.app_error",
map[string]interface{}{"Service": service}, "", http.StatusBadRequest)
map[string]any{"Service": service}, "", http.StatusBadRequest)
}
authUser, err1 := provider.GetUserFromJSON(bytes.NewReader(buf.Bytes()), tokenUser)
if err1 != nil {
return nil, model.NewAppError("LoginByOAuth", "api.user.login_by_oauth.parse.app_error",
map[string]interface{}{"Service": service}, err1.Error(), http.StatusBadRequest)
map[string]any{"Service": service}, err1.Error(), http.StatusBadRequest)
}
if *authUser.AuthData == "" {
return nil, model.NewAppError("LoginByOAuth3", "api.user.login_by_oauth.parse.app_error",
map[string]interface{}{"Service": service}, "", http.StatusBadRequest)
map[string]any{"Service": service}, "", http.StatusBadRequest)
}
user, err := a.GetUserByAuth(model.NewString(*authUser.AuthData), service)
@@ -638,12 +638,12 @@ func (a *App) CompleteSwitchWithOAuth(service string, userData io.Reader, email
ssoUser, err1 := provider.GetUserFromJSON(userData, tokenUser)
if err1 != nil {
return nil, model.NewAppError("CompleteSwitchWithOAuth", "api.user.complete_switch_with_oauth.parse.app_error",
map[string]interface{}{"Service": service}, err1.Error(), http.StatusBadRequest)
map[string]any{"Service": service}, err1.Error(), http.StatusBadRequest)
}
if *ssoUser.AuthData == "" {
return nil, model.NewAppError("CompleteSwitchWithOAuth", "api.user.complete_switch_with_oauth.parse.app_error",
map[string]interface{}{"Service": service}, "", http.StatusBadRequest)
map[string]any{"Service": service}, "", http.StatusBadRequest)
}
user, nErr := a.Srv().Store.User().GetByEmail(email)
@@ -877,7 +877,7 @@ func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service
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)
return nil, "", stateProps, nil, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.service.app_error", map[string]any{"Service": service}, requestErr.Error(), http.StatusInternalServerError)
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
@@ -886,7 +886,7 @@ func (a *App) AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service
resp, err = a.HTTPService().MakeClient(true).Do(req)
if err != nil {
return nil, "", stateProps, nil, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.service.app_error", map[string]interface{}{"Service": service}, err.Error(), http.StatusInternalServerError)
return nil, "", stateProps, nil, model.NewAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.service.app_error", map[string]any{"Service": service}, err.Error(), http.StatusInternalServerError)
} else if resp.StatusCode != http.StatusOK {
defer resp.Body.Close()

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

@@ -3933,7 +3933,7 @@ func (a *OpenTracingAppLayer) EnsureBot(c *request.Context, productID string, bo
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) EnvironmentConfig(filter func(reflect.StructField) bool) map[string]interface{} {
func (a *OpenTracingAppLayer) EnvironmentConfig(filter func(reflect.StructField) bool) map[string]any {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.EnvironmentConfig")
@@ -5865,7 +5865,7 @@ func (a *OpenTracingAppLayer) GetEmojiStaticURL(emojiName string) (string, *mode
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetEnvironmentConfig(filter func(reflect.StructField) bool) map[string]interface{} {
func (a *OpenTracingAppLayer) GetEnvironmentConfig(filter func(reflect.StructField) bool) map[string]any {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetEnvironmentConfig")
@@ -9117,7 +9117,7 @@ func (a *OpenTracingAppLayer) GetStatusFromCache(userID string) *model.Status {
return resultVar0
}
func (a *OpenTracingAppLayer) GetStatusesByIds(userIDs []string) (map[string]interface{}, *model.AppError) {
func (a *OpenTracingAppLayer) GetStatusesByIds(userIDs []string) (map[string]any, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetStatusesByIds")

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

@@ -20,7 +20,7 @@ type Option func(s *Server) error
// construct an app with a different store.
//
// The override parameter must be either a store.Store or func(App) store.Store().
func StoreOverride(override interface{}) Option {
func StoreOverride(override any) Option {
return func(s *Server) error {
switch o := override.(type) {
case store.Store:

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

@@ -54,7 +54,7 @@ func TestExportPermissions(t *testing.T) {
firstResult := results[0]
var row map[string]interface{}
var row map[string]any
err = json.Unmarshal(firstResult, &row)
if err != nil {
t.Error(err)

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

@@ -40,8 +40,8 @@ func NewPluginAPI(a *App, c *request.Context, manifest *model.Manifest) *PluginA
}
}
func (api *PluginAPI) LoadPluginConfiguration(dest interface{}) error {
finalConfig := make(map[string]interface{})
func (api *PluginAPI) LoadPluginConfiguration(dest any) error {
finalConfig := make(map[string]any)
// First set final config to defaults
if api.manifest.SettingsSchema != nil {
@@ -104,15 +104,15 @@ func (api *PluginAPI) SaveConfig(config *model.Config) *model.AppError {
return err
}
func (api *PluginAPI) GetPluginConfig() map[string]interface{} {
func (api *PluginAPI) GetPluginConfig() map[string]any {
cfg := api.app.GetSanitizedConfig()
if pluginConfig, isOk := cfg.PluginSettings.Plugins[api.manifest.Id]; isOk {
return pluginConfig
}
return map[string]interface{}{}
return map[string]any{}
}
func (api *PluginAPI) SavePluginConfig(pluginConfig map[string]interface{}) *model.AppError {
func (api *PluginAPI) SavePluginConfig(pluginConfig map[string]any) *model.AppError {
cfg := api.app.GetSanitizedConfig()
cfg.PluginSettings.Plugins[api.manifest.Id] = pluginConfig
_, _, err := api.app.SaveConfig(cfg, true)
@@ -908,7 +908,7 @@ func (api *PluginAPI) KVList(page, perPage int) ([]string, *model.AppError) {
return api.app.ListPluginKeys(api.id, page, perPage)
}
func (api *PluginAPI) PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast) {
func (api *PluginAPI) PublishWebSocketEvent(event string, payload map[string]any, broadcast *model.WebsocketBroadcast) {
ev := model.NewWebSocketEvent(fmt.Sprintf("custom_%v_%v", api.id, event), "", "", "", nil)
ev = ev.SetBroadcast(broadcast).SetData(payload)
api.app.Publish(ev)
@@ -930,16 +930,16 @@ func (api *PluginAPI) RolesGrantPermission(roleNames []string, permissionId stri
return api.app.RolesGrantPermission(roleNames, permissionId)
}
func (api *PluginAPI) LogDebug(msg string, keyValuePairs ...interface{}) {
func (api *PluginAPI) LogDebug(msg string, keyValuePairs ...any) {
api.logger.Debugw(msg, keyValuePairs...)
}
func (api *PluginAPI) LogInfo(msg string, keyValuePairs ...interface{}) {
func (api *PluginAPI) LogInfo(msg string, keyValuePairs ...any) {
api.logger.Infow(msg, keyValuePairs...)
}
func (api *PluginAPI) LogError(msg string, keyValuePairs ...interface{}) {
func (api *PluginAPI) LogError(msg string, keyValuePairs ...any) {
api.logger.Errorw(msg, keyValuePairs...)
}
func (api *PluginAPI) LogWarn(msg string, keyValuePairs ...interface{}) {
func (api *PluginAPI) LogWarn(msg string, keyValuePairs ...any) {
api.logger.Warnw(msg, keyValuePairs...)
}

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

@@ -54,7 +54,7 @@ func getDefaultPluginSettingsSchema() string {
func setDefaultPluginConfig(th *TestHelper, pluginID string) {
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.PluginSettings.Plugins[pluginID] = map[string]interface{}{
cfg.PluginSettings.Plugins[pluginID] = map[string]any{
"BasicChannelName": th.BasicChannel.Name,
"BasicChannelId": th.BasicChannel.Id,
"BasicTeamName": th.BasicTeam.Name,
@@ -691,7 +691,7 @@ func TestPluginAPISavePluginConfig(t *testing.T) {
pluginConfigJsonString := `{"mystringsetting": "str", "MyIntSetting": 32, "myboolsetting": true}`
var pluginConfig map[string]interface{}
var pluginConfig map[string]any
err := json.Unmarshal([]byte(pluginConfigJsonString), &pluginConfig)
require.NoError(t, err)
@@ -733,7 +733,7 @@ func TestPluginAPIGetPluginConfig(t *testing.T) {
api := NewPluginAPI(th.App, th.Context, manifest)
pluginConfigJsonString := `{"mystringsetting": "str", "myintsetting": 32, "myboolsetting": true}`
var pluginConfig map[string]interface{}
var pluginConfig map[string]any
err := json.Unmarshal([]byte(pluginConfigJsonString), &pluginConfig)
require.NoError(t, err)
@@ -750,7 +750,7 @@ func TestPluginAPILoadPluginConfiguration(t *testing.T) {
th := Setup(t)
defer th.TearDown()
var pluginJson map[string]interface{}
var pluginJson map[string]any
err := json.Unmarshal([]byte(`{"mystringsetting": "str", "MyIntSetting": 32, "myboolsetting": true}`), &pluginJson)
require.NoError(t, err)
@@ -785,7 +785,7 @@ func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
th := Setup(t)
defer th.TearDown()
var pluginJson map[string]interface{}
var pluginJson map[string]any
err := json.Unmarshal([]byte(`{"mystringsetting": "override"}`), &pluginJson)
require.NoError(t, err)
@@ -967,7 +967,7 @@ func TestInstallPlugin(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
*cfg.PluginSettings.EnableUploads = true
cfg.PluginSettings.Plugins["testinstallplugin"] = map[string]interface{}{
cfg.PluginSettings.Plugins["testinstallplugin"] = map[string]any{
"DownloadURL": ts.URL + "/testplugin.tar.gz",
}
})
@@ -1789,7 +1789,7 @@ func TestPluginHTTPUpgradeWebSocket(t *testing.T) {
require.Equal(t, resp.Status, model.StatusOk)
for i := 0; i < 10; i++ {
wsc.SendMessage("custom_action", map[string]interface{}{"value": i})
wsc.SendMessage("custom_action", map[string]any{"value": i})
var resp *model.WebSocketResponse
select {
case resp = <-wsc.ResponseChannel:

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

@@ -19,7 +19,7 @@ type BasicConfig struct {
BasicUserID string
}
func IsEmpty(object interface{}) bool {
func IsEmpty(object any) bool {
// get nil case out of the way
if object == nil {

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

@@ -37,7 +37,7 @@ func (p *Plugin) ServeHTTP(_ *plugin.Context, w http.ResponseWriter, r *http.Req
if err != nil {
break
}
resp := model.NewWebSocketResponse("OK", req.Seq, map[string]interface{}{"action": req.Action, "value": req.Data["value"]})
resp := model.NewWebSocketResponse("OK", req.Seq, map[string]any{"action": req.Action, "value": req.Data["value"]})
respJSON, err := resp.ToJSON()
if err != nil {
break

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

@@ -142,7 +142,7 @@ func (a *App) tryExecutePluginCommand(c *request.Context, args *model.CommandArg
// Checking if plugin is working or not
if err := pluginsEnvironment.PerformHealthCheck(matched.PluginId); err != nil {
return matched.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command_error.error.app_error", map[string]interface{}{"Command": trigger}, "err= Plugin has recently crashed: "+matched.PluginId, http.StatusInternalServerError)
return matched.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command_error.error.app_error", map[string]any{"Command": trigger}, "err= Plugin has recently crashed: "+matched.PluginId, http.StatusInternalServerError)
}
pluginHooks, err := pluginsEnvironment.HooksForPlugin(matched.PluginId)
@@ -163,7 +163,7 @@ func (a *App) tryExecutePluginCommand(c *request.Context, args *model.CommandArg
// Checking if plugin crashed after running the command
if err := pluginsEnvironment.PerformHealthCheck(matched.PluginId); err != nil {
errMessage := fmt.Sprintf("err= Plugin %s crashed due to /%s command", matched.PluginId, trigger)
return matched.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command_crash.error.app_error", map[string]interface{}{"Command": trigger, "PluginId": matched.PluginId}, errMessage, http.StatusInternalServerError)
return matched.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command_crash.error.app_error", map[string]any{"Command": trigger, "PluginId": matched.PluginId}, errMessage, http.StatusInternalServerError)
}
// This is a response from the plugin, which may set an incorrect status code;
// e.g setting a status code of 0 will crash the server. So we always bucket everything under 500.

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

@@ -30,7 +30,7 @@ func TestPluginCommand(t *testing.T) {
t.Run("command handled by plugin", func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.PluginSettings.Plugins["testloadpluginconfig"] = map[string]interface{}{
cfg.PluginSettings.Plugins["testloadpluginconfig"] = map[string]any{
"TeamId": args.TeamId,
}
})
@@ -111,7 +111,7 @@ func TestPluginCommand(t *testing.T) {
t.Run("re-entrant command registration on config change", func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.PluginSettings.Plugins["testloadpluginconfig"] = map[string]interface{}{
cfg.PluginSettings.Plugins["testloadpluginconfig"] = map[string]any{
"TeamId": args.TeamId,
}
})
@@ -162,7 +162,7 @@ func TestPluginCommand(t *testing.T) {
// Saving the plugin config eventually results in a call to
// OnConfigurationChange. This used to deadlock on account of
// effectively acquiring a RWLock reentrantly.
err := p.API.SavePluginConfig(map[string]interface{}{
err := p.API.SavePluginConfig(map[string]any{
"TeamId": p.configuration.TeamId,
})
if err != nil {
@@ -218,7 +218,7 @@ func TestPluginCommand(t *testing.T) {
t.Run("plugins can override built-in commands", func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.PluginSettings.Plugins["testloadpluginconfig"] = map[string]interface{}{
cfg.PluginSettings.Plugins["testloadpluginconfig"] = map[string]any{
"TeamId": args.TeamId,
}
})
@@ -379,7 +379,7 @@ func TestPluginCommand(t *testing.T) {
t.Run("plugin returning status code 0", func(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.PluginSettings.Plugins["testloadpluginconfig"] = map[string]interface{}{
cfg.PluginSettings.Plugins["testloadpluginconfig"] = map[string]any{
"TeamId": args.TeamId,
}
})

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

@@ -72,7 +72,7 @@ func (d *DriverImpl) ConnPing(connID string) error {
return driver.ErrBadConn
}
return conn.Raw(func(innerConn interface{}) error {
return conn.Raw(func(innerConn any) error {
return innerConn.(driver.Pinger).Ping(context.Background())
})
}
@@ -86,7 +86,7 @@ func (d *DriverImpl) ConnQuery(connID, q string, args []driver.NamedValue) (_ st
return "", driver.ErrBadConn
}
err = conn.Raw(func(innerConn interface{}) error {
err = conn.Raw(func(innerConn any) error {
rows, err = innerConn.(driver.QueryerContext).QueryContext(context.Background(), q, args)
return err
})
@@ -112,7 +112,7 @@ func (d *DriverImpl) ConnExec(connID, q string, args []driver.NamedValue) (_ plu
return ret, driver.ErrBadConn
}
err = conn.Raw(func(innerConn interface{}) error {
err = conn.Raw(func(innerConn any) error {
res, err = innerConn.(driver.ExecerContext).ExecContext(context.Background(), q, args)
return err
})
@@ -148,7 +148,7 @@ func (d *DriverImpl) Tx(connID string, opts driver.TxOptions) (_ string, err err
return "", driver.ErrBadConn
}
err = conn.Raw(func(innerConn interface{}) error {
err = conn.Raw(func(innerConn any) error {
tx, err = innerConn.(driver.ConnBeginTx).BeginTx(context.Background(), opts)
return err
})
@@ -190,7 +190,7 @@ func (d *DriverImpl) Stmt(connID, q string) (_ string, err error) {
return "", driver.ErrBadConn
}
err = conn.Raw(func(innerConn interface{}) error {
err = conn.Raw(func(innerConn any) error {
stmt, err = innerConn.(driver.Conn).Prepare(q)
return err
})

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

@@ -54,7 +54,7 @@ func TestPluginDeadlock(t *testing.T) {
UserId: "{{.User.Id}}",
ChannelId: "{{.Channel.Id}}",
Message: "message",
Props: map[string]interface{}{
Props: map[string]any{
"from_plugin": true,
},
})
@@ -129,7 +129,7 @@ func TestPluginDeadlock(t *testing.T) {
UserId: "{{.User.Id}}",
ChannelId: "{{.Channel.Id}}",
Message: "message",
Props: map[string]interface{}{
Props: map[string]any{
"from_plugin": true,
},
})
@@ -244,7 +244,7 @@ func TestPluginDeadlock(t *testing.T) {
UserId: "{{.User.Id}}",
ChannelId: "{{.Channel.Id}}",
Message: "messageUpdated",
Props: map[string]interface{}{
Props: map[string]any{
"from_plugin": true,
},
}

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

@@ -885,7 +885,7 @@ func TestErrorString(t *testing.T) {
}
func (p *MyPlugin) OnActivate() error {
return model.NewAppError("where", "id", map[string]interface{}{"param": 1}, "details", 42)
return model.NewAppError("where", "id", map[string]any{"param": 1}, "details", 42)
}
func main() {

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

@@ -320,7 +320,7 @@ func extractPlugin(pluginFile io.ReadSeeker, extractDir string) (*model.Manifest
}
if !model.IsValidPluginId(manifest.Id) {
return nil, "", model.NewAppError("installPluginLocally", "app.plugin.invalid_id.app_error", map[string]interface{}{"Min": model.MinIdLength, "Max": model.MaxIdLength, "Regex": model.ValidIdRegex}, "", http.StatusBadRequest)
return nil, "", model.NewAppError("installPluginLocally", "app.plugin.invalid_id.app_error", map[string]any{"Min": model.MinIdLength, "Max": model.MaxIdLength, "Regex": model.ValidIdRegex}, "", http.StatusBadRequest)
}
return manifest, extractDir, nil

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

@@ -44,12 +44,12 @@ func (a *App) CreatePostAsUser(c *request.Context, post *model.Post, currentSess
// Check that channel has not been deleted
channel, errCh := a.Srv().Store.Channel().Get(post.ChannelId, true)
if errCh != nil {
err := model.NewAppError("CreatePostAsUser", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "post.channel_id"}, errCh.Error(), http.StatusBadRequest)
err := model.NewAppError("CreatePostAsUser", "api.context.invalid_param.app_error", map[string]any{"Name": "post.channel_id"}, errCh.Error(), http.StatusBadRequest)
return nil, err
}
if strings.HasPrefix(post.Type, model.PostSystemMessagePrefix) {
err := model.NewAppError("CreatePostAsUser", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "post.type"}, "", http.StatusBadRequest)
err := model.NewAppError("CreatePostAsUser", "api.context.invalid_param.app_error", map[string]any{"Name": "post.type"}, "", http.StatusBadRequest)
return nil, err
}
@@ -240,7 +240,7 @@ func (a *App) CreatePost(c *request.Context, post *model.Post, channel *model.Ch
if attachments, ok := post.GetProp("attachments").([]*model.SlackAttachment); ok {
jsonAttachments, err := json.Marshal(attachments)
if err == nil {
attachmentsInterface := []interface{}{}
attachmentsInterface := []any{}
err = json.Unmarshal(jsonAttachments, &attachmentsInterface)
post.AddProp("attachments", attachmentsInterface)
}
@@ -410,13 +410,13 @@ func (a *App) attachFilesToPost(post *model.Post) *model.AppError {
// If channel is nil, FillInPostProps will look up the channel corresponding to the post.
func (a *App) FillInPostProps(post *model.Post, channel *model.Channel) *model.AppError {
channelMentions := post.ChannelMentions()
channelMentionsProp := make(map[string]interface{})
channelMentionsProp := make(map[string]any)
if len(channelMentions) > 0 {
if channel == nil {
postChannel, err := a.Srv().Store.Channel().GetForPost(post.Id)
if err != nil {
return model.NewAppError("FillInPostProps", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "post.channel_id"}, err.Error(), http.StatusBadRequest)
return model.NewAppError("FillInPostProps", "api.context.invalid_param.app_error", map[string]any{"Name": "post.channel_id"}, err.Error(), http.StatusBadRequest)
}
channel = postChannel
}
@@ -433,7 +433,7 @@ func (a *App) FillInPostProps(post *model.Post, channel *model.Channel) *model.A
mlog.Warn("Failed to get team of the channel mention", mlog.String("team_id", channel.TeamId), mlog.String("channel_id", channel.Id), mlog.Err(err))
continue
}
channelMentionsProp[mentioned.Name] = map[string]interface{}{
channelMentionsProp[mentioned.Name] = map[string]any{
"display_name": mentioned.DisplayName,
"team_name": team.Name,
}
@@ -589,7 +589,7 @@ func (a *App) UpdatePost(c *request.Context, post *model.Post, safeUpdate bool)
}
if oldPost.DeleteAt != 0 {
err = model.NewAppError("UpdatePost", "api.post.update_post.permissions_details.app_error", map[string]interface{}{"PostId": post.Id}, "", http.StatusBadRequest)
err = model.NewAppError("UpdatePost", "api.post.update_post.permissions_details.app_error", map[string]any{"PostId": post.Id}, "", http.StatusBadRequest)
return nil, err
}
@@ -599,7 +599,7 @@ func (a *App) UpdatePost(c *request.Context, post *model.Post, safeUpdate bool)
}
if *a.Config().ServiceSettings.PostEditTimeLimit != -1 && model.GetMillis() > oldPost.CreateAt+int64(*a.Config().ServiceSettings.PostEditTimeLimit*1000) && post.Message != oldPost.Message {
err = model.NewAppError("UpdatePost", "api.post.update_post.permissions_time_limit.app_error", map[string]interface{}{"timeLimit": *a.Config().ServiceSettings.PostEditTimeLimit}, "", http.StatusBadRequest)
err = model.NewAppError("UpdatePost", "api.post.update_post.permissions_time_limit.app_error", map[string]any{"timeLimit": *a.Config().ServiceSettings.PostEditTimeLimit}, "", http.StatusBadRequest)
return nil, err
}

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

@@ -433,7 +433,7 @@ func (a *App) getFirstLinkAndImages(str string) (string, []string) {
firstLink := ""
images := []string{}
markdown.Inspect(str, func(blockOrInline interface{}) bool {
markdown.Inspect(str, func(blockOrInline any) bool {
switch v := blockOrInline.(type) {
case *markdown.Autolink:
if link := v.Destination(); firstLink == "" && a.isLinkAllowedForPreview(link) {

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

@@ -213,7 +213,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: ":" + emoji.Name + ": :taco:",
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: ":" + emoji.Name + ":",
@@ -257,7 +257,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: ":" + emoji3.Name + ": :taco:",
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: ":" + emoji4.Name + ":",
@@ -490,9 +490,9 @@ func TestPreparePostForClient(t *testing.T) {
post, err := th.App.CreatePost(th.Context, &model.Post{
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Props: map[string]interface{}{
"attachments": []interface{}{
map[string]interface{}{
Props: map[string]any{
"attachments": []any{
map[string]any{
"text": "![icon](" + server.URL + "/test-image1.png)",
},
},
@@ -1300,7 +1300,7 @@ func TestGetImagesForPost(t *testing.T) {
Embeds: []*model.PostEmbed{
{
Type: model.PostEmbedOpengraph,
Data: map[string]interface{}{},
Data: map[string]any{},
},
},
},
@@ -1401,7 +1401,7 @@ func TestGetEmojiNamesForPost(t *testing.T) {
Description: "in message attachments",
Post: &model.Post{
Message: "this is a post",
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: ":emoji1:",
@@ -1429,7 +1429,7 @@ func TestGetEmojiNamesForPost(t *testing.T) {
Description: "with duplicates",
Post: &model.Post{
Message: "this is :emoji1",
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: ":emoji2:",
@@ -1486,7 +1486,7 @@ func TestGetCustomEmojisForPost(t *testing.T) {
post := &model.Post{
Message: ":" + emojis[1].Name + ":",
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Pretext: ":" + emojis[2].Name + ":",
@@ -1512,7 +1512,7 @@ func TestGetCustomEmojisForPost(t *testing.T) {
t.Run("with emojis that don't exist", func(t *testing.T) {
post := &model.Post{
Message: ":secret: :" + emojis[0].Name + ":",
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: ":imaginary:",
@@ -1529,7 +1529,7 @@ func TestGetCustomEmojisForPost(t *testing.T) {
t.Run("with no emojis", func(t *testing.T) {
post := &model.Post{
Message: "this post is boring",
Props: map[string]interface{}{},
Props: map[string]any{},
}
emojisForPost, err := th.App.getCustomEmojisForPost(post, nil)
@@ -1693,7 +1693,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "empty attachments",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{},
},
},
@@ -1702,7 +1702,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "attachment with no fields that can contain images",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Title: "This is the title",
@@ -1715,7 +1715,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "images in text",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: "![logo](https://example.com/logo) and ![icon](https://example.com/icon)",
@@ -1728,7 +1728,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "images in pretext",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Pretext: "![logo](https://example.com/logo1) and ![icon](https://example.com/icon1)",
@@ -1741,7 +1741,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "images in fields",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Fields: []*model.SlackAttachmentField{
@@ -1758,7 +1758,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "image in author_icon",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
AuthorIcon: "https://example.com/icon2",
@@ -1771,7 +1771,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "image in image_url",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
ImageURL: "https://example.com/image",
@@ -1784,7 +1784,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "image in thumb_url",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
ThumbURL: "https://example.com/image",
@@ -1797,7 +1797,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "image in footer_icon",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
FooterIcon: "https://example.com/image",
@@ -1810,7 +1810,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "images in multiple fields",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Fields: []*model.SlackAttachmentField{
@@ -1830,7 +1830,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "non-string field",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Fields: []*model.SlackAttachmentField{
@@ -1847,7 +1847,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "images in multiple locations",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: "![text](https://example.com/text)",
@@ -1869,7 +1869,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
{
Name: "multiple attachments",
Post: &model.Post{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: "![logo](https://example.com/logo)",

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

@@ -429,8 +429,8 @@ func TestPostChannelMentions(t *testing.T) {
post, err = th.App.CreatePostAsUser(th.Context, post, "", true)
require.Nil(t, err)
assert.Equal(t, map[string]interface{}{
"mention-test": map[string]interface{}{
assert.Equal(t, map[string]any{
"mention-test": map[string]any{
"display_name": "Mention Test",
"team_name": th.BasicTeam.Name,
},
@@ -439,8 +439,8 @@ func TestPostChannelMentions(t *testing.T) {
post.Message = fmt.Sprintf("goodbye, ~%v!", channelToMention.Name)
result, err := th.App.UpdatePost(th.Context, post, false)
require.Nil(t, err)
assert.Equal(t, map[string]interface{}{
"mention-test": map[string]interface{}{
assert.Equal(t, map[string]any{
"mention-test": map[string]any{
"display_name": "Mention Test",
"team_name": th.BasicTeam.Name,
},
@@ -858,7 +858,7 @@ func TestCreatePost(t *testing.T) {
Description string
Channel *model.Channel
Author string
Assert func(t assert.TestingT, object interface{}, msgAndArgs ...interface{}) bool
Assert func(t assert.TestingT, object any, msgAndArgs ...any) bool
}{
{
Description: "removes metadata from post for members who cannot read channel",
@@ -1345,7 +1345,7 @@ func TestUpdatePost(t *testing.T) {
Description string
Channel *model.Channel
Author string
Assert func(t assert.TestingT, object interface{}, msgAndArgs ...interface{}) bool
Assert func(t assert.TestingT, object any, msgAndArgs ...any) bool
}{
{
Description: "removes metadata from post for members who cannot read channel",
@@ -1879,7 +1879,7 @@ func TestCountMentionsFromPost(t *testing.T) {
ChannelId: channel.Id,
Message: "test",
Type: model.PostTypeAddToChannel,
Props: map[string]interface{}{
Props: map[string]any{
model.PostPropsAddedUserId: model.NewId(),
},
}, channel, false, true)
@@ -1889,7 +1889,7 @@ func TestCountMentionsFromPost(t *testing.T) {
ChannelId: channel.Id,
Message: "test2",
Type: model.PostTypeAddToChannel,
Props: map[string]interface{}{
Props: map[string]any{
model.PostPropsAddedUserId: user2.Id,
},
}, channel, false, true)
@@ -1899,7 +1899,7 @@ func TestCountMentionsFromPost(t *testing.T) {
ChannelId: channel.Id,
Message: "test3",
Type: model.PostTypeAddToChannel,
Props: map[string]interface{}{
Props: map[string]any{
model.PostPropsAddedUserId: user2.Id,
},
}, channel, false, true)
@@ -2089,7 +2089,7 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user2.Id,
ChannelId: channel.Id,
Message: fmt.Sprintf("@%s", user2.Username),
Props: map[string]interface{}{
Props: map[string]any{
"from_webhook": "true",
},
}, channel, false, true)

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

@@ -14,7 +14,7 @@ type Product interface {
}
type ProductManifest struct {
Initializer func(*Server, map[ServiceKey]interface{}) (Product, error)
Initializer func(*Server, map[ServiceKey]any) (Product, error)
Dependencies map[ServiceKey]struct{}
}
@@ -26,7 +26,7 @@ func RegisterProduct(name string, m ProductManifest) {
func (s *Server) initializeProducts(
productMap map[string]ProductManifest,
serviceMap map[ServiceKey]interface{},
serviceMap map[ServiceKey]any,
) error {
// create a product map to consume
pmap := make(map[string]struct{})

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

@@ -198,7 +198,7 @@ func noticeMatchesConditions(config *model.Config, preferences store.PreferenceS
return true, nil
}
func validateUserConfigEntry(preferences store.PreferenceStore, userID string, key string, expectedValue interface{}) (bool, error) {
func validateUserConfigEntry(preferences store.PreferenceStore, userID string, key string, expectedValue any) (bool, error) {
parts := strings.Split(key, ".")
if len(parts) != 2 {
return false, errors.New("Invalid format of user config. Must be in form of Category.SettingName")
@@ -213,7 +213,7 @@ func validateUserConfigEntry(preferences store.PreferenceStore, userID string, k
return pref.Value == expectedValue, nil
}
func validateConfigEntry(conf *model.Config, path string, expectedValue interface{}) bool {
func validateConfigEntry(conf *model.Config, path string, expectedValue any) bool {
value, found := config.GetValueByPath(strings.Split(path, "."), *conf)
if !found {
return false

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

@@ -114,7 +114,7 @@ func TestNoticeValidation(t *testing.T) {
args: args{
notice: &model.ProductNotice{
Conditions: model.Conditions{
ServerConfig: map[string]interface{}{"ServiceSettings.LetsEncryptCertificateCacheFile": "./config/letsencrypt.cache"},
ServerConfig: map[string]any{"ServiceSettings.LetsEncryptCertificateCacheFile": "./config/letsencrypt.cache"},
},
},
},
@@ -126,7 +126,7 @@ func TestNoticeValidation(t *testing.T) {
args: args{
notice: &model.ProductNotice{
Conditions: model.Conditions{
ServerConfig: map[string]interface{}{"ServiceSettings.ZZ": "test"},
ServerConfig: map[string]any{"ServiceSettings.ZZ": "test"},
},
},
},
@@ -138,7 +138,7 @@ func TestNoticeValidation(t *testing.T) {
args: args{
notice: &model.ProductNotice{
Conditions: model.Conditions{
UserConfig: map[string]interface{}{"Stuff": "test"},
UserConfig: map[string]any{"Stuff": "test"},
},
},
},
@@ -150,7 +150,7 @@ func TestNoticeValidation(t *testing.T) {
args: args{
notice: &model.ProductNotice{
Conditions: model.Conditions{
UserConfig: map[string]interface{}{"Stuff.Data": "test"},
UserConfig: map[string]any{"Stuff.Data": "test"},
},
},
},
@@ -162,7 +162,7 @@ func TestNoticeValidation(t *testing.T) {
args: args{
notice: &model.ProductNotice{
Conditions: model.Conditions{
UserConfig: map[string]interface{}{"Stuff.Data2": "test"},
UserConfig: map[string]any{"Stuff.Data2": "test"},
},
},
},
@@ -174,7 +174,7 @@ func TestNoticeValidation(t *testing.T) {
args: args{
notice: &model.ProductNotice{
Conditions: model.Conditions{
UserConfig: map[string]interface{}{"Stuff.Data3": "stuff"},
UserConfig: map[string]any{"Stuff.Data3": "stuff"},
},
},
},

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

@@ -16,7 +16,7 @@ const (
type productA struct{}
func newProductA(s *Server, m map[ServiceKey]interface{}) (Product, error) {
func newProductA(s *Server, m map[ServiceKey]any) (Product, error) {
m[testSrvKey1] = nil
return &productA{}, nil
}
@@ -26,7 +26,7 @@ func (p *productA) Stop() error { return nil }
type productB struct{}
func newProductB(s *Server, m map[ServiceKey]interface{}) (Product, error) {
func newProductB(s *Server, m map[ServiceKey]any) (Product, error) {
m[testSrvKey2] = nil
return &productB{}, nil
}
@@ -36,7 +36,7 @@ func (p *productB) Stop() error { return nil }
func TestInitializeProducts(t *testing.T) {
t.Run("2 products and no circular dependency", func(t *testing.T) {
serviceMap := map[ServiceKey]interface{}{
serviceMap := map[ServiceKey]any{
ConfigKey: nil,
LicenseKey: nil,
FilestoreKey: nil,
@@ -73,7 +73,7 @@ func TestInitializeProducts(t *testing.T) {
})
t.Run("2 products and circular dependency", func(t *testing.T) {
serviceMap := map[ServiceKey]interface{}{
serviceMap := map[ServiceKey]any{
ConfigKey: nil,
LicenseKey: nil,
FilestoreKey: nil,
@@ -110,7 +110,7 @@ func TestInitializeProducts(t *testing.T) {
})
t.Run("2 products and one w/o any dependency", func(t *testing.T) {
serviceMap := map[ServiceKey]interface{}{
serviceMap := map[ServiceKey]any{
ConfigKey: nil,
LicenseKey: nil,
FilestoreKey: nil,

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

@@ -45,7 +45,7 @@ func EmptyContext() *Context {
}
}
func (c *Context) T(translationID string, args ...interface{}) string {
func (c *Context) T(translationID string, args ...any) string {
return c.t(translationID, args...)
}
func (c *Context) Session() *model.Session {

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

@@ -108,7 +108,7 @@ func (a *App) AddSamlIdpCertificate(fileData *multipart.FileHeader) *model.AppEr
func (a *App) removeSamlFile(filename string) *model.AppError {
if err := a.Srv().configStore.RemoveFile(filename); err != nil {
return model.NewAppError("RemoveSamlFile", "api.admin.remove_certificate.delete.app_error", map[string]interface{}{"Filename": filename}, err.Error(), http.StatusInternalServerError)
return model.NewAppError("RemoveSamlFile", "api.admin.remove_certificate.delete.app_error", map[string]any{"Filename": filename}, err.Error(), http.StatusInternalServerError)
}
return nil

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

@@ -392,7 +392,7 @@ func NewServer(options ...Option) (*Server, error) {
return nil, errors.Wrapf(err, "unable to create teams service")
}
serviceMap := map[ServiceKey]interface{}{
serviceMap := map[ServiceKey]any{
ChannelKey: &channelsWrapper{srv: s},
ConfigKey: s.configStore,
LicenseKey: s.licenseWrapper,

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

@@ -75,7 +75,7 @@ func (s *Server) takeInactivityAction() {
mlog.Warn("No SiteURL configured")
}
properties := map[string]interface{}{
properties := map[string]any{
"SiteURL": siteURL,
}
s.GetTelemetryService().SendTelemetry("inactive_server", properties)

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

@@ -44,7 +44,7 @@ func (a *App) GetCloudSession(token string) (*model.Session, *model.AppError) {
session.AddProp(model.SessionPropType, model.SessionTypeCloudKey)
return session, nil
}
return nil, model.NewAppError("GetCloudSession", "api.context.invalid_token.error", map[string]interface{}{"Token": token, "Error": ""}, "The provided token is invalid", http.StatusUnauthorized)
return nil, model.NewAppError("GetCloudSession", "api.context.invalid_token.error", map[string]any{"Token": token, "Error": ""}, "The provided token is invalid", http.StatusUnauthorized)
}
func (a *App) GetRemoteClusterSession(token string, remoteId string) (*model.Session, *model.AppError) {
@@ -59,7 +59,7 @@ func (a *App) GetRemoteClusterSession(token string, remoteId string) (*model.Ses
session.AddProp(model.SessionPropType, model.SessionTypeRemoteclusterToken)
return session, nil
}
return nil, model.NewAppError("GetRemoteClusterSession", "api.context.invalid_token.error", map[string]interface{}{"Token": token, "Error": ""}, "The provided token is invalid", http.StatusUnauthorized)
return nil, model.NewAppError("GetRemoteClusterSession", "api.context.invalid_token.error", map[string]any{"Token": token, "Error": ""}, "The provided token is invalid", http.StatusUnauthorized)
}
func (a *App) GetSession(token string) (*model.Session, *model.AppError) {
@@ -68,7 +68,7 @@ func (a *App) GetSession(token string) (*model.Session, *model.AppError) {
// If we don't have the session we are going to create one with the token eventually.
if session, _ = a.ch.srv.userService.GetSession(token); session != nil {
if session.Token != token {
return nil, model.NewAppError("GetSession", "api.context.invalid_token.error", map[string]interface{}{"Token": token, "Error": ""}, "session token is different from the one in DB", http.StatusUnauthorized)
return nil, model.NewAppError("GetSession", "api.context.invalid_token.error", map[string]any{"Token": token, "Error": ""}, "session token is different from the one in DB", http.StatusUnauthorized)
}
if !session.IsExpired() {
@@ -88,12 +88,12 @@ func (a *App) GetSession(token string) (*model.Session, *model.AppError) {
} else {
mlog.Warn("Error while creating session for user access token", mlog.Err(appErr))
}
return nil, model.NewAppError("GetSession", "api.context.invalid_token.error", map[string]interface{}{"Token": token, "Error": detailedError}, "", statusCode)
return nil, model.NewAppError("GetSession", "api.context.invalid_token.error", map[string]any{"Token": token, "Error": detailedError}, "", statusCode)
}
}
if session.Id == "" || session.IsExpired() {
return nil, model.NewAppError("GetSession", "api.context.invalid_token.error", map[string]interface{}{"Token": token, "Error": ""}, "session is either nil or expired", http.StatusUnauthorized)
return nil, model.NewAppError("GetSession", "api.context.invalid_token.error", map[string]any{"Token": token, "Error": ""}, "session is either nil or expired", http.StatusUnauthorized)
}
if *a.Config().ServiceSettings.SessionIdleTimeoutInMinutes > 0 &&
@@ -116,7 +116,7 @@ func (a *App) GetSession(token string) (*model.Session, *model.AppError) {
mlog.Warn("Error while revoking session", mlog.Err(err))
}
})
return nil, model.NewAppError("GetSession", "api.context.invalid_token.error", map[string]interface{}{"Token": token, "Error": ""}, "idle timeout", http.StatusUnauthorized)
return nil, model.NewAppError("GetSession", "api.context.invalid_token.error", map[string]any{"Token": token, "Error": ""}, "idle timeout", http.StatusUnauthorized)
}
}

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

@@ -97,7 +97,7 @@ func (*HeaderProvider) DoCommand(a *app.App, c *request.Context, args *model.Com
if err != nil {
text := args.T("api.command_channel_header.update_channel.app_error")
if err.Id == "model.channel.is_valid.header.app_error" {
text = args.T("api.command_channel_header.update_channel.max_length", map[string]interface{}{
text = args.T("api.command_channel_header.update_channel.max_length", map[string]any{
"MaxLength": model.ChannelHeaderMaxRunes,
})
}

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

@@ -21,7 +21,7 @@ func TestHeaderProviderDoCommand(t *testing.T) {
// Try a public channel *with* permission.
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: th.BasicChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -38,7 +38,7 @@ func TestHeaderProviderDoCommand(t *testing.T) {
// Try a public channel *without* permission.
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: th.BasicChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -52,7 +52,7 @@ func TestHeaderProviderDoCommand(t *testing.T) {
privateChannel := th.createPrivateChannel(th.BasicTeam)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: privateChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -64,7 +64,7 @@ func TestHeaderProviderDoCommand(t *testing.T) {
// Try a private channel *without* permission.
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: privateChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -80,7 +80,7 @@ func TestHeaderProviderDoCommand(t *testing.T) {
groupChannel := th.createGroupChannel(user1, user2)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: groupChannel.Id,
UserId: user1.Id,
}
@@ -90,7 +90,7 @@ func TestHeaderProviderDoCommand(t *testing.T) {
// Try a group channel *without* being a member.
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: groupChannel.Id,
UserId: user3.Id,
}
@@ -102,7 +102,7 @@ func TestHeaderProviderDoCommand(t *testing.T) {
directChannel := th.createDmChannel(user1)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: directChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -112,7 +112,7 @@ func TestHeaderProviderDoCommand(t *testing.T) {
// Try a direct channel *without* being a member.
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: directChannel.Id,
UserId: user2.Id,
}

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

@@ -82,7 +82,7 @@ func (*PurposeProvider) DoCommand(a *app.App, c *request.Context, args *model.Co
if err != nil {
text := args.T("api.command_channel_purpose.update_channel.app_error")
if err.Id == "model.channel.is_valid.purpose.app_error" {
text = args.T("api.command_channel_purpose.update_channel.max_length", map[string]interface{}{
text = args.T("api.command_channel_purpose.update_channel.max_length", map[string]any{
"MaxLength": model.ChannelPurposeMaxRunes,
})
}

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

@@ -21,7 +21,7 @@ func TestPurposeProviderDoCommand(t *testing.T) {
th.addPermissionToRole(model.PermissionManagePublicChannelProperties.Id, model.ChannelUserRoleId)
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: th.BasicChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -38,7 +38,7 @@ func TestPurposeProviderDoCommand(t *testing.T) {
th.removePermissionFromRole(model.PermissionManagePublicChannelProperties.Id, model.ChannelUserRoleId)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: th.BasicChannel.Id,
}
@@ -51,7 +51,7 @@ func TestPurposeProviderDoCommand(t *testing.T) {
th.addPermissionToRole(model.PermissionManagePrivateChannelProperties.Id, model.ChannelUserRoleId)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: privateChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -63,7 +63,7 @@ func TestPurposeProviderDoCommand(t *testing.T) {
th.removePermissionFromRole(model.PermissionManagePrivateChannelProperties.Id, model.ChannelUserRoleId)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: privateChannel.Id,
}
@@ -77,7 +77,7 @@ func TestPurposeProviderDoCommand(t *testing.T) {
groupChannel := th.createGroupChannel(user1, user2)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: groupChannel.Id,
}
@@ -88,7 +88,7 @@ func TestPurposeProviderDoCommand(t *testing.T) {
directChannel := th.createDmChannel(user1)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: directChannel.Id,
}

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

@@ -73,14 +73,14 @@ func (*RenameProvider) DoCommand(a *app.App, c *request.Context, args *model.Com
}
} else if len(message) > model.ChannelNameMaxLength {
return &model.CommandResponse{
Text: args.T("api.command_channel_rename.too_long.app_error", map[string]interface{}{
Text: args.T("api.command_channel_rename.too_long.app_error", map[string]any{
"Length": model.ChannelNameMaxLength,
}),
ResponseType: model.CommandResponseTypeEphemeral,
}
} else if len(message) < model.ChannelNameMinLength {
return &model.CommandResponse{
Text: args.T("api.command_channel_rename.too_short.app_error", map[string]interface{}{
Text: args.T("api.command_channel_rename.too_short.app_error", map[string]any{
"Length": model.ChannelNameMinLength,
}),
ResponseType: model.CommandResponseTypeEphemeral,

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

@@ -20,7 +20,7 @@ func TestRenameProviderDoCommand(t *testing.T) {
rp := RenameProvider{}
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: th.BasicChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -41,7 +41,7 @@ func TestRenameProviderDoCommand(t *testing.T) {
th.removePermissionFromRole(model.PermissionManagePublicChannelProperties.Id, model.ChannelUserRoleId)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: th.BasicChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -55,7 +55,7 @@ func TestRenameProviderDoCommand(t *testing.T) {
th.addPermissionToRole(model.PermissionManagePrivateChannelProperties.Id, model.ChannelUserRoleId)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: privateChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -67,7 +67,7 @@ func TestRenameProviderDoCommand(t *testing.T) {
th.removePermissionFromRole(model.PermissionManagePrivateChannelProperties.Id, model.ChannelUserRoleId)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: privateChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -82,7 +82,7 @@ func TestRenameProviderDoCommand(t *testing.T) {
groupChannel := th.createGroupChannel(user1, user2)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: groupChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -94,7 +94,7 @@ func TestRenameProviderDoCommand(t *testing.T) {
directChannel := th.createDmChannel(user1)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: directChannel.Id,
UserId: th.BasicUser.Id,
}

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

@@ -12,7 +12,7 @@ import (
func TestCodeProviderDoCommand(t *testing.T) {
cp := CodeProvider{}
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
}
for msg, expected := range map[string]string{

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

@@ -68,7 +68,7 @@ func (*CustomStatusProvider) DoCommand(a *app.App, c *request.Context, args *mod
return &model.CommandResponse{
ResponseType: model.CommandResponseTypeEphemeral,
Text: args.T("api.command_custom_status.success", map[string]interface{}{
Text: args.T("api.command_custom_status.success", map[string]any{
"EmojiName": ":" + customStatus.Emoji + ":",
"StatusMessage": customStatus.Text,
}),

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

@@ -73,7 +73,7 @@ func (*groupmsgProvider) DoCommand(a *app.App, c *request.Context, args *model.C
}
if len(invalidUsernames) > 0 {
invalidUsersString := map[string]interface{}{
invalidUsersString := map[string]any{
"Users": "@" + strings.Join(invalidUsernames, ", @"),
}
return &model.CommandResponse{
@@ -87,7 +87,7 @@ func (*groupmsgProvider) DoCommand(a *app.App, c *request.Context, args *model.C
}
if len(targetUsersSlice) < model.ChannelGroupMinUsers {
minUsers := map[string]interface{}{
minUsers := map[string]any{
"MinUsers": model.ChannelGroupMinUsers - 1,
}
return &model.CommandResponse{
@@ -97,7 +97,7 @@ func (*groupmsgProvider) DoCommand(a *app.App, c *request.Context, args *model.C
}
if len(targetUsersSlice) > model.ChannelGroupMaxUsers {
maxUsers := map[string]interface{}{
maxUsers := map[string]any{
"MaxUsers": model.ChannelGroupMaxUsers - 1,
}
return &model.CommandResponse{

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

@@ -75,7 +75,7 @@ func (*InviteProvider) DoCommand(a *app.App, c *request.Context, args *model.Com
if channelToJoin, err = a.GetChannelByName(targetChannelName, args.TeamId, false); err != nil {
return &model.CommandResponse{
Text: args.T("api.command_invite.channel.error", map[string]interface{}{
Text: args.T("api.command_invite.channel.error", map[string]any{
"Channel": targetChannelName,
}),
ResponseType: model.CommandResponseTypeEphemeral,
@@ -96,7 +96,7 @@ func (*InviteProvider) DoCommand(a *app.App, c *request.Context, args *model.Com
case model.ChannelTypeOpen:
if !a.HasPermissionToChannel(args.UserId, channelToJoin.Id, model.PermissionManagePublicChannelMembers) {
return &model.CommandResponse{
Text: args.T("api.command_invite.permission.app_error", map[string]interface{}{
Text: args.T("api.command_invite.permission.app_error", map[string]any{
"User": userProfile.Username,
"Channel": channelToJoin.Name,
}),
@@ -108,7 +108,7 @@ func (*InviteProvider) DoCommand(a *app.App, c *request.Context, args *model.Com
if _, err = a.GetChannelMember(context.Background(), channelToJoin.Id, args.UserId); err == nil {
// User doing the inviting is a member of the channel.
return &model.CommandResponse{
Text: args.T("api.command_invite.permission.app_error", map[string]interface{}{
Text: args.T("api.command_invite.permission.app_error", map[string]any{
"User": userProfile.Username,
"Channel": channelToJoin.Name,
}),
@@ -117,7 +117,7 @@ func (*InviteProvider) DoCommand(a *app.App, c *request.Context, args *model.Com
}
// User doing the inviting is *not* a member of the channel.
return &model.CommandResponse{
Text: args.T("api.command_invite.private_channel.app_error", map[string]interface{}{
Text: args.T("api.command_invite.private_channel.app_error", map[string]any{
"Channel": channelToJoin.Name,
}),
ResponseType: model.CommandResponseTypeEphemeral,
@@ -134,7 +134,7 @@ func (*InviteProvider) DoCommand(a *app.App, c *request.Context, args *model.Com
_, err = a.GetChannelMember(context.Background(), channelToJoin.Id, userProfile.Id)
if err == nil {
return &model.CommandResponse{
Text: args.T("api.command_invite.user_already_in_channel.app_error", map[string]interface{}{
Text: args.T("api.command_invite.user_already_in_channel.app_error", map[string]any{
"User": userProfile.Username,
}),
ResponseType: model.CommandResponseTypeEphemeral,
@@ -149,7 +149,7 @@ func (*InviteProvider) DoCommand(a *app.App, c *request.Context, args *model.Com
text = args.T("api.command_invite.group_constrained_user_denied")
} else if err.Id == "app.team.get_member.missing.app_error" ||
err.Id == "api.channel.add_user.to.channel.failed.deleted.app_error" {
text = args.T("api.command_invite.user_not_in_team.app_error", map[string]interface{}{
text = args.T("api.command_invite.user_not_in_team.app_error", map[string]any{
"Username": userProfile.Username,
})
} else {
@@ -163,7 +163,7 @@ func (*InviteProvider) DoCommand(a *app.App, c *request.Context, args *model.Com
if args.ChannelId != channelToJoin.Id {
return &model.CommandResponse{
Text: args.T("api.command_invite.success", map[string]interface{}{
Text: args.T("api.command_invite.success", map[string]any{
"User": userProfile.Username,
"Channel": channelToJoin.Name,
}),

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

@@ -26,7 +26,7 @@ func TestInvitePeopleProvider(t *testing.T) {
// Test without required permissions
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: th.BasicChannel.Id,
TeamId: th.BasicTeam.Id,
UserId: notTeamUser.Id,

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

@@ -58,7 +58,7 @@ func TestInviteProvider(t *testing.T) {
InviteP := InviteProvider{}
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: th.BasicChannel.Id,
TeamId: th.BasicTeam.Id,
UserId: th.BasicUser.Id,
@@ -195,7 +195,7 @@ func TestInviteGroup(t *testing.T) {
InviteP := InviteProvider{}
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: th.BasicChannel.Id,
TeamId: th.BasicTeam.Id,
UserId: th.BasicUser.Id,

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

@@ -49,7 +49,7 @@ func (*LeaveProvider) DoCommand(a *app.App, c *request.Context, args *model.Comm
err = a.LeaveChannel(c, args.ChannelId, args.UserId)
if err != nil {
if channel.Name == model.DefaultChannelName {
return &model.CommandResponse{Text: args.T("api.channel.leave.default.app_error", map[string]interface{}{"Channel": model.DefaultChannelName}), ResponseType: model.CommandResponseTypeEphemeral}
return &model.CommandResponse{Text: args.T("api.channel.leave.default.app_error", map[string]any{"Channel": model.DefaultChannelName}), ResponseType: model.CommandResponseTypeEphemeral}
}
return &model.CommandResponse{Text: args.T("api.command_leave.fail.app_error"), ResponseType: model.CommandResponseTypeEphemeral}
}

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

@@ -50,7 +50,7 @@ func TestLeaveProviderDoCommand(t *testing.T) {
t.Run("Should error when no Channel ID in args", func(t *testing.T) {
args := &model.CommandArgs{
UserId: th.BasicUser.Id,
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
}
actual := lp.DoCommand(th.App, th.Context, args, "")
assert.Equal(t, "api.command_leave.fail.app_error", actual.Text)
@@ -61,7 +61,7 @@ func TestLeaveProviderDoCommand(t *testing.T) {
args := &model.CommandArgs{
UserId: th.BasicUser.Id,
ChannelId: publicChannel.Id,
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
}
actual := lp.DoCommand(th.App, th.Context, args, "")
assert.Equal(t, "api.command_leave.fail.app_error", actual.Text)
@@ -72,7 +72,7 @@ func TestLeaveProviderDoCommand(t *testing.T) {
args := &model.CommandArgs{
UserId: th.BasicUser.Id,
ChannelId: publicChannel.Id,
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
TeamId: th.BasicTeam.Id,
SiteURL: "http://localhost:8065",
}
@@ -90,7 +90,7 @@ func TestLeaveProviderDoCommand(t *testing.T) {
args := &model.CommandArgs{
UserId: th.BasicUser.Id,
ChannelId: privateChannel.Id,
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
TeamId: th.BasicTeam.Id,
SiteURL: "http://localhost:8065",
}
@@ -102,7 +102,7 @@ func TestLeaveProviderDoCommand(t *testing.T) {
args := &model.CommandArgs{
UserId: th.BasicUser.Id,
ChannelId: defaultChannel.Id,
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
TeamId: th.BasicTeam.Id,
SiteURL: "http://localhost:8065",
}
@@ -114,7 +114,7 @@ func TestLeaveProviderDoCommand(t *testing.T) {
args := &model.CommandArgs{
UserId: guest.Id,
ChannelId: defaultChannel.Id,
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
TeamId: th.BasicTeam.Id,
SiteURL: "http://localhost:8065",
}
@@ -132,7 +132,7 @@ func TestLeaveProviderDoCommand(t *testing.T) {
args := &model.CommandArgs{
UserId: guest.Id,
ChannelId: publicChannel.Id,
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
TeamId: th.BasicTeam.Id,
SiteURL: "http://localhost:8065",
}

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

@@ -58,13 +58,13 @@ func (*MuteProvider) DoCommand(a *app.App, c *request.Context, args *model.Comma
channel, _ = a.Srv().Store.Channel().GetByName(channel.TeamId, channelName, true)
if channel == nil {
return &model.CommandResponse{Text: args.T("api.command_mute.error", map[string]interface{}{"Channel": channelName}), ResponseType: model.CommandResponseTypeEphemeral}
return &model.CommandResponse{Text: args.T("api.command_mute.error", map[string]any{"Channel": channelName}), ResponseType: model.CommandResponseTypeEphemeral}
}
}
channelMember, err := a.ToggleMuteChannel(channel.Id, args.UserId)
if err != nil {
return &model.CommandResponse{Text: args.T("api.command_mute.not_member.error", map[string]interface{}{"Channel": channelName}), ResponseType: model.CommandResponseTypeEphemeral}
return &model.CommandResponse{Text: args.T("api.command_mute.not_member.error", map[string]any{"Channel": channelName}), ResponseType: model.CommandResponseTypeEphemeral}
}
// Direct and Group messages won't have a nice channel title, omit it
@@ -76,7 +76,7 @@ func (*MuteProvider) DoCommand(a *app.App, c *request.Context, args *model.Comma
}
if channelMember.NotifyProps[model.MarkUnreadNotifyProp] == model.ChannelNotifyMention {
return &model.CommandResponse{Text: args.T("api.command_mute.success_mute", map[string]interface{}{"Channel": channel.DisplayName}), ResponseType: model.CommandResponseTypeEphemeral}
return &model.CommandResponse{Text: args.T("api.command_mute.success_mute", map[string]any{"Channel": channel.DisplayName}), ResponseType: model.CommandResponseTypeEphemeral}
}
return &model.CommandResponse{Text: args.T("api.command_mute.success_unmute", map[string]interface{}{"Channel": channel.DisplayName}), ResponseType: model.CommandResponseTypeEphemeral}
return &model.CommandResponse{Text: args.T("api.command_mute.success_unmute", map[string]any{"Channel": channel.DisplayName}), ResponseType: model.CommandResponseTypeEphemeral}
}

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

@@ -36,7 +36,7 @@ func (rp *RemoteProvider) GetTrigger() string {
func (rp *RemoteProvider) GetCommand(a *app.App, T i18n.TranslateFunc) *model.Command {
remote := model.NewAutocompleteData(rp.GetTrigger(), "[action]", T("api.command_remote.remote_add_remove.help", map[string]interface{}{"Actions": AvailableRemoteActions}))
remote := model.NewAutocompleteData(rp.GetTrigger(), "[action]", T("api.command_remote.remote_add_remove.help", map[string]any{"Actions": AvailableRemoteActions}))
create := model.NewAutocompleteData("create", "", T("api.command_remote.invite.help"))
create.AddNamedTextArgument("name", T("api.command_remote.name.help"), T("api.command_remote.name.hint"), "", true)
@@ -71,13 +71,13 @@ func (rp *RemoteProvider) GetCommand(a *app.App, T i18n.TranslateFunc) *model.Co
func (rp *RemoteProvider) DoCommand(a *app.App, c *request.Context, args *model.CommandArgs, message string) *model.CommandResponse {
if !a.HasPermissionTo(args.UserId, model.PermissionManageSecureConnections) {
return responsef(args.T("api.command_remote.permission_required", map[string]interface{}{"Permission": "manage_secure_connections"}))
return responsef(args.T("api.command_remote.permission_required", map[string]any{"Permission": "manage_secure_connections"}))
}
margs := parseNamedArgs(args.Command)
action, ok := margs[ActionKey]
if !ok {
return responsef(args.T("api.command_remote.missing_command", map[string]interface{}{"Actions": AvailableRemoteActions}))
return responsef(args.T("api.command_remote.missing_command", map[string]any{"Actions": AvailableRemoteActions}))
}
switch action {
@@ -91,7 +91,7 @@ func (rp *RemoteProvider) DoCommand(a *app.App, c *request.Context, args *model.
return rp.doStatus(a, args, margs)
}
return responsef(args.T("api.command_remote.unknown_action", map[string]interface{}{"Action": action}))
return responsef(args.T("api.command_remote.unknown_action", map[string]any{"Action": action}))
}
func (rp *RemoteProvider) GetAutoCompleteListItems(a *app.App, commandArgs *model.CommandArgs, arg *model.AutocompleteArg, parsed, toBeParsed string) ([]model.AutocompleteListItem, error) {
@@ -110,12 +110,12 @@ func (rp *RemoteProvider) GetAutoCompleteListItems(a *app.App, commandArgs *mode
func (rp *RemoteProvider) doCreate(a *app.App, args *model.CommandArgs, margs map[string]string) *model.CommandResponse {
password := margs["password"]
if password == "" {
return responsef(args.T("api.command_remote.missing_empty", map[string]interface{}{"Arg": "password"}))
return responsef(args.T("api.command_remote.missing_empty", map[string]any{"Arg": "password"}))
}
name := margs["name"]
if name == "" {
return responsef(args.T("api.command_remote.missing_empty", map[string]interface{}{"Arg": "name"}))
return responsef(args.T("api.command_remote.missing_empty", map[string]any{"Arg": "name"}))
}
displayname := margs["displayname"]
@@ -137,7 +137,7 @@ func (rp *RemoteProvider) doCreate(a *app.App, args *model.CommandArgs, margs ma
rcSaved, appErr := a.AddRemoteCluster(rc)
if appErr != nil {
return responsef(args.T("api.command_remote.add_remote.error", map[string]interface{}{"Error": appErr.Error()}))
return responsef(args.T("api.command_remote.add_remote.error", map[string]any{"Error": appErr.Error()}))
}
// Display the encrypted invitation
@@ -149,24 +149,24 @@ func (rp *RemoteProvider) doCreate(a *app.App, args *model.CommandArgs, margs ma
}
encrypted, err := invite.Encrypt(password)
if err != nil {
return responsef(args.T("api.command_remote.encrypt_invitation.error", map[string]interface{}{"Error": err.Error()}))
return responsef(args.T("api.command_remote.encrypt_invitation.error", map[string]any{"Error": err.Error()}))
}
encoded := base64.URLEncoding.EncodeToString(encrypted)
return responsef("##### " + args.T("api.command_remote.invitation_created") + "\n" +
args.T("api.command_remote.invite_summary", map[string]interface{}{"Command": "/secure-connection accept", "Invitation": encoded, "SiteURL": invite.SiteURL}))
args.T("api.command_remote.invite_summary", map[string]any{"Command": "/secure-connection accept", "Invitation": encoded, "SiteURL": invite.SiteURL}))
}
// doAccept accepts an invitation generated by a remote site.
func (rp *RemoteProvider) doAccept(a *app.App, args *model.CommandArgs, margs map[string]string) *model.CommandResponse {
password := margs["password"]
if password == "" {
return responsef(args.T("api.command_remote.missing_empty", map[string]interface{}{"Arg": "password"}))
return responsef(args.T("api.command_remote.missing_empty", map[string]any{"Arg": "password"}))
}
name := margs["name"]
if name == "" {
return responsef(args.T("api.command_remote.missing_empty", map[string]interface{}{"Arg": "name"}))
return responsef(args.T("api.command_remote.missing_empty", map[string]any{"Arg": "name"}))
}
displayname := margs["displayname"]
@@ -176,18 +176,18 @@ func (rp *RemoteProvider) doAccept(a *app.App, args *model.CommandArgs, margs ma
blob := margs["invite"]
if blob == "" {
return responsef(args.T("api.command_remote.missing_empty", map[string]interface{}{"Arg": "invite"}))
return responsef(args.T("api.command_remote.missing_empty", map[string]any{"Arg": "invite"}))
}
// invite is encoded as base64 and encrypted
decoded, err := base64.URLEncoding.DecodeString(blob)
if err != nil {
return responsef(args.T("api.command_remote.decode_invitation.error", map[string]interface{}{"Error": err.Error()}))
return responsef(args.T("api.command_remote.decode_invitation.error", map[string]any{"Error": err.Error()}))
}
invite := &model.RemoteClusterInvite{}
err = invite.Decrypt(decoded, password)
if err != nil {
return responsef(args.T("api.command_remote.incorrect_password.error", map[string]interface{}{"Error": err.Error()}))
return responsef(args.T("api.command_remote.incorrect_password.error", map[string]any{"Error": err.Error()}))
}
rcs, _ := a.GetRemoteClusterService()
@@ -202,36 +202,36 @@ func (rp *RemoteProvider) doAccept(a *app.App, args *model.CommandArgs, margs ma
rc, err := rcs.AcceptInvitation(invite, name, displayname, args.UserId, args.TeamId, url)
if err != nil {
return responsef(args.T("api.command_remote.accept_invitation.error", map[string]interface{}{"Error": err.Error()}))
return responsef(args.T("api.command_remote.accept_invitation.error", map[string]any{"Error": err.Error()}))
}
return responsef("##### " + args.T("api.command_remote.accept_invitation", map[string]interface{}{"SiteURL": rc.SiteURL}))
return responsef("##### " + args.T("api.command_remote.accept_invitation", map[string]any{"SiteURL": rc.SiteURL}))
}
// doRemove removes a remote cluster from the database, effectively revoking the trust relationship.
func (rp *RemoteProvider) doRemove(a *app.App, args *model.CommandArgs, margs map[string]string) *model.CommandResponse {
id, ok := margs["connectionID"]
if !ok {
return responsef(args.T("api.command_remote.missing_empty", map[string]interface{}{"Arg": "remoteId"}))
return responsef(args.T("api.command_remote.missing_empty", map[string]any{"Arg": "remoteId"}))
}
deleted, err := a.DeleteRemoteCluster(id)
if err != nil {
responsef(args.T("api.command_remote.remove_remote.error", map[string]interface{}{"Error": err.Error()}))
responsef(args.T("api.command_remote.remove_remote.error", map[string]any{"Error": err.Error()}))
}
result := "removed"
if !deleted {
result = "**NOT FOUND**"
}
return responsef("##### " + args.T("api.command_remote.cluster_removed", map[string]interface{}{"RemoteId": id, "Result": result}))
return responsef("##### " + args.T("api.command_remote.cluster_removed", map[string]any{"RemoteId": id, "Result": result}))
}
// doStatus displays connection status for all remote clusters.
func (rp *RemoteProvider) doStatus(a *app.App, args *model.CommandArgs, _ map[string]string) *model.CommandResponse {
list, err := a.GetAllRemoteClusters(model.RemoteClusterQueryFilter{})
if err != nil {
responsef(args.T("api.command_remote.fetch_status.error", map[string]interface{}{"Error": err.Error()}))
responsef(args.T("api.command_remote.fetch_status.error", map[string]any{"Error": err.Error()}))
}
if len(list) == 0 {

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

@@ -128,7 +128,7 @@ func doCommand(a *app.App, c *request.Context, args *model.CommandArgs, message
if err != nil {
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
return &model.CommandResponse{
Text: args.T("api.command_remove.user_not_in_channel", map[string]interface{}{
Text: args.T("api.command_remove.user_not_in_channel", map[string]any{
"Username": userProfile.GetDisplayName(nameFormat),
}),
ResponseType: model.CommandResponseTypeEphemeral,
@@ -140,7 +140,7 @@ func doCommand(a *app.App, c *request.Context, args *model.CommandArgs, message
if err.Id == "api.channel.remove_members.denied" {
text = args.T("api.command_remove.group_constrained_user_denied")
} else {
text = args.T(err.Id, map[string]interface{}{
text = args.T(err.Id, map[string]any{
"Channel": model.DefaultChannelName,
})
}

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

@@ -40,7 +40,7 @@ func TestRemoveProviderDoCommand(t *testing.T) {
// Try a public channel *without* permission.
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: publicChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -51,7 +51,7 @@ func TestRemoveProviderDoCommand(t *testing.T) {
// Try a public channel *with* permission.
th.App.AddUserToChannel(th.BasicUser, publicChannel, false)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: publicChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -61,7 +61,7 @@ func TestRemoveProviderDoCommand(t *testing.T) {
// Try a private channel *without* permission.
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: privateChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -72,7 +72,7 @@ func TestRemoveProviderDoCommand(t *testing.T) {
// Try a private channel *with* permission.
th.App.AddUserToChannel(th.BasicUser, privateChannel, false)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: privateChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -87,7 +87,7 @@ func TestRemoveProviderDoCommand(t *testing.T) {
groupChannel := th.createGroupChannel(user1, user2)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: groupChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -99,7 +99,7 @@ func TestRemoveProviderDoCommand(t *testing.T) {
directChannel := th.createDmChannel(user1)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: directChannel.Id,
UserId: th.BasicUser.Id,
}
@@ -114,7 +114,7 @@ func TestRemoveProviderDoCommand(t *testing.T) {
th.App.UpdateActive(th.Context, deactivatedUser, false)
args = &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: publicChannel.Id,
UserId: th.BasicUser.Id,
}

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

@@ -31,7 +31,7 @@ func (sp *ShareProvider) GetTrigger() string {
}
func (sp *ShareProvider) GetCommand(a *app.App, T i18n.TranslateFunc) *model.Command {
share := model.NewAutocompleteData(CommandTriggerShare, "[action]", T("api.command_share.available_actions", map[string]interface{}{"Actions": AvailableShareActions}))
share := model.NewAutocompleteData(CommandTriggerShare, "[action]", T("api.command_share.available_actions", map[string]any{"Actions": AvailableShareActions}))
inviteRemote := model.NewAutocompleteData("invite", "", T("api.command_share.invite_remote.help"))
inviteRemote.AddNamedDynamicListArgument("connectionID", T("api.command_share.remote_id.help"), "builtin:"+CommandTriggerShare, true)
@@ -122,7 +122,7 @@ func (sp *ShareProvider) getAutoCompleteUnInviteRemote(a *app.App, _ *model.Comm
func (sp *ShareProvider) DoCommand(a *app.App, c *request.Context, args *model.CommandArgs, message string) *model.CommandResponse {
if !a.HasPermissionTo(args.UserId, model.PermissionManageSharedChannels) {
return responsef(args.T("api.command_share.permission_required", map[string]interface{}{"Permission": "manage_shared_channels"}))
return responsef(args.T("api.command_share.permission_required", map[string]any{"Permission": "manage_shared_channels"}))
}
if a.Srv().GetSharedChannelSyncService() == nil {
@@ -136,7 +136,7 @@ func (sp *ShareProvider) DoCommand(a *app.App, c *request.Context, args *model.C
margs := parseNamedArgs(args.Command)
action, ok := margs[ActionKey]
if !ok {
return responsef(args.T("api.command_share.missing_action", map[string]interface{}{"Actions": AvailableShareActions}))
return responsef(args.T("api.command_share.missing_action", map[string]any{"Actions": AvailableShareActions}))
}
switch action {
@@ -151,14 +151,14 @@ func (sp *ShareProvider) DoCommand(a *app.App, c *request.Context, args *model.C
case "status":
return sp.doStatus(a, args, margs)
}
return responsef(args.T("api.command_share.unknown_action", map[string]interface{}{"Action": action, "Actions": AvailableShareActions}))
return responsef(args.T("api.command_share.unknown_action", map[string]any{"Action": action, "Actions": AvailableShareActions}))
}
func (sp *ShareProvider) doShareChannel(a *app.App, args *model.CommandArgs, margs map[string]string) *model.CommandResponse {
// check that channel exists.
channel, errApp := a.GetChannel(args.ChannelId)
if errApp != nil {
return responsef(args.T("api.command_share.share_channel.error", map[string]interface{}{"Error": errApp.Error()}))
return responsef(args.T("api.command_share.share_channel.error", map[string]any{"Error": errApp.Error()}))
}
if name := margs["name"]; name == "" {
@@ -179,7 +179,7 @@ func (sp *ShareProvider) doShareChannel(a *app.App, args *model.CommandArgs, mar
readonly, err := parseBool(margs["readonly"])
if err != nil {
return responsef(args.T("api.command_share.invalid_value.error", map[string]interface{}{"Arg": "readonly", "Error": err.Error()}))
return responsef(args.T("api.command_share.invalid_value.error", map[string]any{"Arg": "readonly", "Error": err.Error()}))
}
sc := &model.SharedChannel{
@@ -195,7 +195,7 @@ func (sp *ShareProvider) doShareChannel(a *app.App, args *model.CommandArgs, mar
}
if _, err := a.SaveSharedChannel(sc); err != nil {
return responsef(args.T("api.command_share.share_channel.error", map[string]interface{}{"Error": err.Error()}))
return responsef(args.T("api.command_share.share_channel.error", map[string]any{"Error": err.Error()}))
}
notifyClientsForChannelUpdate(a, sc)
@@ -206,12 +206,12 @@ func (sp *ShareProvider) doShareChannel(a *app.App, args *model.CommandArgs, mar
func (sp *ShareProvider) doUnshareChannel(a *app.App, args *model.CommandArgs, margs map[string]string) *model.CommandResponse {
sc, appErr := a.GetSharedChannel(args.ChannelId)
if appErr != nil {
return responsef(args.T("api.command_share.shared_channel_unshare.error", map[string]interface{}{"Error": appErr.Error()}))
return responsef(args.T("api.command_share.shared_channel_unshare.error", map[string]any{"Error": appErr.Error()}))
}
deleted, err := a.DeleteSharedChannel(args.ChannelId)
if err != nil {
return responsef(args.T("api.command_share.shared_channel_unshare.error", map[string]interface{}{"Error": err.Error()}))
return responsef(args.T("api.command_share.shared_channel_unshare.error", map[string]any{"Error": err.Error()}))
}
if !deleted {
return responsef(args.T("api.command_share.not_shared_channel_unshare"))
@@ -230,7 +230,7 @@ func (sp *ShareProvider) doInviteRemote(a *app.App, args *model.CommandArgs, mar
hasRemote, err := a.HasRemote(args.ChannelId, remoteId)
if err != nil {
return responsef(args.T("api.command_share.fetch_remote.error", map[string]interface{}{"Error": err.Error()}))
return responsef(args.T("api.command_share.fetch_remote.error", map[string]any{"Error": err.Error()}))
}
if hasRemote {
return responsef(args.T("api.command_share.remote_already_invited"))
@@ -239,7 +239,7 @@ func (sp *ShareProvider) doInviteRemote(a *app.App, args *model.CommandArgs, mar
// Check if channel is shared or not.
hasChan, err := a.HasSharedChannel(args.ChannelId)
if err != nil {
return responsef(args.T("api.command_share.check_channel_exist.error", map[string]interface{}{"Error": err.Error()}))
return responsef(args.T("api.command_share.check_channel_exist.error", map[string]any{"Error": err.Error()}))
}
if !hasChan {
// If it doesn't exist, then create it.
@@ -259,19 +259,19 @@ func (sp *ShareProvider) doInviteRemote(a *app.App, args *model.CommandArgs, mar
rc, appErr := a.GetRemoteCluster(remoteId)
if appErr != nil {
return responsef(args.T("api.command_share.remote_id_invalid.error", map[string]interface{}{"Error": appErr.Error()}))
return responsef(args.T("api.command_share.remote_id_invalid.error", map[string]any{"Error": appErr.Error()}))
}
channel, errApp := a.GetChannel(args.ChannelId)
if errApp != nil {
return responsef(args.T("api.command_share.channel_invite.error", map[string]interface{}{"Name": rc.DisplayName, "Error": errApp.Error()}))
return responsef(args.T("api.command_share.channel_invite.error", map[string]any{"Name": rc.DisplayName, "Error": errApp.Error()}))
}
// send channel invite to remote cluster
if err := a.Srv().GetSharedChannelSyncService().SendChannelInvite(channel, args.UserId, rc); err != nil {
return responsef(args.T("api.command_share.channel_invite.error", map[string]interface{}{"Name": rc.DisplayName, "Error": err.Error()}))
return responsef(args.T("api.command_share.channel_invite.error", map[string]any{"Name": rc.DisplayName, "Error": err.Error()}))
}
return responsef("##### " + args.T("api.command_share.invitation_sent", map[string]interface{}{"Name": rc.DisplayName, "SiteURL": rc.SiteURL}))
return responsef("##### " + args.T("api.command_share.invitation_sent", map[string]any{"Name": rc.DisplayName, "SiteURL": rc.SiteURL}))
}
func (sp *ShareProvider) doUninviteRemote(a *app.App, args *model.CommandArgs, margs map[string]string) *model.CommandResponse {
@@ -282,20 +282,20 @@ func (sp *ShareProvider) doUninviteRemote(a *app.App, args *model.CommandArgs, m
scr, err := a.GetSharedChannelRemoteByIds(args.ChannelId, remoteId)
if err != nil || scr.ChannelId != args.ChannelId {
return responsef(args.T("api.command_share.channel_remote_id_not_exists", map[string]interface{}{"RemoteId": remoteId}))
return responsef(args.T("api.command_share.channel_remote_id_not_exists", map[string]any{"RemoteId": remoteId}))
}
deleted, err := a.DeleteSharedChannelRemote(scr.Id)
if err != nil || !deleted {
return responsef(args.T("api.command_share.could_not_uninvite.error", map[string]interface{}{"RemoteId": remoteId, "Error": err.Error()}))
return responsef(args.T("api.command_share.could_not_uninvite.error", map[string]any{"RemoteId": remoteId, "Error": err.Error()}))
}
return responsef("##### " + args.T("api.command_share.remote_uninvited", map[string]interface{}{"RemoteId": remoteId}))
return responsef("##### " + args.T("api.command_share.remote_uninvited", map[string]any{"RemoteId": remoteId}))
}
func (sp *ShareProvider) doStatus(a *app.App, args *model.CommandArgs, _ map[string]string) *model.CommandResponse {
statuses, err := a.GetSharedChannelRemotesStatus(args.ChannelId)
if err != nil {
return responsef(args.T("api.command_share.fetch_remote_status.error", map[string]interface{}{"Error": err.Error()}))
return responsef(args.T("api.command_share.fetch_remote_status.error", map[string]any{"Error": err.Error()}))
}
if len(statuses) == 0 {
return responsef(args.T("api.command_share.no_remote_invited"))
@@ -303,7 +303,7 @@ func (sp *ShareProvider) doStatus(a *app.App, args *model.CommandArgs, _ map[str
var sb strings.Builder
fmt.Fprintf(&sb, args.T("api.command_share.channel_status_id", map[string]interface{}{"ChannelId": statuses[0].ChannelId})+"\n\n")
fmt.Fprintf(&sb, args.T("api.command_share.channel_status_id", map[string]any{"ChannelId": statuses[0].ChannelId})+"\n\n")
fmt.Fprintf(&sb, args.T("api.command_share.remote_table_header")+" \n")
// "| Secure Connection | SiteURL | ReadOnly | InviteAccepted | Online | Last Sync |"

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

@@ -39,7 +39,7 @@ func TestShareProviderDoCommand(t *testing.T) {
channel := th.CreateChannel(th.BasicTeam, WithShared(false))
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: channel.Id,
UserId: th.BasicUser.Id,
TeamId: th.BasicTeam.Id,
@@ -74,7 +74,7 @@ func TestShareProviderDoCommand(t *testing.T) {
commandProvider := ShareProvider{}
channel := th.CreateChannel(th.BasicTeam, WithShared(true))
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
ChannelId: channel.Id,
UserId: th.BasicUser.Id,
TeamId: th.BasicTeam.Id,

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

@@ -106,7 +106,7 @@ func TestExecuteCommand(t *testing.T) {
TeamId: th.BasicTeam.Id,
ChannelId: th.BasicChannel.Id,
UserId: th.BasicUser.Id,
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
}
resp, err := th.App.ExecuteCommand(th.Context, args)
require.Nil(t, err)
@@ -119,7 +119,7 @@ func TestExecuteCommand(t *testing.T) {
t.Run("missing slash character", func(t *testing.T) {
argsMissingSlashCharacter := &model.CommandArgs{
Command: "missing leading slash character",
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
}
_, err := th.App.ExecuteCommand(th.Context, argsMissingSlashCharacter)
require.Equal(t, "api.command.execute_command.format.app_error", err.Id)
@@ -128,7 +128,7 @@ func TestExecuteCommand(t *testing.T) {
t.Run("empty", func(t *testing.T) {
argsMissingSlashCharacter := &model.CommandArgs{
Command: "",
T: func(s string, args ...interface{}) string { return s },
T: func(s string, args ...any) string { return s },
}
_, err := th.App.ExecuteCommand(th.Context, argsMissingSlashCharacter)
require.Equal(t, "api.command.execute_command.format.app_error", err.Id)

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

@@ -17,7 +17,7 @@ const (
)
// responsef creates an ephemeral command response using printf syntax.
func responsef(format string, args ...interface{}) *model.CommandResponse {
func responsef(format string, args ...any) *model.CommandResponse {
return &model.CommandResponse{
ResponseType: model.CommandResponseTypeEphemeral,
Text: fmt.Sprintf(format, args...),

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

@@ -51,12 +51,12 @@ func (a *App) GetAllStatuses() map[string]*model.Status {
return statusMap
}
func (a *App) GetStatusesByIds(userIDs []string) (map[string]interface{}, *model.AppError) {
func (a *App) GetStatusesByIds(userIDs []string) (map[string]any, *model.AppError) {
if !*a.Config().ServiceSettings.EnableUserStatuses {
return map[string]interface{}{}, nil
return map[string]any{}, nil
}
statusMap := map[string]interface{}{}
statusMap := map[string]any{}
metrics := a.Metrics()
missingUserIds := []string{}

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

@@ -227,7 +227,7 @@ func (a *App) SyncSyncableRoles(syncableID string, syncableType model.GroupSynca
}
return nil
default:
return model.NewAppError("App.SyncSyncableRoles", "groups.unsupported_syncable_type", map[string]interface{}{"Value": syncableType}, "", http.StatusInternalServerError)
return model.NewAppError("App.SyncSyncableRoles", "groups.unsupported_syncable_type", map[string]any{"Value": syncableType}, "", http.StatusInternalServerError)
}
}

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

@@ -220,7 +220,7 @@ func (a *App) UpdateTeam(team *model.Team) (*model.Team, *model.AppError) {
case errors.As(err, &appErr):
return nil, appErr
case errors.As(err, &domErr):
return nil, model.NewAppError("UpdateTeam", "api.team.update_restricted_domains.mismatch.app_error", map[string]interface{}{"Domain": domErr.Domain}, "", http.StatusBadRequest)
return nil, model.NewAppError("UpdateTeam", "api.team.update_restricted_domains.mismatch.app_error", map[string]any{"Domain": domErr.Domain}, "", http.StatusBadRequest)
default:
return nil, model.NewAppError("UpdateTeam", "app.team.update.updating.app_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -265,7 +265,7 @@ func (a *App) RenameTeam(team *model.Team, newTeamName string, newDisplayName st
case errors.As(err, &appErr):
return nil, appErr
case errors.As(err, &domErr):
return nil, model.NewAppError("RenameTeam", "api.team.update_restricted_domains.mismatch.app_error", map[string]interface{}{"Domain": domErr.Domain}, "", http.StatusBadRequest)
return nil, model.NewAppError("RenameTeam", "api.team.update_restricted_domains.mismatch.app_error", map[string]any{"Domain": domErr.Domain}, "", http.StatusBadRequest)
default:
return nil, model.NewAppError("RenameTeam", "app.team.update.updating.app_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -351,7 +351,7 @@ func (a *App) PatchTeam(teamID string, patch *model.TeamPatch) (*model.Team, *mo
case errors.As(err, &appErr):
return nil, appErr
case errors.As(err, &domErr):
return nil, model.NewAppError("PatchTeam", "api.team.update_restricted_domains.mismatch.app_error", map[string]interface{}{"Domain": domErr.Domain}, "", http.StatusBadRequest)
return nil, model.NewAppError("PatchTeam", "api.team.update_restricted_domains.mismatch.app_error", map[string]any{"Domain": domErr.Domain}, "", http.StatusBadRequest)
default:
return nil, model.NewAppError("PatchTeam", "app.team.update.updating.app_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -1419,7 +1419,7 @@ func (a *App) InviteNewUsersToTeamGracefully(memberInvite *model.MemberInvite, t
Error: nil,
}
if !teams.IsEmailAddressAllowed(email, allowedDomains) {
invite.Error = model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.invalid_email.app_error", map[string]interface{}{"Addresses": email}, "", http.StatusBadRequest)
invite.Error = model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.invalid_email.app_error", map[string]any{"Addresses": email}, "", http.StatusBadRequest)
} else {
goodEmails = append(goodEmails, email)
}
@@ -1550,7 +1550,7 @@ func (a *App) InviteGuestsToChannelsGracefully(teamID string, guestsInvite *mode
Error: nil,
}
if !users.CheckEmailDomain(email, *a.Config().GuestAccountsSettings.RestrictCreationToDomains) {
invite.Error = model.NewAppError("InviteGuestsToChannelsGracefully", "api.team.invite_members.invalid_email.app_error", map[string]interface{}{"Addresses": email}, "", http.StatusBadRequest)
invite.Error = model.NewAppError("InviteGuestsToChannelsGracefully", "api.team.invite_members.invalid_email.app_error", map[string]any{"Addresses": email}, "", http.StatusBadRequest)
} else {
goodEmails = append(goodEmails, email)
}
@@ -1616,7 +1616,7 @@ func (a *App) InviteNewUsersToTeam(emailList []string, teamID, senderId string)
if len(invalidEmailList) > 0 {
s := strings.Join(invalidEmailList, ", ")
return model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.invalid_email.app_error", map[string]interface{}{"Addresses": s}, "", http.StatusBadRequest)
return model.NewAppError("InviteNewUsersToTeam", "api.team.invite_members.invalid_email.app_error", map[string]any{"Addresses": s}, "", http.StatusBadRequest)
}
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
@@ -1654,7 +1654,7 @@ func (a *App) InviteGuestsToChannels(teamID string, guestsInvite *model.GuestsIn
if len(invalidEmailList) > 0 {
s := strings.Join(invalidEmailList, ", ")
return model.NewAppError("InviteGuestsToChannels", "api.team.invite_members.invalid_email.app_error", map[string]interface{}{"Addresses": s}, "", http.StatusBadRequest)
return model.NewAppError("InviteGuestsToChannels", "api.team.invite_members.invalid_email.app_error", map[string]any{"Addresses": s}, "", http.StatusBadRequest)
}
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay

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

@@ -47,7 +47,7 @@ func (a *App) runPluginsHook(c *request.Context, info *model.FileInfo, file io.R
newInfo, rejStr := hooks.FileWillBeUploaded(pluginContext, info, file, w)
if rejStr != "" {
rejErr = model.NewAppError("runPluginsHook", "app.upload.run_plugins_hook.rejected",
map[string]interface{}{"Filename": info.Name, "Reason": rejStr}, "", http.StatusBadRequest)
map[string]any{"Filename": info.Name, "Reason": rejStr}, "", http.StatusBadRequest)
return false
}
if newInfo != nil {
@@ -102,7 +102,7 @@ func (a *App) runPluginsHook(c *request.Context, info *model.FileInfo, file io.R
func (a *App) CreateUploadSession(us *model.UploadSession) (*model.UploadSession, *model.AppError) {
if us.FileSize > *a.Config().FileSettings.MaxFileSize {
return nil, model.NewAppError("CreateUploadSession", "app.upload.create.upload_too_large.app_error",
map[string]interface{}{"channelId": us.ChannelId}, "", http.StatusRequestEntityTooLarge)
map[string]any{"channelId": us.ChannelId}, "", http.StatusRequestEntityTooLarge)
}
us.FileOffset = 0
@@ -121,11 +121,11 @@ func (a *App) CreateUploadSession(us *model.UploadSession) (*model.UploadSession
channel, err := a.GetChannel(us.ChannelId)
if err != nil {
return nil, model.NewAppError("CreateUploadSession", "app.upload.create.incorrect_channel_id.app_error",
map[string]interface{}{"channelId": us.ChannelId}, "", http.StatusBadRequest)
map[string]any{"channelId": us.ChannelId}, "", http.StatusBadRequest)
}
if channel.DeleteAt != 0 {
return nil, model.NewAppError("CreateUploadSession", "app.upload.create.cannot_upload_to_deleted_channel.app_error",
map[string]interface{}{"channelId": us.ChannelId}, "", http.StatusBadRequest)
map[string]any{"channelId": us.ChannelId}, "", http.StatusBadRequest)
}
}
@@ -217,7 +217,7 @@ func (a *App) UploadData(c *request.Context, us *model.UploadSession, rd io.Read
errStr = err.Error()
}
return nil, model.NewAppError("UploadData", "app.upload.upload_data.first_part_too_small.app_error",
map[string]interface{}{"Size": minFirstPartSize}, errStr, http.StatusBadRequest)
map[string]any{"Size": minFirstPartSize}, errStr, http.StatusBadRequest)
}
} else if us.FileOffset < us.FileSize {
// resume upload
@@ -266,7 +266,7 @@ func (a *App) UploadData(c *request.Context, us *model.UploadSession, rd io.Read
if info.IsImage() && !info.IsSvg() {
if limitErr := checkImageResolutionLimit(info.Width, info.Height, *a.Config().FileSettings.MaxImageResolution); limitErr != nil {
return nil, model.NewAppError("uploadData", "app.upload.upload_data.large_image.app_error",
map[string]interface{}{"Filename": us.Filename, "Width": info.Width, "Height": info.Height}, "", http.StatusBadRequest)
map[string]any{"Filename": us.Filename, "Width": info.Width, "Height": info.Height}, "", http.StatusBadRequest)
}
nameWithoutExtension := info.Name[:strings.LastIndex(info.Name, ".")]

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

@@ -137,7 +137,7 @@ func (a *App) CreateUserWithInviteId(c *request.Context, user *model.User, invit
}
if !users.CheckUserDomain(user, team.AllowedDomains) {
return nil, model.NewAppError("CreateUserWithInviteId", "api.team.invite_members.invalid_email.app_error", map[string]interface{}{"Addresses": team.AllowedDomains}, "", http.StatusForbidden)
return nil, model.NewAppError("CreateUserWithInviteId", "api.team.invite_members.invalid_email.app_error", map[string]any{"Addresses": team.AllowedDomains}, "", http.StatusForbidden)
}
user.EmailVerified = false
@@ -319,7 +319,7 @@ func (a *App) CreateOAuthUser(c *request.Context, service string, userData io.Re
}
user, err1 := provider.GetUserFromJSON(userData, tokenUser)
if err1 != nil {
return nil, model.NewAppError("CreateOAuthUser", "api.user.create_oauth_user.create.app_error", map[string]interface{}{"Service": service}, err1.Error(), http.StatusInternalServerError)
return nil, model.NewAppError("CreateOAuthUser", "api.user.create_oauth_user.create.app_error", map[string]any{"Service": service}, err1.Error(), http.StatusInternalServerError)
}
if user.AuthService == "" {
user.AuthService = service
@@ -342,7 +342,7 @@ func (a *App) CreateOAuthUser(c *request.Context, service string, userData io.Re
userByEmail, _ := a.ch.srv.userService.GetUserByEmail(user.Email)
if userByEmail != nil {
if userByEmail.AuthService == "" {
return nil, model.NewAppError("CreateOAuthUser", "api.user.create_oauth_user.already_attached.app_error", map[string]interface{}{"Service": service, "Auth": model.UserAuthServiceEmail}, "email="+user.Email, http.StatusBadRequest)
return nil, model.NewAppError("CreateOAuthUser", "api.user.create_oauth_user.already_attached.app_error", map[string]any{"Service": service, "Auth": model.UserAuthServiceEmail}, "email="+user.Email, http.StatusBadRequest)
}
if provider.IsSameUser(userByEmail, user) {
if _, err := a.Srv().Store.User().UpdateAuthData(userByEmail.Id, user.AuthService, user.AuthData, "", false); err != nil {
@@ -351,7 +351,7 @@ func (a *App) CreateOAuthUser(c *request.Context, service string, userData io.Re
}
return userByEmail, nil
}
return nil, model.NewAppError("CreateOAuthUser", "api.user.create_oauth_user.already_attached.app_error", map[string]interface{}{"Service": service, "Auth": userByEmail.AuthService}, "email="+user.Email+" authData="+*user.AuthData, http.StatusBadRequest)
return nil, model.NewAppError("CreateOAuthUser", "api.user.create_oauth_user.already_attached.app_error", map[string]any{"Service": service, "Auth": userByEmail.AuthService}, "email="+user.Email+" authData="+*user.AuthData, http.StatusBadRequest)
}
user.EmailVerified = true
@@ -1592,7 +1592,7 @@ func (a *App) PermanentDeleteUser(c *request.Context, user *model.User) *model.A
var invErr *store.ErrInvalidInput
switch {
case errors.As(err, &invErr):
return model.NewAppError("PermanentDeleteUser", "app.bot.permenent_delete.bad_id", map[string]interface{}{"user_id": invErr.Value}, invErr.Error(), http.StatusBadRequest)
return model.NewAppError("PermanentDeleteUser", "app.bot.permenent_delete.bad_id", map[string]any{"user_id": invErr.Value}, invErr.Error(), http.StatusBadRequest)
default: // last fallback in case it doesn't map to an existing app error.
return model.NewAppError("PermanentDeleteUser", "app.bot.permanent_delete.internal_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -1952,7 +1952,7 @@ func (a *App) AutocompleteUsersInTeam(teamID string, term string, options *model
func (a *App) UpdateOAuthUserAttrs(userData io.Reader, user *model.User, provider einterfaces.OAuthProvider, service string, tokenUser *model.User) *model.AppError {
oauthUser, err1 := provider.GetUserFromJSON(userData, tokenUser)
if err1 != nil {
return model.NewAppError("UpdateOAuthUserAttrs", "api.user.update_oauth_user_attrs.get_user.app_error", map[string]interface{}{"Service": service}, err1.Error(), http.StatusBadRequest)
return model.NewAppError("UpdateOAuthUserAttrs", "api.user.update_oauth_user_attrs.get_user.app_error", map[string]any{"Service": service}, err1.Error(), http.StatusBadRequest)
}
userAttrsChanged := false

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

@@ -91,7 +91,7 @@ func setupTestHelper(s store.Store, includeCacheLayer bool, tb testing.TB) *Test
sessionCache: cache,
config: configStore.Get,
sessionPool: sync.Pool{
New: func() interface{} {
New: func() any {
return &model.Session{}
},
},

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

@@ -69,7 +69,7 @@ func New(c ServiceConfig) (*UserService, error) {
cluster: c.Cluster,
sessionCache: sessionCache,
sessionPool: sync.Pool{
New: func() interface{} {
New: func() any {
return &model.Session{}
},
},

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

@@ -362,7 +362,7 @@ func (wc *WebConn) readPump() {
}
var decoder interface {
Decode(v interface{}) error
Decode(v any) error
}
if msgType == websocket.TextMessage {
decoder = json.NewDecoder(rd)

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

@@ -187,7 +187,7 @@ func SplitWebhookPost(post *model.Post, maxPostSize int) ([]*model.Post, *model.
base := post.Clone()
base.Message = ""
base.SetProps(make(map[string]interface{}))
base.SetProps(make(map[string]any))
for k, v := range post.GetProps() {
if k != "attachments" {
base.AddProp(k, v)
@@ -195,7 +195,7 @@ func SplitWebhookPost(post *model.Post, maxPostSize int) ([]*model.Post, *model.
}
if utf8.RuneCountInString(model.StringInterfaceToJSON(base.GetProps())) > model.PostPropsMaxUserRunes {
return nil, model.NewAppError("SplitWebhookPost", "web.incoming_webhook.split_props_length.app_error", map[string]interface{}{"Max": model.PostPropsMaxUserRunes}, "", http.StatusBadRequest)
return nil, model.NewAppError("SplitWebhookPost", "web.incoming_webhook.split_props_length.app_error", map[string]any{"Max": model.PostPropsMaxUserRunes}, "", http.StatusBadRequest)
}
for utf8.RuneCountInString(remainingText) > maxPostSize {
@@ -221,7 +221,7 @@ func SplitWebhookPost(post *model.Post, maxPostSize int) ([]*model.Post, *model.
newAttachment := *attachment
for {
lastSplit := splits[len(splits)-1]
newProps := make(map[string]interface{})
newProps := make(map[string]any)
for k, v := range lastSplit.GetProps() {
newProps[k] = v
}
@@ -244,7 +244,7 @@ func SplitWebhookPost(post *model.Post, maxPostSize int) ([]*model.Post, *model.
truncationNeeded := runeCount - model.PostPropsMaxUserRunes
textRuneCount := utf8.RuneCountInString(attachment.Text)
if textRuneCount < truncationNeeded {
return nil, model.NewAppError("SplitWebhookPost", "web.incoming_webhook.split_props_length.app_error", map[string]interface{}{"Max": model.PostPropsMaxUserRunes}, "", http.StatusBadRequest)
return nil, model.NewAppError("SplitWebhookPost", "web.incoming_webhook.split_props_length.app_error", map[string]any{"Max": model.PostPropsMaxUserRunes}, "", http.StatusBadRequest)
}
x := 0
for index := range attachment.Text {
@@ -271,7 +271,7 @@ func (a *App) CreateWebhookPost(c *request.Context, userID string, channel *mode
post.AddProp("from_webhook", "true")
if strings.HasPrefix(post.Type, model.PostSystemMessagePrefix) {
err := model.NewAppError("CreateWebhookPost", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "post.type"}, "", http.StatusBadRequest)
err := model.NewAppError("CreateWebhookPost", "api.context.invalid_param.app_error", map[string]any{"Name": "post.type"}, "", http.StatusBadRequest)
return nil, err
}
@@ -828,7 +828,7 @@ func (a *App) HandleCommandWebhook(c *request.Context, hookID string, response *
var nfErr *store.ErrNotFound
switch {
case errors.As(nErr, &nfErr):
return model.NewAppError("HandleCommandWebhook", "app.command_webhook.get.missing", map[string]interface{}{"hook_id": hookID}, nfErr.Error(), http.StatusNotFound)
return model.NewAppError("HandleCommandWebhook", "app.command_webhook.get.missing", map[string]any{"hook_id": hookID}, nfErr.Error(), http.StatusNotFound)
default:
return model.NewAppError("HandleCommandWebhook", "app.command_webhook.get.internal_error", nil, nErr.Error(), http.StatusInternalServerError)
}

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

@@ -388,7 +388,7 @@ func TestSplitWebhookPost(t *testing.T) {
"LongPostAndMultipleAttachments": {
Post: &model.Post{
Message: strings.Repeat("本", maxPostSize*3/2),
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: strings.Repeat("本", 1000),
@@ -408,7 +408,7 @@ func TestSplitWebhookPost(t *testing.T) {
},
{
Message: strings.Repeat("本", maxPostSize/2),
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: strings.Repeat("本", 1000),
@@ -420,7 +420,7 @@ func TestSplitWebhookPost(t *testing.T) {
},
},
{
Props: map[string]interface{}{
Props: map[string]any{
"attachments": []*model.SlackAttachment{
{
Text: strings.Repeat("本", model.PostPropsMaxUserRunes-1000),
@@ -433,7 +433,7 @@ func TestSplitWebhookPost(t *testing.T) {
"UnsplittableProps": {
Post: &model.Post{
Message: "foo",
Props: map[string]interface{}{
Props: map[string]any{
"foo": strings.Repeat("x", model.PostPropsMaxUserRunes*2),
},
},
@@ -467,7 +467,7 @@ func makePost(message int, attachments []int) *model.Post {
}
sa = append(sa, attach)
}
props = map[string]interface{}{"attachments": sa}
props = map[string]any{"attachments": sa}
}
post := &model.Post{
Message: strings.Repeat("那", message),
@@ -782,7 +782,7 @@ func TestDoOutgoingWebhookRequest(t *testing.T) {
})
t.Run("with a slow response", func(t *testing.T) {
releaseHandler := make(chan interface{})
releaseHandler := make(chan any)
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Don't actually handle the response, allowing the app to timeout.

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

@@ -101,7 +101,7 @@ type actionData struct {
selectTeamID string
invalidateConnUserID string
updateConnUserID string
attachment map[string]interface{}
attachment map[string]any
}
func getActionData(data []byte, userIDs, teamIDs, channelIDs []string) *actionData {
@@ -131,7 +131,7 @@ func getActionData(data []byte, userIDs, teamIDs, channelIDs []string) *actionDa
input.updateConnUserID = userIDs[int(data[4])%len(userIDs)]
input.event = events[int(data[5])%len(events)]
data = data[6:]
input.attachment = make(map[string]interface{})
input.attachment = make(map[string]any)
for len(data) >= 4 { // 2 bytes key, 2 bytes value
k := data[:2]
v := data[2:4]