коммит произвёл
GitHub
родитель
b45ff0be5d
Коммит
717a4d04a9
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// AuditModelTypeConv converts key model types to something better suited for audit output.
|
||||
func AuditModelTypeConv(val interface{}) (newVal interface{}, converted bool) {
|
||||
func AuditModelTypeConv(val any) (newVal any, converted bool) {
|
||||
if val == nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ func TestAuditModelTypeConv(t *testing.T) {
|
||||
userPatch := &UserPatch{}
|
||||
|
||||
type args struct {
|
||||
val interface{}
|
||||
val any
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantConverted bool
|
||||
wantNewVal interface{}
|
||||
wantNewVal any
|
||||
}{
|
||||
{name: "nil value", args: args{val: nil}, wantConverted: false, wantNewVal: nil},
|
||||
{name: "string value", args: args{val: "hello"}, wantConverted: false, wantNewVal: "hello"},
|
||||
|
||||
@@ -53,8 +53,8 @@ type BotGetOptions struct {
|
||||
type BotList []*Bot
|
||||
|
||||
// Trace describes the minimum information required to identify a bot for the purpose of logging.
|
||||
func (b *Bot) Trace() map[string]interface{} {
|
||||
return map[string]interface{}{"user_id": b.UserId}
|
||||
func (b *Bot) Trace() map[string]any {
|
||||
return map[string]any{"user_id": b.UserId}
|
||||
}
|
||||
|
||||
// Clone returns a shallow copy of the bot.
|
||||
@@ -192,7 +192,7 @@ func (l *BotList) Etag() string {
|
||||
// MakeBotNotFoundError creates the error returned when a bot does not exist, or when the user isn't allowed to query the bot.
|
||||
// The errors must the same in both cases to avoid leaking that a user is a bot.
|
||||
func MakeBotNotFoundError(userId string) *AppError {
|
||||
return NewAppError("SqlBotStore.Get", "store.sql_bot.get.missing.app_error", map[string]interface{}{"user_id": userId}, "", http.StatusNotFound)
|
||||
return NewAppError("SqlBotStore.Get", "store.sql_bot.get.missing.app_error", map[string]any{"user_id": userId}, "", http.StatusNotFound)
|
||||
}
|
||||
|
||||
func IsBotDMChannel(channel *Channel, botUserID string) bool {
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestBotTrace(t *testing.T) {
|
||||
DeleteAt: 4,
|
||||
}
|
||||
|
||||
require.Equal(t, map[string]interface{}{"user_id": bot.UserId}, bot.Trace())
|
||||
require.Equal(t, map[string]any{"user_id": bot.UserId}, bot.Trace())
|
||||
}
|
||||
|
||||
func TestBotClone(t *testing.T) {
|
||||
|
||||
@@ -38,27 +38,27 @@ const (
|
||||
)
|
||||
|
||||
type Channel struct {
|
||||
Id string `json:"id"`
|
||||
CreateAt int64 `json:"create_at"`
|
||||
UpdateAt int64 `json:"update_at"`
|
||||
DeleteAt int64 `json:"delete_at"`
|
||||
TeamId string `json:"team_id"`
|
||||
Type ChannelType `json:"type"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Name string `json:"name"`
|
||||
Header string `json:"header"`
|
||||
Purpose string `json:"purpose"`
|
||||
LastPostAt int64 `json:"last_post_at"`
|
||||
TotalMsgCount int64 `json:"total_msg_count"`
|
||||
ExtraUpdateAt int64 `json:"extra_update_at"`
|
||||
CreatorId string `json:"creator_id"`
|
||||
SchemeId *string `json:"scheme_id"`
|
||||
Props map[string]interface{} `json:"props"`
|
||||
GroupConstrained *bool `json:"group_constrained"`
|
||||
Shared *bool `json:"shared"`
|
||||
TotalMsgCountRoot int64 `json:"total_msg_count_root"`
|
||||
PolicyID *string `json:"policy_id"`
|
||||
LastRootPostAt int64 `json:"last_root_post_at"`
|
||||
Id string `json:"id"`
|
||||
CreateAt int64 `json:"create_at"`
|
||||
UpdateAt int64 `json:"update_at"`
|
||||
DeleteAt int64 `json:"delete_at"`
|
||||
TeamId string `json:"team_id"`
|
||||
Type ChannelType `json:"type"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Name string `json:"name"`
|
||||
Header string `json:"header"`
|
||||
Purpose string `json:"purpose"`
|
||||
LastPostAt int64 `json:"last_post_at"`
|
||||
TotalMsgCount int64 `json:"total_msg_count"`
|
||||
ExtraUpdateAt int64 `json:"extra_update_at"`
|
||||
CreatorId string `json:"creator_id"`
|
||||
SchemeId *string `json:"scheme_id"`
|
||||
Props map[string]any `json:"props"`
|
||||
GroupConstrained *bool `json:"group_constrained"`
|
||||
Shared *bool `json:"shared"`
|
||||
TotalMsgCountRoot int64 `json:"total_msg_count_root"`
|
||||
PolicyID *string `json:"policy_id"`
|
||||
LastRootPostAt int64 `json:"last_root_post_at"`
|
||||
}
|
||||
|
||||
type ChannelWithTeamData struct {
|
||||
@@ -296,11 +296,11 @@ func (o *Channel) Patch(patch *ChannelPatch) {
|
||||
|
||||
func (o *Channel) MakeNonNil() {
|
||||
if o.Props == nil {
|
||||
o.Props = make(map[string]interface{})
|
||||
o.Props = make(map[string]any)
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Channel) AddProp(key string, value interface{}) {
|
||||
func (o *Channel) AddProp(key string, value any) {
|
||||
o.MakeNonNil()
|
||||
|
||||
o.Props[key] = value
|
||||
@@ -342,7 +342,7 @@ func (t ChannelType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(string(t))
|
||||
}
|
||||
|
||||
func (t *ChannelType) UnmarshalGraphQL(input interface{}) error {
|
||||
func (t *ChannelType) UnmarshalGraphQL(input any) error {
|
||||
chType, ok := input.(string)
|
||||
if !ok {
|
||||
return errors.New("wrong type")
|
||||
|
||||
@@ -143,7 +143,7 @@ func (o *ChannelMember) IsValid() *AppError {
|
||||
|
||||
if len(o.Roles) > UserRolesMaxLength {
|
||||
return NewAppError("ChannelMember.IsValid", "model.channel_member.is_valid.roles_limit.app_error",
|
||||
map[string]interface{}{"Limit": UserRolesMaxLength}, "", http.StatusBadRequest)
|
||||
map[string]any{"Limit": UserRolesMaxLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -97,7 +97,7 @@ func (t SidebarCategoryType) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(string(t))
|
||||
}
|
||||
|
||||
func (t *SidebarCategoryType) UnmarshalGraphQL(input interface{}) error {
|
||||
func (t *SidebarCategoryType) UnmarshalGraphQL(input any) error {
|
||||
chType, ok := input.(string)
|
||||
if !ok {
|
||||
return errors.New("wrong type")
|
||||
@@ -115,7 +115,7 @@ func (t SidebarCategorySorting) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(string(t))
|
||||
}
|
||||
|
||||
func (t *SidebarCategorySorting) UnmarshalGraphQL(input interface{}) error {
|
||||
func (t *SidebarCategorySorting) UnmarshalGraphQL(input any) error {
|
||||
chType, ok := input.(string)
|
||||
if !ok {
|
||||
return errors.New("wrong type")
|
||||
|
||||
@@ -1372,7 +1372,7 @@ func (c *Client4) UpdateUserAuth(userId string, userAuth *UserAuth) (*UserAuth,
|
||||
// is true and a valid code is provided. If activate is false, then code is not
|
||||
// required and multi-factor authentication is disabled for the user.
|
||||
func (c *Client4) UpdateUserMfa(userId, code string, activate bool) (*Response, error) {
|
||||
requestBody := make(map[string]interface{})
|
||||
requestBody := make(map[string]any)
|
||||
requestBody["activate"] = activate
|
||||
requestBody["code"] = code
|
||||
|
||||
@@ -1454,7 +1454,7 @@ func (c *Client4) UpdateUserRoles(userId, roles string) (*Response, error) {
|
||||
|
||||
// UpdateUserActive updates status of a user whether active or not.
|
||||
func (c *Client4) UpdateUserActive(userId string, active bool) (*Response, error) {
|
||||
requestBody := make(map[string]interface{})
|
||||
requestBody := make(map[string]any)
|
||||
requestBody["active"] = active
|
||||
r, err := c.DoAPIPut(c.userRoute(userId)+"/active", StringInterfaceToJSON(requestBody))
|
||||
if err != nil {
|
||||
@@ -3292,7 +3292,7 @@ func (c *Client4) PermanentDeleteChannel(channelId string) (*Response, error) {
|
||||
|
||||
// MoveChannel moves the channel to the destination team.
|
||||
func (c *Client4) MoveChannel(channelId, teamId string, force bool) (*Channel, *Response, error) {
|
||||
requestBody := map[string]interface{}{
|
||||
requestBody := map[string]any{
|
||||
"team_id": teamId,
|
||||
"force": force,
|
||||
}
|
||||
@@ -4126,7 +4126,7 @@ func (c *Client4) SearchPostsWithParams(teamId string, params *SearchParameter)
|
||||
|
||||
// SearchPostsWithMatches returns any posts with matching terms string, including.
|
||||
func (c *Client4) SearchPostsWithMatches(teamId string, terms string, isOrSearch bool) (*PostSearchResults, *Response, error) {
|
||||
requestBody := map[string]interface{}{"terms": terms, "is_or_search": isOrSearch}
|
||||
requestBody := map[string]any{"terms": terms, "is_or_search": isOrSearch}
|
||||
var route string
|
||||
if teamId == "" {
|
||||
route = c.postsRoute() + "/search"
|
||||
@@ -4553,7 +4553,7 @@ func (c *Client4) GetOldClientConfig(etag string) (map[string]string, *Response,
|
||||
// GetEnvironmentConfig will retrieve a map mirroring the server configuration where fields
|
||||
// are set to true if the corresponding config setting is set through an environment variable.
|
||||
// Settings that haven't been set through environment variables will be missing from the map.
|
||||
func (c *Client4) GetEnvironmentConfig() (map[string]interface{}, *Response, error) {
|
||||
func (c *Client4) GetEnvironmentConfig() (map[string]any, *Response, error) {
|
||||
r, err := c.DoAPIGet(c.configRoute()+"/environment", "")
|
||||
if err != nil {
|
||||
return nil, BuildResponse(r), err
|
||||
@@ -5140,7 +5140,7 @@ func (c *Client4) GetSamlMetadataFromIdp(samlMetadataURL string) (*SamlMetadataR
|
||||
|
||||
// ResetSamlAuthDataToEmail resets the AuthData field of SAML users to their Email.
|
||||
func (c *Client4) ResetSamlAuthDataToEmail(includeDeleted bool, dryRun bool, userIDs []string) (int64, *Response, error) {
|
||||
params := map[string]interface{}{
|
||||
params := map[string]any{
|
||||
"include_deleted": includeDeleted,
|
||||
"dry_run": dryRun,
|
||||
"user_ids": userIDs,
|
||||
@@ -5262,7 +5262,7 @@ func (c *Client4) GetClusterStatus() ([]*ClusterInfo, *Response, error) {
|
||||
// If includeRemovedMembers is true, then group members who left or were removed from a
|
||||
// synced team/channel will be re-joined; otherwise, they will be excluded.
|
||||
func (c *Client4) SyncLdap(includeRemovedMembers bool) (*Response, error) {
|
||||
reqBody, jsonErr := json.Marshal(map[string]interface{}{
|
||||
reqBody, jsonErr := json.Marshal(map[string]any{
|
||||
"include_removed_members": includeRemovedMembers,
|
||||
})
|
||||
if jsonErr != nil {
|
||||
@@ -5478,7 +5478,7 @@ func (c *Client4) GetGroupsByUserId(userId string) ([]*Group, *Response, error)
|
||||
}
|
||||
|
||||
func (c *Client4) MigrateAuthToLdap(fromAuthService string, matchField string, force bool) (*Response, error) {
|
||||
r, err := c.DoAPIPost(c.usersRoute()+"/migrate_auth/ldap", StringInterfaceToJSON(map[string]interface{}{
|
||||
r, err := c.DoAPIPost(c.usersRoute()+"/migrate_auth/ldap", StringInterfaceToJSON(map[string]any{
|
||||
"from": fromAuthService,
|
||||
"force": force,
|
||||
"match_field": matchField,
|
||||
@@ -5491,7 +5491,7 @@ func (c *Client4) MigrateAuthToLdap(fromAuthService string, matchField string, f
|
||||
}
|
||||
|
||||
func (c *Client4) MigrateAuthToSaml(fromAuthService string, usersMap map[string]string, auto bool) (*Response, error) {
|
||||
r, err := c.DoAPIPost(c.usersRoute()+"/migrate_auth/saml", StringInterfaceToJSON(map[string]interface{}{
|
||||
r, err := c.DoAPIPost(c.usersRoute()+"/migrate_auth/saml", StringInterfaceToJSON(map[string]any{
|
||||
"from": fromAuthService,
|
||||
"auto": auto,
|
||||
"matches": usersMap,
|
||||
@@ -6003,7 +6003,7 @@ func (c *Client4) GetTeamsForRetentionPolicy(policyID string, page, perPage int)
|
||||
|
||||
// SearchTeamsForRetentionPolicy will search the teams to which the specified policy is currently applied.
|
||||
func (c *Client4) SearchTeamsForRetentionPolicy(policyID string, term string) ([]*Team, *Response, error) {
|
||||
body, jsonErr := json.Marshal(map[string]interface{}{"term": term})
|
||||
body, jsonErr := json.Marshal(map[string]any{"term": term})
|
||||
if jsonErr != nil {
|
||||
return nil, nil, NewAppError("SearchTeamsForRetentionPolicy", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -6066,7 +6066,7 @@ func (c *Client4) GetChannelsForRetentionPolicy(policyID string, page, perPage i
|
||||
|
||||
// SearchChannelsForRetentionPolicy will search the channels to which the specified policy is currently applied.
|
||||
func (c *Client4) SearchChannelsForRetentionPolicy(policyID string, term string) (ChannelListWithTeamData, *Response, error) {
|
||||
body, jsonErr := json.Marshal(map[string]interface{}{"term": term})
|
||||
body, jsonErr := json.Marshal(map[string]any{"term": term})
|
||||
if jsonErr != nil {
|
||||
return nil, nil, NewAppError("SearchChannelsForRetentionPolicy", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -7232,7 +7232,7 @@ func (c *Client4) GetServerBusy() (*ServerBusyState, *Response, error) {
|
||||
// RegisterTermsOfServiceAction saves action performed by a user against a specific terms of service.
|
||||
func (c *Client4) RegisterTermsOfServiceAction(userId, termsOfServiceId string, accepted bool) (*Response, error) {
|
||||
url := c.userTermsOfServiceRoute(userId)
|
||||
data := map[string]interface{}{"termsOfServiceId": termsOfServiceId, "accepted": accepted}
|
||||
data := map[string]any{"termsOfServiceId": termsOfServiceId, "accepted": accepted}
|
||||
r, err := c.DoAPIPost(url, StringInterfaceToJSON(data))
|
||||
if err != nil {
|
||||
return BuildResponse(r), err
|
||||
@@ -7274,7 +7274,7 @@ func (c *Client4) GetUserTermsOfService(userId, etag string) (*UserTermsOfServic
|
||||
// CreateTermsOfService creates new terms of service.
|
||||
func (c *Client4) CreateTermsOfService(text, userId string) (*TermsOfService, *Response, error) {
|
||||
url := c.termsOfServiceRoute()
|
||||
data := map[string]interface{}{"text": text}
|
||||
data := map[string]any{"text": text}
|
||||
r, err := c.DoAPIPost(url, StringInterfaceToJSON(data))
|
||||
if err != nil {
|
||||
return nil, BuildResponse(r), err
|
||||
@@ -7573,7 +7573,7 @@ func (c *Client4) GetChannelMemberCountsByGroup(channelID string, includeTimezon
|
||||
|
||||
// RequestTrialLicense will request a trial license and install it in the server
|
||||
func (c *Client4) RequestTrialLicense(users int) (*Response, error) {
|
||||
b, jsonErr := json.Marshal(map[string]interface{}{"users": users, "terms_accepted": true})
|
||||
b, jsonErr := json.Marshal(map[string]any{"users": users, "terms_accepted": true})
|
||||
if jsonErr != nil {
|
||||
return nil, NewAppError("RequestTrialLicense", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ func TestClient4TrimTrailingSlash(t *testing.T) {
|
||||
// https://github.com/mattermost/mattermost-server/v6/issues/8205
|
||||
func TestClient4CreatePost(t *testing.T) {
|
||||
post := &Post{
|
||||
Props: map[string]interface{}{
|
||||
Props: map[string]any{
|
||||
"attachments": []*SlackAttachment{
|
||||
{
|
||||
Actions: []*PostAction{
|
||||
{
|
||||
Integration: &PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"foo": "bar",
|
||||
},
|
||||
URL: "http://foo.com",
|
||||
@@ -58,7 +58,7 @@ func TestClient4CreatePost(t *testing.T) {
|
||||
Actions: []*PostAction{
|
||||
{
|
||||
Integration: &PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"foo": "bar",
|
||||
},
|
||||
URL: "http://foo.com",
|
||||
|
||||
@@ -175,13 +175,13 @@ type Invoice struct {
|
||||
|
||||
// InvoiceLineItem model represents a cloud invoice lineitem tied to an invoice.
|
||||
type InvoiceLineItem struct {
|
||||
PriceID string `json:"price_id"`
|
||||
Total int64 `json:"total"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
PricePerUnit int64 `json:"price_per_unit"`
|
||||
Description string `json:"description"`
|
||||
Type string `json:"type"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
PriceID string `json:"price_id"`
|
||||
Total int64 `json:"total"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
PricePerUnit int64 `json:"price_per_unit"`
|
||||
Description string `json:"description"`
|
||||
Type string `json:"type"`
|
||||
Metadata map[string]any `json:"metadata"`
|
||||
}
|
||||
|
||||
type CWSWebhookPayload struct {
|
||||
|
||||
@@ -54,7 +54,7 @@ type AutocompleteArg struct {
|
||||
// Required determines if argument is optional or not.
|
||||
Required bool
|
||||
// Actual data of the argument (depends on the Type)
|
||||
Data interface{}
|
||||
Data any
|
||||
}
|
||||
|
||||
// AutocompleteTextArg describes text user can input as an argument.
|
||||
@@ -304,7 +304,7 @@ func (a *AutocompleteArg) Equals(arg *AutocompleteArg) bool {
|
||||
|
||||
// UnmarshalJSON will unmarshal argument
|
||||
func (a *AutocompleteArg) UnmarshalJSON(b []byte) error {
|
||||
var arg map[string]interface{}
|
||||
var arg map[string]any
|
||||
if err := json.Unmarshal(b, &arg); err != nil {
|
||||
return errors.Wrapf(err, "Can't unmarshal argument %s", string(b))
|
||||
}
|
||||
@@ -336,7 +336,7 @@ func (a *AutocompleteArg) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
if a.Type == AutocompleteArgTypeText {
|
||||
m, ok := data.(map[string]interface{})
|
||||
m, ok := data.(map[string]any)
|
||||
if !ok {
|
||||
return errors.Errorf("Wrong Data type in the TextInput argument %s", string(b))
|
||||
}
|
||||
@@ -350,18 +350,18 @@ func (a *AutocompleteArg) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
a.Data = &AutocompleteTextArg{Hint: hint, Pattern: pattern}
|
||||
} else if a.Type == AutocompleteArgTypeStaticList {
|
||||
m, ok := data.(map[string]interface{})
|
||||
m, ok := data.(map[string]any)
|
||||
if !ok {
|
||||
return errors.Errorf("Wrong Data type in the StaticList argument %s", string(b))
|
||||
}
|
||||
list, ok := m["PossibleArguments"].([]interface{})
|
||||
list, ok := m["PossibleArguments"].([]any)
|
||||
if !ok {
|
||||
return errors.Errorf("No field PossibleArguments in the StaticList argument %s", string(b))
|
||||
}
|
||||
|
||||
possibleArguments := []AutocompleteListItem{}
|
||||
for i := range list {
|
||||
args, ok := list[i].(map[string]interface{})
|
||||
args, ok := list[i].(map[string]any)
|
||||
if !ok {
|
||||
return errors.Errorf("Wrong AutocompleteStaticListItem type in the StaticList argument %s", string(b))
|
||||
}
|
||||
@@ -387,7 +387,7 @@ func (a *AutocompleteArg) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
a.Data = &AutocompleteStaticListArg{PossibleArguments: possibleArguments}
|
||||
} else if a.Type == AutocompleteArgTypeDynamicList {
|
||||
m, ok := data.(map[string]interface{})
|
||||
m, ok := data.(map[string]any)
|
||||
if !ok {
|
||||
return errors.Errorf("Wrong type in the DynamicList argument %s", string(b))
|
||||
}
|
||||
|
||||
@@ -2736,21 +2736,21 @@ type PluginState struct {
|
||||
}
|
||||
|
||||
type PluginSettings struct {
|
||||
Enable *bool `access:"plugins,write_restrictable"`
|
||||
EnableUploads *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
AllowInsecureDownloadURL *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
EnableHealthCheck *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
Directory *string `access:"plugins,write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
ClientDirectory *string `access:"plugins,write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
Plugins map[string]map[string]interface{} `access:"plugins"` // telemetry: none
|
||||
PluginStates map[string]*PluginState `access:"plugins"` // telemetry: none
|
||||
EnableMarketplace *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
EnableRemoteMarketplace *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
AutomaticPrepackagedPlugins *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
RequirePluginSignature *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
MarketplaceURL *string `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
SignaturePublicKeyFiles []string `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
ChimeraOAuthProxyURL *string `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
Enable *bool `access:"plugins,write_restrictable"`
|
||||
EnableUploads *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
AllowInsecureDownloadURL *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
EnableHealthCheck *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
Directory *string `access:"plugins,write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
ClientDirectory *string `access:"plugins,write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
Plugins map[string]map[string]any `access:"plugins"` // telemetry: none
|
||||
PluginStates map[string]*PluginState `access:"plugins"` // telemetry: none
|
||||
EnableMarketplace *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
EnableRemoteMarketplace *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
AutomaticPrepackagedPlugins *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
RequirePluginSignature *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
MarketplaceURL *string `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
SignaturePublicKeyFiles []string `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
ChimeraOAuthProxyURL *string `access:"plugins,write_restrictable,cloud_restrictable"`
|
||||
}
|
||||
|
||||
func (s *PluginSettings) SetDefaults(ls LogSettings) {
|
||||
@@ -2779,7 +2779,7 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) {
|
||||
}
|
||||
|
||||
if s.Plugins == nil {
|
||||
s.Plugins = make(map[string]map[string]interface{})
|
||||
s.Plugins = make(map[string]map[string]any)
|
||||
}
|
||||
|
||||
if s.PluginStates == nil {
|
||||
@@ -3145,7 +3145,7 @@ func (o *Config) Clone() *Config {
|
||||
func (o *Config) ToJSONFiltered(tagType, tagValue string) ([]byte, error) {
|
||||
filteredConfigMap := structToMapFilteredByTag(*o, tagType, tagValue)
|
||||
for key, value := range filteredConfigMap {
|
||||
v, ok := value.(map[string]interface{})
|
||||
v, ok := value.(map[string]any)
|
||||
if ok && len(v) == 0 {
|
||||
delete(filteredConfigMap, key)
|
||||
}
|
||||
@@ -3275,7 +3275,7 @@ func (o *Config) IsValid() *AppError {
|
||||
}
|
||||
|
||||
if *o.PasswordSettings.MinimumLength < PasswordMinimumLength || *o.PasswordSettings.MinimumLength > PasswordMaximumLength {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.password_length.app_error", map[string]interface{}{"MinLength": PasswordMinimumLength, "MaxLength": PasswordMaximumLength}, "", http.StatusBadRequest)
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.password_length.app_error", map[string]any{"MinLength": PasswordMinimumLength, "MaxLength": PasswordMaximumLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if err := o.RateLimitSettings.isValid(); err != nil {
|
||||
@@ -3342,7 +3342,7 @@ func (s *TeamSettings) isValid() *AppError {
|
||||
}
|
||||
|
||||
if len(*s.SiteName) > SitenameMaxLength {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.sitename_length.app_error", map[string]interface{}{"MaxLength": SitenameMaxLength}, "", http.StatusBadRequest)
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.sitename_length.app_error", map[string]any{"MaxLength": SitenameMaxLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -3402,7 +3402,7 @@ func (s *FileSettings) isValid() *AppError {
|
||||
}
|
||||
|
||||
if *s.MaxImageDecoderConcurrency < -1 || *s.MaxImageDecoderConcurrency == 0 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.image_decoder_concurrency.app_error", map[string]interface{}{"Value": *s.MaxImageDecoderConcurrency}, "", http.StatusBadRequest)
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.image_decoder_concurrency.app_error", map[string]any{"Value": *s.MaxImageDecoderConcurrency}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -3605,7 +3605,7 @@ func (s *ServiceSettings) isValid() *AppError {
|
||||
if len(s.TLSOverwriteCiphers) > 0 {
|
||||
for _, cipher := range s.TLSOverwriteCiphers {
|
||||
if _, ok := ServerTLSSupportedCiphers[cipher]; !ok {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.tls_overwrite_cipher.app_error", map[string]interface{}{"name": cipher}, "", http.StatusBadRequest)
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.tls_overwrite_cipher.app_error", map[string]any{"name": cipher}, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3699,7 +3699,7 @@ func (s *ElasticsearchSettings) isValid() *AppError {
|
||||
|
||||
minBatchSize := 1
|
||||
if *s.BatchSize < minBatchSize {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.bulk_indexing_batch_size.app_error", map[string]interface{}{"BatchSize": minBatchSize}, "", http.StatusBadRequest)
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.bulk_indexing_batch_size.app_error", map[string]any{"BatchSize": minBatchSize}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.RequestTimeoutSeconds < 1 {
|
||||
@@ -3724,7 +3724,7 @@ func (bs *BleveSettings) isValid() *AppError {
|
||||
}
|
||||
minBatchSize := 1
|
||||
if *bs.BatchSize < minBatchSize {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.bleve_search.bulk_indexing_batch_size.app_error", map[string]interface{}{"BatchSize": minBatchSize}, "", http.StatusBadRequest)
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.bleve_search.bulk_indexing_batch_size.app_error", map[string]any{"BatchSize": minBatchSize}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -3801,7 +3801,7 @@ func (s *DisplaySettings) isValid() *AppError {
|
||||
return NewAppError(
|
||||
"Config.IsValid",
|
||||
"model.config.is_valid.display.custom_url_schemes.app_error",
|
||||
map[string]interface{}{"Scheme": scheme},
|
||||
map[string]any{"Scheme": scheme},
|
||||
"",
|
||||
http.StatusBadRequest,
|
||||
)
|
||||
@@ -3911,7 +3911,7 @@ func (o *Config) Sanitize() {
|
||||
|
||||
// structToMapFilteredByTag converts a struct into a map removing those fields that has the tag passed
|
||||
// as argument
|
||||
func structToMapFilteredByTag(t interface{}, typeOfTag, filterTag string) map[string]interface{} {
|
||||
func structToMapFilteredByTag(t any, typeOfTag, filterTag string) map[string]any {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
mlog.Warn("Panicked in structToMapFilteredByTag. This should never happen.", mlog.Any("recover", r))
|
||||
@@ -3925,7 +3925,7 @@ func structToMapFilteredByTag(t interface{}, typeOfTag, filterTag string) map[st
|
||||
return nil
|
||||
}
|
||||
|
||||
out := map[string]interface{}{}
|
||||
out := map[string]any{}
|
||||
|
||||
for i := 0; i < val.NumField(); i++ {
|
||||
field := val.Field(i)
|
||||
@@ -3936,7 +3936,7 @@ func structToMapFilteredByTag(t interface{}, typeOfTag, filterTag string) map[st
|
||||
continue
|
||||
}
|
||||
|
||||
var value interface{}
|
||||
var value any
|
||||
|
||||
switch field.Kind() {
|
||||
case reflect.Struct:
|
||||
|
||||
@@ -1321,12 +1321,12 @@ func TestConfigFilteredByTag(t *testing.T) {
|
||||
cfgMap := structToMapFilteredByTag(c, ConfigAccessTagType, ConfigAccessTagCloudRestrictable)
|
||||
|
||||
// Remove entire sections but the map is still there
|
||||
clusterSettings, ok := cfgMap["SqlSettings"].(map[string]interface{})
|
||||
clusterSettings, ok := cfgMap["SqlSettings"].(map[string]any)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, 0, len(clusterSettings))
|
||||
|
||||
// Some fields are removed if they have the filtering tag
|
||||
serviceSettings, ok := cfgMap["ServiceSettings"].(map[string]interface{})
|
||||
serviceSettings, ok := cfgMap["ServiceSettings"].(map[string]any)
|
||||
require.True(t, ok)
|
||||
_, ok = serviceSettings["ListenAddress"]
|
||||
require.False(t, ok)
|
||||
|
||||
@@ -141,11 +141,11 @@ func (group *Group) IsValidForCreate() *AppError {
|
||||
}
|
||||
|
||||
if l := len(group.DisplayName); l == 0 || l > GroupDisplayNameMaxLength {
|
||||
return NewAppError("Group.IsValidForCreate", "model.group.display_name.app_error", map[string]interface{}{"GroupDisplayNameMaxLength": GroupDisplayNameMaxLength}, "", http.StatusBadRequest)
|
||||
return NewAppError("Group.IsValidForCreate", "model.group.display_name.app_error", map[string]any{"GroupDisplayNameMaxLength": GroupDisplayNameMaxLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(group.Description) > GroupDescriptionMaxLength {
|
||||
return NewAppError("Group.IsValidForCreate", "model.group.description.app_error", map[string]interface{}{"GroupDescriptionMaxLength": GroupDescriptionMaxLength}, "", http.StatusBadRequest)
|
||||
return NewAppError("Group.IsValidForCreate", "model.group.description.app_error", map[string]any{"GroupDescriptionMaxLength": GroupDescriptionMaxLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
isValidSource := false
|
||||
@@ -197,11 +197,11 @@ func (group *Group) IsValidName() *AppError {
|
||||
|
||||
if group.Name == nil {
|
||||
if group.AllowReference {
|
||||
return NewAppError("Group.IsValidName", "model.group.name.app_error", map[string]interface{}{"GroupNameMaxLength": GroupNameMaxLength}, "", http.StatusBadRequest)
|
||||
return NewAppError("Group.IsValidName", "model.group.name.app_error", map[string]any{"GroupNameMaxLength": GroupNameMaxLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
} else {
|
||||
if l := len(*group.Name); l == 0 || l > GroupNameMaxLength {
|
||||
return NewAppError("Group.IsValidName", "model.group.name.invalid_length.app_error", map[string]interface{}{"GroupNameMaxLength": GroupNameMaxLength}, "", http.StatusBadRequest)
|
||||
return NewAppError("Group.IsValidName", "model.group.name.invalid_length.app_error", map[string]any{"GroupNameMaxLength": GroupNameMaxLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if !validGroupnameChars.MatchString(*group.Name) {
|
||||
|
||||
@@ -53,7 +53,7 @@ func (syncable *GroupSyncable) IsValid() *AppError {
|
||||
}
|
||||
|
||||
func (syncable *GroupSyncable) UnmarshalJSON(b []byte) error {
|
||||
var kvp map[string]interface{}
|
||||
var kvp map[string]any
|
||||
err := json.Unmarshal(b, &kvp)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -164,7 +164,7 @@ type PostActionCookie struct {
|
||||
ChannelId string `json:"channel_id,omitempty"`
|
||||
DataSource string `json:"data_source,omitempty"`
|
||||
Integration *PostActionIntegration `json:"integration,omitempty"`
|
||||
RetainProps map[string]interface{} `json:"retain_props,omitempty"`
|
||||
RetainProps map[string]any `json:"retain_props,omitempty"`
|
||||
RemoveProps []string `json:"remove_props,omitempty"`
|
||||
}
|
||||
|
||||
@@ -174,22 +174,22 @@ type PostActionOptions struct {
|
||||
}
|
||||
|
||||
type PostActionIntegration struct {
|
||||
URL string `json:"url,omitempty"`
|
||||
Context map[string]interface{} `json:"context,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
Context map[string]any `json:"context,omitempty"`
|
||||
}
|
||||
|
||||
type PostActionIntegrationRequest struct {
|
||||
UserId string `json:"user_id"`
|
||||
UserName string `json:"user_name"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
ChannelName string `json:"channel_name"`
|
||||
TeamId string `json:"team_id"`
|
||||
TeamName string `json:"team_domain"`
|
||||
PostId string `json:"post_id"`
|
||||
TriggerId string `json:"trigger_id"`
|
||||
Type string `json:"type"`
|
||||
DataSource string `json:"data_source"`
|
||||
Context map[string]interface{} `json:"context,omitempty"`
|
||||
UserId string `json:"user_id"`
|
||||
UserName string `json:"user_name"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
ChannelName string `json:"channel_name"`
|
||||
TeamId string `json:"team_id"`
|
||||
TeamName string `json:"team_domain"`
|
||||
PostId string `json:"post_id"`
|
||||
TriggerId string `json:"trigger_id"`
|
||||
Type string `json:"type"`
|
||||
DataSource string `json:"data_source"`
|
||||
Context map[string]any `json:"context,omitempty"`
|
||||
}
|
||||
|
||||
type PostActionIntegrationResponse struct {
|
||||
@@ -236,15 +236,15 @@ type OpenDialogRequest struct {
|
||||
}
|
||||
|
||||
type SubmitDialogRequest struct {
|
||||
Type string `json:"type"`
|
||||
URL string `json:"url,omitempty"`
|
||||
CallbackId string `json:"callback_id"`
|
||||
State string `json:"state"`
|
||||
UserId string `json:"user_id"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
TeamId string `json:"team_id"`
|
||||
Submission map[string]interface{} `json:"submission"`
|
||||
Cancelled bool `json:"cancelled"`
|
||||
Type string `json:"type"`
|
||||
URL string `json:"url,omitempty"`
|
||||
CallbackId string `json:"callback_id"`
|
||||
State string `json:"state"`
|
||||
UserId string `json:"user_id"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
TeamId string `json:"team_id"`
|
||||
Submission map[string]any `json:"submission"`
|
||||
Cancelled bool `json:"cancelled"`
|
||||
}
|
||||
|
||||
type SubmitDialogResponse struct {
|
||||
@@ -298,7 +298,7 @@ func DecodeAndVerifyTriggerId(triggerId string, s *ecdsa.PrivateKey) (string, st
|
||||
|
||||
now := GetMillis()
|
||||
if now-timestamp > InteractiveDialogTriggerTimeoutMilliseconds {
|
||||
return "", "", NewAppError("DecodeAndVerifyTriggerId", "interactive_message.decode_trigger_id.expired", map[string]interface{}{"Seconds": InteractiveDialogTriggerTimeoutMilliseconds / 1000}, "", http.StatusBadRequest)
|
||||
return "", "", NewAppError("DecodeAndVerifyTriggerId", "interactive_message.decode_trigger_id.expired", map[string]any{"Seconds": InteractiveDialogTriggerTimeoutMilliseconds / 1000}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
signature, err := base64.StdEncoding.DecodeString(split[3])
|
||||
@@ -373,7 +373,7 @@ func AddPostActionCookies(o *Post, secret []byte) *Post {
|
||||
p := o.Clone()
|
||||
|
||||
// retainedProps carry over their value from the old post, including no value
|
||||
retainProps := map[string]interface{}{}
|
||||
retainProps := map[string]any{}
|
||||
removeProps := []string{}
|
||||
for _, key := range PostActionRetainPropKeys {
|
||||
value, ok := p.GetProps()[key]
|
||||
|
||||
@@ -86,8 +86,8 @@ func TestPostActionIntegrationEquals(t *testing.T) {
|
||||
t.Run("equal uncomparable types", func(t *testing.T) {
|
||||
pa1 := &PostAction{
|
||||
Integration: &PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
"a": map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"a": map[string]any{
|
||||
"a": 0,
|
||||
},
|
||||
},
|
||||
@@ -95,8 +95,8 @@ func TestPostActionIntegrationEquals(t *testing.T) {
|
||||
}
|
||||
pa2 := &PostAction{
|
||||
Integration: &PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
"a": map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"a": map[string]any{
|
||||
"a": 0,
|
||||
},
|
||||
},
|
||||
@@ -108,14 +108,14 @@ func TestPostActionIntegrationEquals(t *testing.T) {
|
||||
t.Run("equal comparable types", func(t *testing.T) {
|
||||
pa1 := &PostAction{
|
||||
Integration: &PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"a": "test",
|
||||
},
|
||||
},
|
||||
}
|
||||
pa2 := &PostAction{
|
||||
Integration: &PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"a": "test",
|
||||
},
|
||||
},
|
||||
@@ -126,8 +126,8 @@ func TestPostActionIntegrationEquals(t *testing.T) {
|
||||
t.Run("non-equal types", func(t *testing.T) {
|
||||
pa1 := &PostAction{
|
||||
Integration: &PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
"a": map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"a": map[string]any{
|
||||
"a": 0,
|
||||
},
|
||||
},
|
||||
@@ -135,7 +135,7 @@ func TestPostActionIntegrationEquals(t *testing.T) {
|
||||
}
|
||||
pa2 := &PostAction{
|
||||
Integration: &PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"a": "test",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -22,25 +22,25 @@ type RelationalIntegrityCheckData struct {
|
||||
}
|
||||
|
||||
type IntegrityCheckResult struct {
|
||||
Data interface{} `json:"data"`
|
||||
Err error `json:"err"`
|
||||
Data any `json:"data"`
|
||||
Err error `json:"err"`
|
||||
}
|
||||
|
||||
func (r *IntegrityCheckResult) UnmarshalJSON(b []byte) error {
|
||||
var data map[string]interface{}
|
||||
var data map[string]any
|
||||
if err := json.Unmarshal(b, &data); err != nil {
|
||||
return err
|
||||
}
|
||||
if d, ok := data["data"]; ok && d != nil {
|
||||
var rdata RelationalIntegrityCheckData
|
||||
m := d.(map[string]interface{})
|
||||
m := d.(map[string]any)
|
||||
rdata.ParentName = m["parent_name"].(string)
|
||||
rdata.ChildName = m["child_name"].(string)
|
||||
rdata.ParentIdAttr = m["parent_id_attr"].(string)
|
||||
rdata.ChildIdAttr = m["child_id_attr"].(string)
|
||||
for _, recData := range m["records"].([]interface{}) {
|
||||
for _, recData := range m["records"].([]any) {
|
||||
var record OrphanedRecord
|
||||
m := recData.(map[string]interface{})
|
||||
m := recData.(map[string]any)
|
||||
if val := m["parent_id"]; val != nil {
|
||||
record.ParentId = NewString(val.(string))
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ type Features struct {
|
||||
FutureFeatures *bool `json:"future_features"`
|
||||
}
|
||||
|
||||
func (f *Features) ToMap() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
func (f *Features) ToMap() map[string]any {
|
||||
return map[string]any{
|
||||
"ldap": *f.LDAP,
|
||||
"ldap_groups": *f.LDAPGroups,
|
||||
"mfa": *f.MFA,
|
||||
|
||||
@@ -38,7 +38,7 @@ type LinkMetadata struct {
|
||||
// - *model.PostImage if the linked content is an image
|
||||
// - *opengraph.OpenGraph if the linked content is an HTML document
|
||||
// - nil if the linked content has no metadata
|
||||
Data interface{}
|
||||
Data any
|
||||
}
|
||||
|
||||
// truncateText ensure string is 300 chars, truncate and add ellipsis
|
||||
@@ -142,7 +142,7 @@ func (o *LinkMetadata) DeserializeDataToConcreteType() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var data interface{}
|
||||
var data any
|
||||
var err error
|
||||
|
||||
switch o.Type {
|
||||
|
||||
@@ -79,7 +79,7 @@ type PluginSetting struct {
|
||||
Placeholder string `json:"placeholder" yaml:"placeholder"`
|
||||
|
||||
// The default value of the setting.
|
||||
Default interface{} `json:"default" yaml:"default"`
|
||||
Default any `json:"default" yaml:"default"`
|
||||
|
||||
// For "radio" or "dropdown" settings, this is the list of pre-defined options that the user can choose
|
||||
// from.
|
||||
@@ -183,7 +183,7 @@ type Manifest struct {
|
||||
SettingsSchema *PluginSettingsSchema `json:"settings_schema,omitempty" yaml:"settings_schema,omitempty"`
|
||||
|
||||
// Plugins can store any kind of data in Props to allow other plugins to use it.
|
||||
Props map[string]interface{} `json:"props,omitempty" yaml:"props,omitempty"`
|
||||
Props map[string]any `json:"props,omitempty" yaml:"props,omitempty"`
|
||||
|
||||
// RequiredConfig defines any required server configuration fields for the plugin to function properly.
|
||||
//
|
||||
|
||||
@@ -40,7 +40,7 @@ type MessageExportCursor struct {
|
||||
// PreviewID returns the value of the post's previewed_post prop, if present, or an empty string.
|
||||
func (m *MessageExport) PreviewID() string {
|
||||
var previewID string
|
||||
props := map[string]interface{}{}
|
||||
props := map[string]any{}
|
||||
if m.PostProps != nil && json.Unmarshal([]byte(*m.PostProps), &props) == nil {
|
||||
if val, ok := props[PostPropsPreviewedPost]; ok {
|
||||
previewID = val.(string)
|
||||
|
||||
@@ -22,11 +22,11 @@ type PluginKeyValue struct {
|
||||
|
||||
func (kv *PluginKeyValue) IsValid() *AppError {
|
||||
if kv.PluginId == "" || utf8.RuneCountInString(kv.PluginId) > KeyValuePluginIdMaxRunes {
|
||||
return NewAppError("PluginKeyValue.IsValid", "model.plugin_key_value.is_valid.plugin_id.app_error", map[string]interface{}{"Max": KeyValueKeyMaxRunes, "Min": 0}, "key="+kv.Key, http.StatusBadRequest)
|
||||
return NewAppError("PluginKeyValue.IsValid", "model.plugin_key_value.is_valid.plugin_id.app_error", map[string]any{"Max": KeyValueKeyMaxRunes, "Min": 0}, "key="+kv.Key, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if kv.Key == "" || utf8.RuneCountInString(kv.Key) > KeyValueKeyMaxRunes {
|
||||
return NewAppError("PluginKeyValue.IsValid", "model.plugin_key_value.is_valid.key.app_error", map[string]interface{}{"Max": KeyValueKeyMaxRunes, "Min": 0}, "key="+kv.Key, http.StatusBadRequest)
|
||||
return NewAppError("PluginKeyValue.IsValid", "model.plugin_key_value.is_valid.key.app_error", map[string]any{"Max": KeyValueKeyMaxRunes, "Min": 0}, "key="+kv.Key, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -411,7 +411,7 @@ func (o *Post) PreSave() {
|
||||
|
||||
func (o *Post) PreCommit() {
|
||||
if o.GetProps() == nil {
|
||||
o.SetProps(make(map[string]interface{}))
|
||||
o.SetProps(make(map[string]any))
|
||||
}
|
||||
|
||||
if o.Filenames == nil {
|
||||
@@ -430,14 +430,14 @@ func (o *Post) PreCommit() {
|
||||
|
||||
func (o *Post) MakeNonNil() {
|
||||
if o.GetProps() == nil {
|
||||
o.SetProps(make(map[string]interface{}))
|
||||
o.SetProps(make(map[string]any))
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Post) DelProp(key string) {
|
||||
o.propsMu.Lock()
|
||||
defer o.propsMu.Unlock()
|
||||
propsCopy := make(map[string]interface{}, len(o.Props)-1)
|
||||
propsCopy := make(map[string]any, len(o.Props)-1)
|
||||
for k, v := range o.Props {
|
||||
propsCopy[k] = v
|
||||
}
|
||||
@@ -445,10 +445,10 @@ func (o *Post) DelProp(key string) {
|
||||
o.Props = propsCopy
|
||||
}
|
||||
|
||||
func (o *Post) AddProp(key string, value interface{}) {
|
||||
func (o *Post) AddProp(key string, value any) {
|
||||
o.propsMu.Lock()
|
||||
defer o.propsMu.Unlock()
|
||||
propsCopy := make(map[string]interface{}, len(o.Props)+1)
|
||||
propsCopy := make(map[string]any, len(o.Props)+1)
|
||||
for k, v := range o.Props {
|
||||
propsCopy[k] = v
|
||||
}
|
||||
@@ -468,7 +468,7 @@ func (o *Post) SetProps(props StringInterface) {
|
||||
o.Props = props
|
||||
}
|
||||
|
||||
func (o *Post) GetProp(key string) interface{} {
|
||||
func (o *Post) GetProp(key string) any {
|
||||
o.propsMu.RLock()
|
||||
defer o.propsMu.RUnlock()
|
||||
return o.Props[key]
|
||||
@@ -567,7 +567,7 @@ func (o *Post) Attachments() []*SlackAttachment {
|
||||
return attachments
|
||||
}
|
||||
var ret []*SlackAttachment
|
||||
if attachments, ok := o.GetProp("attachments").([]interface{}); ok {
|
||||
if attachments, ok := o.GetProp("attachments").([]any); ok {
|
||||
for _, attachment := range attachments {
|
||||
if enc, err := json.Marshal(attachment); err == nil {
|
||||
var decoded SlackAttachment
|
||||
@@ -648,7 +648,7 @@ func RewriteImageURLs(message string, f func(string) string) string {
|
||||
|
||||
var ranges []markdown.Range
|
||||
|
||||
markdown.Inspect(message, func(blockOrInline interface{}) bool {
|
||||
markdown.Inspect(message, func(blockOrInline any) bool {
|
||||
switch v := blockOrInline.(type) {
|
||||
case *markdown.ReferenceImage:
|
||||
ranges = append(ranges, v.ReferenceDefinition.RawDestination)
|
||||
|
||||
@@ -21,5 +21,5 @@ type PostEmbed struct {
|
||||
URL string `json:"url,omitempty"`
|
||||
|
||||
// Any additional data for the embedded content. Only used for OpenGraph embeds.
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
Data any `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ func TestPost_AttachmentsEqual(t *testing.T) {
|
||||
},
|
||||
Integration: &PostActionIntegration{
|
||||
URL: "http://localhost",
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"context": "foobar",
|
||||
"test": 123,
|
||||
},
|
||||
@@ -299,7 +299,7 @@ func TestPost_AttachmentsEqual(t *testing.T) {
|
||||
},
|
||||
Integration: &PostActionIntegration{
|
||||
URL: "http://localhost",
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"context": "foobar",
|
||||
"test": 123,
|
||||
},
|
||||
@@ -324,7 +324,7 @@ func TestPost_AttachmentsEqual(t *testing.T) {
|
||||
},
|
||||
Integration: &PostActionIntegration{
|
||||
URL: "http://localhost",
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"context": "foobar",
|
||||
"test": "mattermost",
|
||||
},
|
||||
@@ -346,7 +346,7 @@ func TestPost_AttachmentsEqual(t *testing.T) {
|
||||
},
|
||||
Integration: &PostActionIntegration{
|
||||
URL: "http://localhost",
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
"context": "foobar",
|
||||
"test": 123,
|
||||
},
|
||||
@@ -848,7 +848,7 @@ func TestPostPatchDisableMentionHighlights(t *testing.T) {
|
||||
|
||||
func TestPostAttachments(t *testing.T) {
|
||||
p := &Post{
|
||||
Props: map[string]interface{}{
|
||||
Props: map[string]any{
|
||||
"attachments": []byte(`[{
|
||||
"actions" : {null}
|
||||
}]
|
||||
@@ -857,17 +857,17 @@ func TestPostAttachments(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("empty actions", func(t *testing.T) {
|
||||
p.Props["attachments"] = []interface{}{
|
||||
map[string]interface{}{"actions": []interface{}{}},
|
||||
p.Props["attachments"] = []any{
|
||||
map[string]any{"actions": []any{}},
|
||||
}
|
||||
attachments := p.Attachments()
|
||||
require.Empty(t, attachments[0].Actions)
|
||||
})
|
||||
|
||||
t.Run("a couple of actions", func(t *testing.T) {
|
||||
p.Props["attachments"] = []interface{}{
|
||||
map[string]interface{}{"actions": []interface{}{
|
||||
map[string]interface{}{"id": "test1"}, map[string]interface{}{"id": "test2"}},
|
||||
p.Props["attachments"] = []any{
|
||||
map[string]any{"actions": []any{
|
||||
map[string]any{"id": "test1"}, map[string]any{"id": "test2"}},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -878,9 +878,9 @@ func TestPostAttachments(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should ignore null actions", func(t *testing.T) {
|
||||
p.Props["attachments"] = []interface{}{
|
||||
map[string]interface{}{"actions": []interface{}{
|
||||
map[string]interface{}{"id": "test1"}, nil, map[string]interface{}{"id": "test2"}, nil, nil},
|
||||
p.Props["attachments"] = []any{
|
||||
map[string]any{"actions": []any{
|
||||
map[string]any{"id": "test1"}, nil, map[string]any{"id": "test2"}, nil, nil},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -891,11 +891,11 @@ func TestPostAttachments(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("nil fields", func(t *testing.T) {
|
||||
p.Props["attachments"] = []interface{}{
|
||||
map[string]interface{}{"fields": []interface{}{
|
||||
map[string]interface{}{"value": ":emoji1:"},
|
||||
p.Props["attachments"] = []any{
|
||||
map[string]any{"fields": []any{
|
||||
map[string]any{"value": ":emoji1:"},
|
||||
nil,
|
||||
map[string]interface{}{"value": ":emoji2:"},
|
||||
map[string]any{"value": ":emoji2:"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -40,19 +40,19 @@ func (n *ProductNotice) TeamAdminOnly() bool {
|
||||
}
|
||||
|
||||
type Conditions struct {
|
||||
Audience *NoticeAudience `json:"audience,omitempty"`
|
||||
ClientType *NoticeClientType `json:"clientType,omitempty"` // Only show the notice on specific clients. Defaults to 'all'
|
||||
DesktopVersion []string `json:"desktopVersion,omitempty"` // What desktop client versions does this notice apply to.; Format: semver ranges (https://devhints.io/semver); Example: [">=1.2.3 < ~2.4.x"]; Example: ["<v5.19", "v5.20-v5.22"]
|
||||
DisplayDate *string `json:"displayDate,omitempty"` // When to display the notice.; Examples:; "2020-03-01T00:00:00Z" - show on specified date; ">= 2020-03-01T00:00:00Z" - show after specified date; "< 2020-03-01T00:00:00Z" - show before the specified date; "> 2020-03-01T00:00:00Z <= 2020-04-01T00:00:00Z" - show only between the specified dates
|
||||
InstanceType *NoticeInstanceType `json:"instanceType,omitempty"`
|
||||
MobileVersion []string `json:"mobileVersion,omitempty"` // What mobile client versions does this notice apply to.; Format: semver ranges (https://devhints.io/semver); Example: [">=1.2.3 < ~2.4.x"]; Example: ["<v5.19", "v5.20-v5.22"]
|
||||
NumberOfPosts *int64 `json:"numberOfPosts,omitempty"` // Only show the notice when server has more than specified number of posts
|
||||
NumberOfUsers *int64 `json:"numberOfUsers,omitempty"` // Only show the notice when server has more than specified number of users
|
||||
ServerConfig map[string]interface{} `json:"serverConfig,omitempty"` // Map of mattermost server config paths and their values. Notice will be displayed only if; the values match the target server config; Example: serverConfig: { "PluginSettings.Enable": true, "GuestAccountsSettings.Enable":; false }
|
||||
ServerVersion []string `json:"serverVersion,omitempty"` // What server versions does this notice apply to.; Format: semver ranges (https://devhints.io/semver); Example: [">=1.2.3 < ~2.4.x"]; Example: ["<v5.19", "v5.20-v5.22"]
|
||||
Sku *NoticeSKU `json:"sku,omitempty"`
|
||||
UserConfig map[string]interface{} `json:"userConfig,omitempty"` // Map of user's settings and their values. Notice will be displayed only if the values; match the viewing users' config; Example: userConfig: { "new_sidebar.disabled": true }
|
||||
DeprecatingDependency *ExternalDependency `json:"deprecating_dependency,omitempty"` // External dependency which is going to be deprecated
|
||||
Audience *NoticeAudience `json:"audience,omitempty"`
|
||||
ClientType *NoticeClientType `json:"clientType,omitempty"` // Only show the notice on specific clients. Defaults to 'all'
|
||||
DesktopVersion []string `json:"desktopVersion,omitempty"` // What desktop client versions does this notice apply to.; Format: semver ranges (https://devhints.io/semver); Example: [">=1.2.3 < ~2.4.x"]; Example: ["<v5.19", "v5.20-v5.22"]
|
||||
DisplayDate *string `json:"displayDate,omitempty"` // When to display the notice.; Examples:; "2020-03-01T00:00:00Z" - show on specified date; ">= 2020-03-01T00:00:00Z" - show after specified date; "< 2020-03-01T00:00:00Z" - show before the specified date; "> 2020-03-01T00:00:00Z <= 2020-04-01T00:00:00Z" - show only between the specified dates
|
||||
InstanceType *NoticeInstanceType `json:"instanceType,omitempty"`
|
||||
MobileVersion []string `json:"mobileVersion,omitempty"` // What mobile client versions does this notice apply to.; Format: semver ranges (https://devhints.io/semver); Example: [">=1.2.3 < ~2.4.x"]; Example: ["<v5.19", "v5.20-v5.22"]
|
||||
NumberOfPosts *int64 `json:"numberOfPosts,omitempty"` // Only show the notice when server has more than specified number of posts
|
||||
NumberOfUsers *int64 `json:"numberOfUsers,omitempty"` // Only show the notice when server has more than specified number of users
|
||||
ServerConfig map[string]any `json:"serverConfig,omitempty"` // Map of mattermost server config paths and their values. Notice will be displayed only if; the values match the target server config; Example: serverConfig: { "PluginSettings.Enable": true, "GuestAccountsSettings.Enable":; false }
|
||||
ServerVersion []string `json:"serverVersion,omitempty"` // What server versions does this notice apply to.; Format: semver ranges (https://devhints.io/semver); Example: [">=1.2.3 < ~2.4.x"]; Example: ["<v5.19", "v5.20-v5.22"]
|
||||
Sku *NoticeSKU `json:"sku,omitempty"`
|
||||
UserConfig map[string]any `json:"userConfig,omitempty"` // Map of user's settings and their values. Notice will be displayed only if the values; match the viewing users' config; Example: userConfig: { "new_sidebar.disabled": true }
|
||||
DeprecatingDependency *ExternalDependency `json:"deprecating_dependency,omitempty"` // External dependency which is going to be deprecated
|
||||
}
|
||||
|
||||
type NoticeMessageInternal struct {
|
||||
|
||||
@@ -194,7 +194,7 @@ func (m RemoteClusterMsg) IsValid() *AppError {
|
||||
}
|
||||
|
||||
if len(m.Payload) == 0 {
|
||||
return NewAppError("RemoteClusterMsg.IsValid", "api.context.invalid_body_param.app_error", map[string]interface{}{"Name": "PayLoad"}, "", http.StatusBadRequest)
|
||||
return NewAppError("RemoteClusterMsg.IsValid", "api.context.invalid_body_param.app_error", map[string]any{"Name": "PayLoad"}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -97,7 +97,7 @@ func (s *Session) IsValid() *AppError {
|
||||
|
||||
if len(s.Roles) > UserRolesMaxLength {
|
||||
return NewAppError("Session.IsValid", "model.session.is_valid.roles_limit.app_error",
|
||||
map[string]interface{}{"Limit": UserRolesMaxLength}, "session_id="+s.Id, http.StatusBadRequest)
|
||||
map[string]any{"Limit": UserRolesMaxLength}, "session_id="+s.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -26,7 +26,7 @@ type SlackAttachment struct {
|
||||
ThumbURL string `json:"thumb_url"`
|
||||
Footer string `json:"footer"`
|
||||
FooterIcon string `json:"footer_icon"`
|
||||
Timestamp interface{} `json:"ts"` // This is either a string or an int64
|
||||
Timestamp any `json:"ts"` // This is either a string or an int64
|
||||
Actions []*PostAction `json:"actions,omitempty"`
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func (s *SlackAttachment) Equals(input *SlackAttachment) bool {
|
||||
|
||||
type SlackAttachmentField struct {
|
||||
Title string `json:"title"`
|
||||
Value interface{} `json:"value"`
|
||||
Value any `json:"value"`
|
||||
Short SlackCompatibleBool `json:"short"`
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ func TestParseSlackAttachment(t *testing.T) {
|
||||
|
||||
expectedPost := &Post{
|
||||
Type: PostTypeSlackAttachment,
|
||||
Props: map[string]interface{}{
|
||||
Props: map[string]any{
|
||||
"attachments": []*SlackAttachment{},
|
||||
},
|
||||
}
|
||||
@@ -35,7 +35,7 @@ func TestParseSlackAttachment(t *testing.T) {
|
||||
|
||||
expectedPost := &Post{
|
||||
Type: PostTypeSlackAttachment,
|
||||
Props: map[string]interface{}{
|
||||
Props: map[string]any{
|
||||
"attachments": []*SlackAttachment{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ func StatusListToJSON(u []*Status) ([]byte, error) {
|
||||
return json.Marshal(list)
|
||||
}
|
||||
|
||||
func StatusMapToInterfaceMap(statusMap map[string]*Status) map[string]interface{} {
|
||||
interfaceMap := map[string]interface{}{}
|
||||
func StatusMapToInterfaceMap(statusMap map[string]*Status) map[string]any {
|
||||
interfaceMap := map[string]any{}
|
||||
for _, s := range statusMap {
|
||||
// Omitted statues mean offline
|
||||
if s.Status != StatusOffline {
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestStatusListToJSON(t *testing.T) {
|
||||
jsonStatuses, err := StatusListToJSON(statuses)
|
||||
assert.NoError(t, err)
|
||||
|
||||
var dat []map[string]interface{}
|
||||
var dat []map[string]any
|
||||
if err := json.Unmarshal(jsonStatuses, &dat); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ func (o *TeamMember) IsValid() *AppError {
|
||||
|
||||
if len(o.Roles) > UserRolesMaxLength {
|
||||
return NewAppError("TeamMember.IsValid", "model.team_member.is_valid.roles_limit.app_error",
|
||||
map[string]interface{}{"Limit": UserRolesMaxLength}, "", http.StatusBadRequest)
|
||||
map[string]any{"Limit": UserRolesMaxLength}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -42,7 +42,7 @@ func InvalidTermsOfServiceError(fieldName string, termsOfServiceId string) *AppE
|
||||
if termsOfServiceId != "" {
|
||||
details = "terms_of_service_id=" + termsOfServiceId
|
||||
}
|
||||
return NewAppError("TermsOfService.IsValid", id, map[string]interface{}{"MaxLength": PostMessageMaxRunesV2}, details, http.StatusBadRequest)
|
||||
return NewAppError("TermsOfService.IsValid", id, map[string]any{"MaxLength": PostMessageMaxRunesV2}, details, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
func (t *TermsOfService) PreSave() {
|
||||
|
||||
@@ -335,7 +335,7 @@ func (u *User) IsValid() *AppError {
|
||||
|
||||
if len(u.Roles) > UserRolesMaxLength {
|
||||
return NewAppError("User.IsValid", "model.user.is_valid.roles_limit.app_error",
|
||||
map[string]interface{}{"Limit": UserRolesMaxLength}, "user_id="+u.Id, http.StatusBadRequest)
|
||||
map[string]any{"Limit": UserRolesMaxLength}, "user_id="+u.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -36,7 +36,7 @@ const (
|
||||
BinaryParamKey = "MM_BINARY_PARAMETERS"
|
||||
)
|
||||
|
||||
type StringInterface map[string]interface{}
|
||||
type StringInterface map[string]any
|
||||
type StringArray []string
|
||||
|
||||
func (sa StringArray) Remove(input string) StringArray {
|
||||
@@ -86,7 +86,7 @@ func (sa StringArray) Value() (driver.Value, error) {
|
||||
}
|
||||
|
||||
// Scan converts database column value to StringArray
|
||||
func (sa *StringArray) Scan(value interface{}) error {
|
||||
func (sa *StringArray) Scan(value any) error {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func (sa *StringArray) Scan(value interface{}) error {
|
||||
}
|
||||
|
||||
// Scan converts database column value to StringMap
|
||||
func (m *StringMap) Scan(value interface{}) error {
|
||||
func (m *StringMap) Scan(value any) error {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -148,7 +148,7 @@ func (m StringMap) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal((map[string]string)(m))
|
||||
}
|
||||
|
||||
func (m *StringMap) UnmarshalGraphQL(input interface{}) error {
|
||||
func (m *StringMap) UnmarshalGraphQL(input any) error {
|
||||
json, ok := input.(map[string]string)
|
||||
if !ok {
|
||||
return errors.New("wrong type")
|
||||
@@ -158,7 +158,7 @@ func (m *StringMap) UnmarshalGraphQL(input interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (si *StringInterface) Scan(value interface{}) error {
|
||||
func (si *StringInterface) Scan(value any) error {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -203,7 +203,7 @@ type AppError struct {
|
||||
StatusCode int `json:"status_code,omitempty"` // The http status code
|
||||
Where string `json:"-"` // The function where it happened in the form of Struct.Func
|
||||
IsOAuth bool `json:"is_oauth,omitempty"` // Whether the error is OAuth specific
|
||||
params map[string]interface{}
|
||||
params map[string]any
|
||||
}
|
||||
|
||||
func (er *AppError) Error() string {
|
||||
@@ -254,7 +254,7 @@ func AppErrorFromJSON(data io.Reader) *AppError {
|
||||
return &er
|
||||
}
|
||||
|
||||
func NewAppError(where string, id string, params map[string]interface{}, details string, status int) *AppError {
|
||||
func NewAppError(where string, id string, params map[string]any, details string, status int) *AppError {
|
||||
ap := &AppError{}
|
||||
ap.Id = id
|
||||
ap.params = params
|
||||
@@ -391,10 +391,10 @@ func ArrayFromJSON(data io.Reader) []string {
|
||||
return objmap
|
||||
}
|
||||
|
||||
func ArrayFromInterface(data interface{}) []string {
|
||||
func ArrayFromInterface(data any) []string {
|
||||
stringArray := []string{}
|
||||
|
||||
dataArray, ok := data.([]interface{})
|
||||
dataArray, ok := data.([]any)
|
||||
if !ok {
|
||||
return stringArray
|
||||
}
|
||||
@@ -408,23 +408,23 @@ func ArrayFromInterface(data interface{}) []string {
|
||||
return stringArray
|
||||
}
|
||||
|
||||
func StringInterfaceToJSON(objmap map[string]interface{}) string {
|
||||
func StringInterfaceToJSON(objmap map[string]any) string {
|
||||
b, _ := json.Marshal(objmap)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func StringInterfaceFromJSON(data io.Reader) map[string]interface{} {
|
||||
func StringInterfaceFromJSON(data io.Reader) map[string]any {
|
||||
decoder := json.NewDecoder(data)
|
||||
|
||||
var objmap map[string]interface{}
|
||||
var objmap map[string]any
|
||||
if err := decoder.Decode(&objmap); err != nil {
|
||||
return make(map[string]interface{})
|
||||
return make(map[string]any)
|
||||
}
|
||||
return objmap
|
||||
}
|
||||
|
||||
// ToJSON serializes an arbitrary data type to JSON, discarding the error.
|
||||
func ToJSON(v interface{}) []byte {
|
||||
func ToJSON(v any) []byte {
|
||||
b, _ := json.Marshal(v)
|
||||
return b
|
||||
}
|
||||
@@ -531,7 +531,7 @@ func IsValidAlphaNumHyphenUnderscorePlus(s string) bool {
|
||||
return validSimpleAlphaNumHyphenUnderscorePlus.MatchString(s)
|
||||
}
|
||||
|
||||
func Etag(parts ...interface{}) string {
|
||||
func Etag(parts ...any) string {
|
||||
|
||||
etag := CurrentVersion
|
||||
|
||||
|
||||
@@ -621,7 +621,7 @@ func TestNowhereNil(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
Description string
|
||||
Value interface{}
|
||||
Value any
|
||||
Expected bool
|
||||
}{
|
||||
{
|
||||
@@ -770,7 +770,7 @@ func TestNowhereNil(t *testing.T) {
|
||||
|
||||
// checkNowhereNil checks that the given interface value is not nil, and if a struct, that all of
|
||||
// its public fields are also nowhere nil
|
||||
func checkNowhereNil(t *testing.T, name string, value interface{}) bool {
|
||||
func checkNowhereNil(t *testing.T, name string, value any) bool {
|
||||
if value == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ const (
|
||||
|
||||
type writeMessage struct {
|
||||
msgType msgType
|
||||
data interface{}
|
||||
data any
|
||||
}
|
||||
|
||||
const avgReadMsgSizeBytes = 1024
|
||||
@@ -111,7 +111,7 @@ func makeClient(dialer *websocket.Dialer, url, connectURL, authToken string, hea
|
||||
client.configurePingHandling()
|
||||
go client.writer()
|
||||
|
||||
client.SendMessage(WebsocketAuthenticationChallenge, map[string]interface{}{"token": authToken})
|
||||
client.SendMessage(WebsocketAuthenticationChallenge, map[string]any{"token": authToken})
|
||||
|
||||
return client, nil
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func (wsc *WebSocketClient) ConnectWithDialer(dialer *websocket.Dialer) *AppErro
|
||||
wsc.EventChannel = make(chan *WebSocketEvent, 100)
|
||||
wsc.ResponseChannel = make(chan *WebSocketResponse, 100)
|
||||
|
||||
wsc.SendMessage(WebsocketAuthenticationChallenge, map[string]interface{}{"token": wsc.AuthToken})
|
||||
wsc.SendMessage(WebsocketAuthenticationChallenge, map[string]any{"token": wsc.AuthToken})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -268,7 +268,7 @@ func (wsc *WebSocketClient) Listen() {
|
||||
}()
|
||||
}
|
||||
|
||||
func (wsc *WebSocketClient) SendMessage(action string, data map[string]interface{}) {
|
||||
func (wsc *WebSocketClient) SendMessage(action string, data map[string]any) {
|
||||
req := &WebSocketRequest{}
|
||||
req.Seq = wsc.Sequence
|
||||
req.Action = action
|
||||
@@ -281,7 +281,7 @@ func (wsc *WebSocketClient) SendMessage(action string, data map[string]interface
|
||||
}
|
||||
}
|
||||
|
||||
func (wsc *WebSocketClient) SendBinaryMessage(action string, data map[string]interface{}) error {
|
||||
func (wsc *WebSocketClient) SendBinaryMessage(action string, data map[string]any) error {
|
||||
req := &WebSocketRequest{}
|
||||
req.Seq = wsc.Sequence
|
||||
req.Action = action
|
||||
@@ -304,7 +304,7 @@ func (wsc *WebSocketClient) SendBinaryMessage(action string, data map[string]int
|
||||
// UserTyping will push a user_typing event out to all connected users
|
||||
// who are in the specified channel
|
||||
func (wsc *WebSocketClient) UserTyping(channelId, parentId string) {
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"channel_id": channelId,
|
||||
"parent_id": parentId,
|
||||
}
|
||||
@@ -320,7 +320,7 @@ func (wsc *WebSocketClient) GetStatuses() {
|
||||
// GetStatusesByIds will fetch certain user statuses based on ids and return
|
||||
// a map of string statuses using user id as the key
|
||||
func (wsc *WebSocketClient) GetStatusesByIds(userIds []string) {
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"user_ids": userIds,
|
||||
}
|
||||
wsc.SendMessage("get_statuses_by_ids", data)
|
||||
|
||||
@@ -167,7 +167,7 @@ func TestWebSocketClose(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func binaryWebsocketHandler(t *testing.T, clientData map[string]interface{}, doneCh chan struct{}) http.HandlerFunc {
|
||||
func binaryWebsocketHandler(t *testing.T, clientData map[string]any, doneCh chan struct{}) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, req *http.Request) {
|
||||
defer close(doneCh)
|
||||
upgrader := &websocket.Upgrader{
|
||||
@@ -194,7 +194,7 @@ func binaryWebsocketHandler(t *testing.T, clientData map[string]interface{}, don
|
||||
}
|
||||
|
||||
func TestWebSocketSendBinaryMessage(t *testing.T) {
|
||||
clientData := map[string]interface{}{
|
||||
clientData := map[string]any{
|
||||
"data": []byte("some data to send as binary"),
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ func TestWebSocketSendBinaryMessage(t *testing.T) {
|
||||
cli.Listen()
|
||||
defer cli.Close()
|
||||
|
||||
err = cli.SendBinaryMessage("binaryAction", map[string]interface{}{
|
||||
err = cli.SendBinaryMessage("binaryAction", map[string]any{
|
||||
"unmarshable": func() {},
|
||||
})
|
||||
require.Error(t, err)
|
||||
|
||||
@@ -152,15 +152,15 @@ func (p *precomputedWebSocketEventJSON) copy() *precomputedWebSocketEventJSON {
|
||||
|
||||
// webSocketEventJSON mirrors WebSocketEvent to make some of its unexported fields serializable
|
||||
type webSocketEventJSON struct {
|
||||
Event string `json:"event"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
Broadcast *WebsocketBroadcast `json:"broadcast"`
|
||||
Sequence int64 `json:"seq"`
|
||||
Event string `json:"event"`
|
||||
Data map[string]any `json:"data"`
|
||||
Broadcast *WebsocketBroadcast `json:"broadcast"`
|
||||
Sequence int64 `json:"seq"`
|
||||
}
|
||||
|
||||
type WebSocketEvent struct {
|
||||
event string
|
||||
data map[string]interface{}
|
||||
data map[string]any
|
||||
broadcast *WebsocketBroadcast
|
||||
sequence int64
|
||||
precomputedJSON *precomputedWebSocketEventJSON
|
||||
@@ -181,14 +181,14 @@ func (ev *WebSocketEvent) PrecomputeJSON() *WebSocketEvent {
|
||||
return copy
|
||||
}
|
||||
|
||||
func (ev *WebSocketEvent) Add(key string, value interface{}) {
|
||||
func (ev *WebSocketEvent) Add(key string, value any) {
|
||||
ev.data[key] = value
|
||||
}
|
||||
|
||||
func NewWebSocketEvent(event, teamId, channelId, userId string, omitUsers map[string]bool) *WebSocketEvent {
|
||||
return &WebSocketEvent{
|
||||
event: event,
|
||||
data: make(map[string]interface{}),
|
||||
data: make(map[string]any),
|
||||
broadcast: &WebsocketBroadcast{
|
||||
TeamId: teamId,
|
||||
ChannelId: channelId,
|
||||
@@ -209,9 +209,9 @@ func (ev *WebSocketEvent) Copy() *WebSocketEvent {
|
||||
}
|
||||
|
||||
func (ev *WebSocketEvent) DeepCopy() *WebSocketEvent {
|
||||
var dataCopy map[string]interface{}
|
||||
var dataCopy map[string]any
|
||||
if ev.data != nil {
|
||||
dataCopy = make(map[string]interface{}, len(ev.data))
|
||||
dataCopy = make(map[string]any, len(ev.data))
|
||||
for k, v := range ev.data {
|
||||
dataCopy[k] = v
|
||||
}
|
||||
@@ -227,7 +227,7 @@ func (ev *WebSocketEvent) DeepCopy() *WebSocketEvent {
|
||||
return copy
|
||||
}
|
||||
|
||||
func (ev *WebSocketEvent) GetData() map[string]interface{} {
|
||||
func (ev *WebSocketEvent) GetData() map[string]any {
|
||||
return ev.data
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ func (ev *WebSocketEvent) SetEvent(event string) *WebSocketEvent {
|
||||
return copy
|
||||
}
|
||||
|
||||
func (ev *WebSocketEvent) SetData(data map[string]interface{}) *WebSocketEvent {
|
||||
func (ev *WebSocketEvent) SetData(data map[string]any) *WebSocketEvent {
|
||||
copy := ev.Copy()
|
||||
copy.data = data
|
||||
return copy
|
||||
@@ -308,7 +308,7 @@ func WebSocketEventFromJSON(data io.Reader) (*WebSocketEvent, error) {
|
||||
ev.event = o.Event
|
||||
if u, ok := o.Data["user"]; ok {
|
||||
// We need to convert to and from JSON again
|
||||
// because the user is in the form of a map[string]interface{}.
|
||||
// because the user is in the form of a map[string]any.
|
||||
buf, err := json.Marshal(u)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -330,17 +330,17 @@ func WebSocketEventFromJSON(data io.Reader) (*WebSocketEvent, error) {
|
||||
// for a request made to the server. This is available through the ResponseChannel
|
||||
// channel in WebSocketClient.
|
||||
type WebSocketResponse struct {
|
||||
Status string `json:"status"` // The status of the response. For example: OK, FAIL.
|
||||
SeqReply int64 `json:"seq_reply,omitempty"` // A counter which is incremented for every response sent.
|
||||
Data map[string]interface{} `json:"data,omitempty"` // The data contained in the response.
|
||||
Error *AppError `json:"error,omitempty"` // A field that is set if any error has occurred.
|
||||
Status string `json:"status"` // The status of the response. For example: OK, FAIL.
|
||||
SeqReply int64 `json:"seq_reply,omitempty"` // A counter which is incremented for every response sent.
|
||||
Data map[string]any `json:"data,omitempty"` // The data contained in the response.
|
||||
Error *AppError `json:"error,omitempty"` // A field that is set if any error has occurred.
|
||||
}
|
||||
|
||||
func (m *WebSocketResponse) Add(key string, value interface{}) {
|
||||
func (m *WebSocketResponse) Add(key string, value any) {
|
||||
m.Data[key] = value
|
||||
}
|
||||
|
||||
func NewWebSocketResponse(status string, seqReply int64, data map[string]interface{}) *WebSocketResponse {
|
||||
func NewWebSocketResponse(status string, seqReply int64, data map[string]any) *WebSocketResponse {
|
||||
return &WebSocketResponse{Status: status, SeqReply: seqReply, Data: data}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ func TestWebSocketEventImmutable(t *testing.T) {
|
||||
require.NotEqual(t, m.GetBroadcast(), new.GetBroadcast())
|
||||
require.Equal(t, new.GetBroadcast(), broadcast)
|
||||
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"key": "val",
|
||||
"key2": "val2",
|
||||
}
|
||||
@@ -85,12 +85,12 @@ func TestWebSocketEventFromJSON(t *testing.T) {
|
||||
require.NotNil(t, ev, "should have parsed")
|
||||
require.Equal(t, ev.EventType(), "test")
|
||||
require.Equal(t, ev.GetSequence(), int64(45))
|
||||
require.Equal(t, ev.data, map[string]interface{}{"key": "val"})
|
||||
require.Equal(t, ev.data, map[string]any{"key": "val"})
|
||||
require.Equal(t, ev.GetBroadcast(), &WebsocketBroadcast{UserId: "userid"})
|
||||
}
|
||||
|
||||
func TestWebSocketResponse(t *testing.T) {
|
||||
m := NewWebSocketResponse("OK", 1, map[string]interface{}{})
|
||||
m := NewWebSocketResponse("OK", 1, map[string]any{})
|
||||
e := NewWebSocketError(1, &AppError{})
|
||||
m.Add("RootId", NewId())
|
||||
json, err := m.ToJSON()
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
// WebSocketRequest represents a request made to the server through a websocket.
|
||||
type WebSocketRequest struct {
|
||||
// Client-provided fields
|
||||
Seq int64 `json:"seq" msgpack:"seq"` // A counter which is incremented for every request made.
|
||||
Action string `json:"action" msgpack:"action"` // The action to perform for a request. For example: get_statuses, user_typing.
|
||||
Data map[string]interface{} `json:"data" msgpack:"data"` // The metadata for an action.
|
||||
Seq int64 `json:"seq" msgpack:"seq"` // A counter which is incremented for every request made.
|
||||
Action string `json:"action" msgpack:"action"` // The action to perform for a request. For example: get_statuses, user_typing.
|
||||
Data map[string]any `json:"data" msgpack:"data"` // The metadata for an action.
|
||||
|
||||
// Server-provided fields
|
||||
Session Session `json:"-" msgpack:"-"`
|
||||
|
||||
Ссылка в новой задаче
Block a user