Replacing interface{} with any everywhere (except generated mocks) (#29446)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a21d470bee
Коммит
d316df6d28
@@ -1774,7 +1774,7 @@ func addChannelMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
props := model.StringInterfaceFromJSON(r.Body)
|
||||
|
||||
var userIds []string
|
||||
interfaceIds, ok := props["user_ids"].([]interface{})
|
||||
interfaceIds, ok := props["user_ids"].([]any)
|
||||
if ok {
|
||||
if len(interfaceIds) > maxListSize {
|
||||
c.SetInvalidParam("user_ids")
|
||||
|
||||
@@ -401,8 +401,8 @@ func queryLogs(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
logsJSON := make(map[string][]interface{})
|
||||
var result interface{}
|
||||
logsJSON := make(map[string][]any)
|
||||
var result any
|
||||
for node, logLines := range logs {
|
||||
for _, log := range logLines {
|
||||
err = json.Unmarshal([]byte(log), &result)
|
||||
|
||||
@@ -88,7 +88,7 @@ func (a *App) MakeAuditRecord(rctx request.CTX, event string, initialStatus stri
|
||||
rec := &audit.Record{
|
||||
EventName: event,
|
||||
Status: initialStatus,
|
||||
Meta: map[string]interface{}{
|
||||
Meta: map[string]any{
|
||||
audit.KeyAPIPath: "",
|
||||
audit.KeyClusterID: a.GetClusterId(),
|
||||
},
|
||||
@@ -100,9 +100,9 @@ func (a *App) MakeAuditRecord(rctx request.CTX, event string, initialStatus stri
|
||||
XForwardedFor: "",
|
||||
},
|
||||
EventData: audit.EventData{
|
||||
Parameters: map[string]interface{}{},
|
||||
PriorState: map[string]interface{}{},
|
||||
ResultState: map[string]interface{}{},
|
||||
Parameters: map[string]any{},
|
||||
PriorState: map[string]any{},
|
||||
ResultState: map[string]any{},
|
||||
ObjectType: "",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func (a *App) UpsertDraft(c request.CTX, draft *model.Draft, connectionID string
|
||||
// Check that channel exists and has not been deleted
|
||||
channel, errCh := a.Srv().Store().Channel().Get(draft.ChannelId, true)
|
||||
if errCh != nil {
|
||||
err := model.NewAppError("CreateDraft", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "draft.channel_id"}, "", http.StatusBadRequest).Wrap(errCh)
|
||||
err := model.NewAppError("CreateDraft", "api.context.invalid_param.app_error", map[string]any{"Name": "draft.channel_id"}, "", http.StatusBadRequest).Wrap(errCh)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ func (a *App) elasticsearchChannelIndexCheck() {
|
||||
}
|
||||
|
||||
// TODO include a link to changelog
|
||||
postMessage := i18n.T("app.channel.elasticsearch_channel_index.notify_admin.message", map[string]interface{}{"ElasticsearchSection": elasticsearchSettingsSectionLink})
|
||||
postMessage := i18n.T("app.channel.elasticsearch_channel_index.notify_admin.message", map[string]any{"ElasticsearchSection": elasticsearchSettingsSectionLink})
|
||||
|
||||
for _, sysAdmin := range sysAdmins {
|
||||
var channel *model.Channel
|
||||
|
||||
@@ -1512,7 +1512,7 @@ func (a *App) GetLastAccessibleFileTime() (int64, *model.AppError) {
|
||||
|
||||
lastAccessibleFileTime, err := strconv.ParseInt(system.Value, 10, 64)
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("GetLastAccessibleFileTime", "common.parse_error_int64", map[string]interface{}{"Value": system.Value}, "", http.StatusInternalServerError).Wrap(err)
|
||||
return 0, model.NewAppError("GetLastAccessibleFileTime", "common.parse_error_int64", map[string]any{"Value": system.Value}, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
return lastAccessibleFileTime, nil
|
||||
|
||||
@@ -127,7 +127,7 @@ func (a *App) isUniqueToUsernames(val string) *model.AppError {
|
||||
return model.NewAppError("isUniqueToUsernames", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
if user != nil {
|
||||
return model.NewAppError("isUniqueToUsernames", "app.group.username_conflict", map[string]interface{}{"Username": val}, "", http.StatusBadRequest)
|
||||
return model.NewAppError("isUniqueToUsernames", "app.group.username_conflict", map[string]any{"Username": val}, "", http.StatusBadRequest)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -135,14 +135,14 @@ func (a *App) upgradePlanAdminNotifyPost(c request.CTX, workspaceName string, us
|
||||
props := make(model.StringInterface)
|
||||
T := i18n.GetUserTranslations(admin.Locale)
|
||||
|
||||
message := T("app.cloud.upgrade_plan_bot_message", map[string]interface{}{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
|
||||
message := T("app.cloud.upgrade_plan_bot_message", map[string]any{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
|
||||
if len(userBasedData) == 1 {
|
||||
message = T("app.cloud.upgrade_plan_bot_message_single", map[string]interface{}{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName}) // todo (allan): investigate if translations library can do this
|
||||
message = T("app.cloud.upgrade_plan_bot_message_single", map[string]any{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName}) // todo (allan): investigate if translations library can do this
|
||||
}
|
||||
if trial {
|
||||
message = T("app.cloud.trial_plan_bot_message", map[string]interface{}{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
|
||||
message = T("app.cloud.trial_plan_bot_message", map[string]any{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
|
||||
if len(userBasedData) == 1 {
|
||||
message = T("app.cloud.trial_plan_bot_message_single", map[string]interface{}{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
|
||||
message = T("app.cloud.trial_plan_bot_message_single", map[string]any{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,11 +114,11 @@ func (ps *PlatformService) ReloadConfig() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ps *PlatformService) GetEnvironmentOverridesWithFilter(filter func(reflect.StructField) bool) map[string]interface{} {
|
||||
func (ps *PlatformService) GetEnvironmentOverridesWithFilter(filter func(reflect.StructField) bool) map[string]any {
|
||||
return ps.configStore.GetEnvironmentOverridesWithFilter(filter)
|
||||
}
|
||||
|
||||
func (ps *PlatformService) GetEnvironmentOverrides() map[string]interface{} {
|
||||
func (ps *PlatformService) GetEnvironmentOverrides() map[string]any {
|
||||
return ps.configStore.GetEnvironmentOverrides()
|
||||
}
|
||||
|
||||
|
||||
@@ -1597,7 +1597,7 @@ func (a *App) GetLastAccessiblePostTime() (int64, *model.AppError) {
|
||||
|
||||
lastAccessiblePostTime, err := strconv.ParseInt(system.Value, 10, 64)
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("GetLastAccessiblePostTime", "common.parse_error_int64", map[string]interface{}{"Value": system.Value}, "", http.StatusInternalServerError).Wrap(err)
|
||||
return 0, model.NewAppError("GetLastAccessiblePostTime", "common.parse_error_int64", map[string]any{"Value": system.Value}, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
return lastAccessiblePostTime, nil
|
||||
|
||||
@@ -451,7 +451,7 @@ func (a *App) notifyUser(rctx request.CTX, userId string, userFailedMessages []*
|
||||
var messageBuilder strings.Builder
|
||||
|
||||
totalFailedMessages := len(userFailedMessages)
|
||||
messageHeader := T("app.scheduled_post.failed_messages", map[string]interface{}{
|
||||
messageHeader := T("app.scheduled_post.failed_messages", map[string]any{
|
||||
"Count": totalFailedMessages,
|
||||
})
|
||||
messageBuilder.WriteString(messageHeader)
|
||||
@@ -461,7 +461,7 @@ func (a *App) notifyUser(rctx request.CTX, userId string, userFailedMessages []*
|
||||
channelName := channelNames[key.ChannelId]
|
||||
errorReason := getErrorReason(T, key.ErrorCode)
|
||||
|
||||
detailedMessage := T("app.scheduled_post.failed_message_detail", map[string]interface{}{
|
||||
detailedMessage := T("app.scheduled_post.failed_message_detail", map[string]any{
|
||||
"Count": count,
|
||||
"ChannelName": channelName,
|
||||
"ErrorReason": errorReason,
|
||||
|
||||
@@ -384,7 +384,7 @@ func TestHandleFailedScheduledPosts(t *testing.T) {
|
||||
}
|
||||
|
||||
T := i18n.GetUserTranslations(user.Locale)
|
||||
messageHeader := T("app.scheduled_post.failed_messages", map[string]interface{}{
|
||||
messageHeader := T("app.scheduled_post.failed_messages", map[string]any{
|
||||
"Count": len(userFailedMessages),
|
||||
})
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ func (*ExportLinkProvider) DoCommand(a *app.App, c request.CTX, args *model.Comm
|
||||
}
|
||||
|
||||
// return link
|
||||
return &model.CommandResponse{ResponseType: model.CommandResponseTypeEphemeral, Text: args.T("api.command_exportlink.link.text", map[string]interface{}{
|
||||
return &model.CommandResponse{ResponseType: model.CommandResponseTypeEphemeral, Text: args.T("api.command_exportlink.link.text", map[string]any{
|
||||
"Link": res.URL,
|
||||
"Expiration": res.Expiration.String(),
|
||||
})}
|
||||
|
||||
@@ -261,7 +261,7 @@ func (a *App) createUserOrGuest(c request.CTX, user *model.User, guest bool) (*m
|
||||
case errors.Is(nErr, users.AcceptedDomainError):
|
||||
return nil, model.NewAppError("createUserOrGuest", "api.user.create_user.accepted_domain.app_error", nil, "", http.StatusBadRequest).Wrap(nErr)
|
||||
case errors.As(nErr, &nfErr):
|
||||
return nil, model.NewAppError("createUserOrGuest", nfErr.Id(), map[string]interface{}{"Min": *a.Config().PasswordSettings.MinimumLength}, "", http.StatusBadRequest)
|
||||
return nil, model.NewAppError("createUserOrGuest", nfErr.Id(), map[string]any{"Min": *a.Config().PasswordSettings.MinimumLength}, "", http.StatusBadRequest)
|
||||
case errors.Is(nErr, users.UserStoreIsEmptyError):
|
||||
return nil, model.NewAppError("createUserOrGuest", "app.user.store_is_empty.app_error", nil, "", http.StatusInternalServerError).Wrap(nErr)
|
||||
case errors.As(nErr, &invErr):
|
||||
|
||||
@@ -5,20 +5,20 @@ package audit
|
||||
|
||||
// Record provides a consistent set of fields used for all audit logging.
|
||||
type Record struct {
|
||||
EventName string `json:"event_name"`
|
||||
Status string `json:"status"`
|
||||
EventData EventData `json:"event"`
|
||||
Actor EventActor `json:"actor"`
|
||||
Meta map[string]interface{} `json:"meta"`
|
||||
Error EventError `json:"error,omitempty"`
|
||||
EventName string `json:"event_name"`
|
||||
Status string `json:"status"`
|
||||
EventData EventData `json:"event"`
|
||||
Actor EventActor `json:"actor"`
|
||||
Meta map[string]any `json:"meta"`
|
||||
Error EventError `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// EventData contains all event specific data about the modified entity
|
||||
type EventData struct {
|
||||
Parameters map[string]interface{} `json:"parameters"` // Payload and parameters being processed as part of the request
|
||||
PriorState map[string]interface{} `json:"prior_state"` // Prior state of the object being modified, nil if no prior state
|
||||
ResultState map[string]interface{} `json:"resulting_state"` // Resulting object after creating or modifying it
|
||||
ObjectType string `json:"object_type"` // String representation of the object type. eg. "post"
|
||||
Parameters map[string]any `json:"parameters"` // Payload and parameters being processed as part of the request
|
||||
PriorState map[string]any `json:"prior_state"` // Prior state of the object being modified, nil if no prior state
|
||||
ResultState map[string]any `json:"resulting_state"` // Resulting object after creating or modifying it
|
||||
ObjectType string `json:"object_type"` // String representation of the object type. eg. "post"
|
||||
}
|
||||
|
||||
// EventActor is the subject triggering the event
|
||||
@@ -46,7 +46,7 @@ type EventError struct {
|
||||
// AuditableObject returns. For example: it's likely OK to write a user object to the
|
||||
// audit logs, but not the user password in cleartext or hashed form
|
||||
type Auditable interface {
|
||||
Auditable() map[string]interface{}
|
||||
Auditable() map[string]any
|
||||
}
|
||||
|
||||
// Success marks the audit record status as successful.
|
||||
@@ -62,7 +62,7 @@ func (rec *Record) Fail() {
|
||||
// AddEventParameter adds a parameter, e.g. query or post body, to the event
|
||||
func AddEventParameter[T string | bool | int | int64 | []string | map[string]string](rec *Record, key string, val T) {
|
||||
if rec.EventData.Parameters == nil {
|
||||
rec.EventData.Parameters = make(map[string]interface{})
|
||||
rec.EventData.Parameters = make(map[string]any)
|
||||
}
|
||||
|
||||
rec.EventData.Parameters[key] = val
|
||||
@@ -71,7 +71,7 @@ func AddEventParameter[T string | bool | int | int64 | []string | map[string]str
|
||||
// AddEventParameterAuditable adds an object that is of type Auditable to the event
|
||||
func AddEventParameterAuditable(rec *Record, key string, val Auditable) {
|
||||
if rec.EventData.Parameters == nil {
|
||||
rec.EventData.Parameters = make(map[string]interface{})
|
||||
rec.EventData.Parameters = make(map[string]any)
|
||||
}
|
||||
|
||||
rec.EventData.Parameters[key] = val.Auditable()
|
||||
@@ -80,10 +80,10 @@ func AddEventParameterAuditable(rec *Record, key string, val Auditable) {
|
||||
// AddEventParameterAuditableArray adds an array of objects of type Auditable to the event
|
||||
func AddEventParameterAuditableArray[T Auditable](rec *Record, key string, val []T) {
|
||||
if rec.EventData.Parameters == nil {
|
||||
rec.EventData.Parameters = make(map[string]interface{})
|
||||
rec.EventData.Parameters = make(map[string]any)
|
||||
}
|
||||
|
||||
processedAuditables := make([]map[string]interface{}, 0, len(val))
|
||||
processedAuditables := make([]map[string]any, 0, len(val))
|
||||
for _, auditableVal := range val {
|
||||
processedAuditables = append(processedAuditables, auditableVal.Auditable())
|
||||
}
|
||||
@@ -108,7 +108,7 @@ func (rec *Record) AddEventObjectType(objectType string) {
|
||||
|
||||
// AddMeta adds a key/value entry to the audit record that can be used for related information not directly related to
|
||||
// the modified object, e.g. authentication method
|
||||
func (rec *Record) AddMeta(name string, val interface{}) {
|
||||
func (rec *Record) AddMeta(name string, val any) {
|
||||
rec.Meta[name] = val
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ func draftSliceColumns() []string {
|
||||
}
|
||||
}
|
||||
|
||||
func draftToSlice(draft *model.Draft) []interface{} {
|
||||
return []interface{}{
|
||||
func draftToSlice(draft *model.Draft) []any {
|
||||
return []any{
|
||||
draft.CreateAt,
|
||||
draft.UpdateAt,
|
||||
draft.DeleteAt,
|
||||
|
||||
@@ -319,7 +319,7 @@ func (s SqlPreferenceStore) CleanupFlagsBatch(limit int64) (int64, error) {
|
||||
// Delete preference for limit_visible_dms_gms where their value is greater than "40" or less than "1"
|
||||
func (s SqlPreferenceStore) DeleteInvalidVisibleDmsGms() (int64, error) {
|
||||
var queryString string
|
||||
var args []interface{}
|
||||
var args []any
|
||||
var err error
|
||||
|
||||
// We need to pad the value field with zeros when doing comparison's because the value is stored as a string.
|
||||
|
||||
@@ -48,8 +48,8 @@ func (s *SqlScheduledPostStore) columns(prefix string) []string {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SqlScheduledPostStore) scheduledPostToSlice(scheduledPost *model.ScheduledPost) []interface{} {
|
||||
return []interface{}{
|
||||
func (s *SqlScheduledPostStore) scheduledPostToSlice(scheduledPost *model.ScheduledPost) []any {
|
||||
return []any{
|
||||
scheduledPost.Id,
|
||||
scheduledPost.CreateAt,
|
||||
scheduledPost.UpdateAt,
|
||||
@@ -230,9 +230,9 @@ func (s *SqlScheduledPostStore) UpdatedScheduledPost(scheduledPost *model.Schedu
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SqlScheduledPostStore) toUpdateMap(scheduledPost *model.ScheduledPost) map[string]interface{} {
|
||||
func (s *SqlScheduledPostStore) toUpdateMap(scheduledPost *model.ScheduledPost) map[string]any {
|
||||
now := model.GetMillis()
|
||||
return map[string]interface{}{
|
||||
return map[string]any{
|
||||
"UpdateAt": now,
|
||||
"Message": scheduledPost.Message,
|
||||
"Props": model.StringInterfaceToJSON(scheduledPost.GetProps()),
|
||||
|
||||
@@ -71,14 +71,14 @@ func (c *Context) MakeAuditRecord(event string, initialStatus string) *audit.Rec
|
||||
IpAddress: c.AppContext.IPAddress(),
|
||||
XForwardedFor: c.AppContext.XForwardedFor(),
|
||||
},
|
||||
Meta: map[string]interface{}{
|
||||
Meta: map[string]any{
|
||||
audit.KeyAPIPath: c.AppContext.Path(),
|
||||
audit.KeyClusterID: c.App.GetClusterId(),
|
||||
},
|
||||
EventData: audit.EventData{
|
||||
Parameters: map[string]interface{}{},
|
||||
PriorState: map[string]interface{}{},
|
||||
ResultState: map[string]interface{}{},
|
||||
Parameters: map[string]any{},
|
||||
PriorState: map[string]any{},
|
||||
ResultState: map[string]any{},
|
||||
ObjectType: "",
|
||||
},
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user