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

8
services/cache/cache.go поставляемый
Просмотреть файл

@@ -20,19 +20,19 @@ type Cache interface {
// Set adds the given key and value to the store without an expiry. If the key already exists,
// it will overwrite the previous value.
Set(key string, value interface{}) error
Set(key string, value any) error
// SetWithDefaultExpiry adds the given key and value to the store with the default expiry. If
// the key already exists, it will overwrite the previous value
SetWithDefaultExpiry(key string, value interface{}) error
SetWithDefaultExpiry(key string, value any) error
// SetWithExpiry adds the given key and value to the cache with the given expiry. If the key
// already exists, it will overwrite the previous value
SetWithExpiry(key string, value interface{}, ttl time.Duration) error
SetWithExpiry(key string, value any, ttl time.Duration) error
// Get the content stored in the cache for the given key, and decode it into the value interface.
// Return ErrKeyNotFound if the key is missing from the cache
Get(key string, value interface{}) error
Get(key string, value any) error
// Remove deletes the value for a given key.
Remove(key string) error

12
services/cache/lru.go поставляемый
Просмотреть файл

@@ -70,25 +70,25 @@ func (l *LRU) Purge() error {
// Set adds the given key and value to the store without an expiry. If the key already exists,
// it will overwrite the previous value.
func (l *LRU) Set(key string, value interface{}) error {
func (l *LRU) Set(key string, value any) error {
return l.SetWithExpiry(key, value, 0)
}
// SetWithDefaultExpiry adds the given key and value to the store with the default expiry. If
// the key already exists, it will overwrite the previous value
func (l *LRU) SetWithDefaultExpiry(key string, value interface{}) error {
func (l *LRU) SetWithDefaultExpiry(key string, value any) error {
return l.SetWithExpiry(key, value, l.defaultExpiry)
}
// SetWithExpiry adds the given key and value to the cache with the given expiry. If the key
// already exists, it will overwrite the previous value
func (l *LRU) SetWithExpiry(key string, value interface{}, ttl time.Duration) error {
func (l *LRU) SetWithExpiry(key string, value any, ttl time.Duration) error {
return l.set(key, value, ttl)
}
// Get the content stored in the cache for the given key, and decode it into the value interface.
// return ErrKeyNotFound if the key is missing from the cache
func (l *LRU) Get(key string, value interface{}) error {
func (l *LRU) Get(key string, value any) error {
return l.get(key, value)
}
@@ -137,7 +137,7 @@ func (l *LRU) Name() string {
return l.name
}
func (l *LRU) set(key string, value interface{}, ttl time.Duration) error {
func (l *LRU) set(key string, value any, ttl time.Duration) error {
var expires time.Time
if ttl > 0 {
expires = time.Now().Add(ttl)
@@ -184,7 +184,7 @@ func (l *LRU) set(key string, value interface{}, ttl time.Duration) error {
return nil
}
func (l *LRU) get(key string, value interface{}) error {
func (l *LRU) get(key string, value any) error {
val, err := l.getItem(key)
if err != nil {
return err

8
services/cache/lru_striped.go поставляемый
Просмотреть файл

@@ -63,22 +63,22 @@ func (L LRUStriped) Purge() error {
}
// Set does the same as LRU.Set
func (L LRUStriped) Set(key string, value interface{}) error {
func (L LRUStriped) Set(key string, value any) error {
return L.keyBucket(key).Set(key, value)
}
// SetWithDefaultExpiry does the same as LRU.SetWithDefaultExpiry
func (L LRUStriped) SetWithDefaultExpiry(key string, value interface{}) error {
func (L LRUStriped) SetWithDefaultExpiry(key string, value any) error {
return L.keyBucket(key).SetWithDefaultExpiry(key, value)
}
// SetWithExpiry does the same as LRU.SetWithExpiry
func (L LRUStriped) SetWithExpiry(key string, value interface{}, ttl time.Duration) error {
func (L LRUStriped) SetWithExpiry(key string, value any, ttl time.Duration) error {
return L.keyBucket(key).SetWithExpiry(key, value, ttl)
}
// Get does the same as LRU.Get
func (L LRUStriped) Get(key string, value interface{}) error {
func (L LRUStriped) Get(key string, value any) error {
return L.keyBucket(key).Get(key, value)
}

8
services/cache/lru_test.go поставляемый
Просмотреть файл

@@ -112,7 +112,7 @@ func TestLRUMarshalUnMarshal(t *testing.T) {
InvalidateClusterEvent: "",
})
value1 := map[string]interface{}{
value1 := map[string]any{
"key1": 1,
"key2": "value2",
}
@@ -120,7 +120,7 @@ func TestLRUMarshalUnMarshal(t *testing.T) {
require.NoError(t, err)
var value2 map[string]interface{}
var value2 map[string]any
err = l.Get("test", &value2)
require.NoError(t, err)
assert.EqualValues(t, 1, value2["key1"])
@@ -143,7 +143,7 @@ func TestLRUMarshalUnMarshal(t *testing.T) {
Message: "OriginalId",
MessageSource: "MessageSource",
Type: "Type",
Props: map[string]interface{}{
Props: map[string]any{
"key": "val",
},
Hashtags: "Hashtags",
@@ -490,7 +490,7 @@ func BenchmarkLRU(b *testing.B) {
Message: "OriginalId",
MessageSource: "MessageSource",
Type: "Type",
Props: map[string]interface{}{
Props: map[string]any{
"key": "val",
},
Hashtags: "Hashtags",

16
services/cache/mocks/Cache.go поставляемый
Просмотреть файл

@@ -14,11 +14,11 @@ type Cache struct {
}
// Get provides a mock function with given fields: key, value
func (_m *Cache) Get(key string, value interface{}) error {
func (_m *Cache) Get(key string, value any) error {
ret := _m.Called(key, value)
var r0 error
if rf, ok := ret.Get(0).(func(string, interface{}) error); ok {
if rf, ok := ret.Get(0).(func(string, any) error); ok {
r0 = rf(key, value)
} else {
r0 = ret.Error(0)
@@ -128,11 +128,11 @@ func (_m *Cache) Remove(key string) error {
}
// Set provides a mock function with given fields: key, value
func (_m *Cache) Set(key string, value interface{}) error {
func (_m *Cache) Set(key string, value any) error {
ret := _m.Called(key, value)
var r0 error
if rf, ok := ret.Get(0).(func(string, interface{}) error); ok {
if rf, ok := ret.Get(0).(func(string, any) error); ok {
r0 = rf(key, value)
} else {
r0 = ret.Error(0)
@@ -142,11 +142,11 @@ func (_m *Cache) Set(key string, value interface{}) error {
}
// SetWithDefaultExpiry provides a mock function with given fields: key, value
func (_m *Cache) SetWithDefaultExpiry(key string, value interface{}) error {
func (_m *Cache) SetWithDefaultExpiry(key string, value any) error {
ret := _m.Called(key, value)
var r0 error
if rf, ok := ret.Get(0).(func(string, interface{}) error); ok {
if rf, ok := ret.Get(0).(func(string, any) error); ok {
r0 = rf(key, value)
} else {
r0 = ret.Error(0)
@@ -156,11 +156,11 @@ func (_m *Cache) SetWithDefaultExpiry(key string, value interface{}) error {
}
// SetWithExpiry provides a mock function with given fields: key, value, ttl
func (_m *Cache) SetWithExpiry(key string, value interface{}, ttl time.Duration) error {
func (_m *Cache) SetWithExpiry(key string, value any, ttl time.Duration) error {
ret := _m.Called(key, value, ttl)
var r0 error
if rf, ok := ret.Get(0).(func(string, interface{}, time.Duration) error); ok {
if rf, ok := ret.Get(0).(func(string, any, time.Duration) error); ok {
r0 = rf(key, value, ttl)
} else {
r0 = ret.Error(0)

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

@@ -119,7 +119,7 @@ func closeBody(r *http.Response) {
}
}
func (c *Client) buildURL(urlPath string, args ...interface{}) string {
func (c *Client) buildURL(urlPath string, args ...any) string {
return fmt.Sprintf("%s/%s", strings.TrimRight(c.address, "/"), strings.TrimLeft(fmt.Sprintf(urlPath, args...), "/"))
}

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

@@ -20,7 +20,7 @@ func (r *Response) IsSuccess() bool {
}
// SetPayload serializes an arbitrary struct as a RawMessage.
func (r *Response) SetPayload(v interface{}) error {
func (r *Response) SetPayload(v any) error {
raw, err := json.Marshal(v)
if err != nil {
return err

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

@@ -12,7 +12,7 @@ import (
//
// There are a number of send channels (`MaxConcurrentSends`) to allow for sending to multiple
// remotes concurrently, while preserving message order for each remote.
func (rcs *Service) enqueueTask(ctx context.Context, remoteId string, task interface{}) error {
func (rcs *Service) enqueueTask(ctx context.Context, remoteId string, task any) error {
if ctx == nil {
ctx = context.Background()
}

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

@@ -79,7 +79,7 @@ type ConnectionStateListener func(rc *model.RemoteCluster, online bool)
type Service struct {
server ServerIface
httpClient *http.Client
send []chan interface{}
send []chan any
// everything below guarded by `mux`
mux sync.RWMutex
@@ -120,9 +120,9 @@ func NewRemoteClusterService(server ServerIface) (*Service, error) {
connectionStateListeners: make(map[string]ConnectionStateListener),
}
service.send = make([]chan interface{}, MaxConcurrentSends)
service.send = make([]chan any, MaxConcurrentSends)
for i := range service.send {
service.send[i] = make(chan interface{}, SendChanBuffer)
service.send[i] = make(chan any, SendChanBuffer)
}
return service, nil

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

@@ -134,7 +134,7 @@ func (b *BleveEngine) createOrOpenIndex(indexName string, mapping *mapping.Index
return index, nil
}
index, err := bleve.NewUsing(indexPath, mapping, "scorch", "scorch", map[string]interface{}{
index, err := bleve.NewUsing(indexPath, mapping, "scorch", "scorch", map[string]any{
"forceSegmentType": "zap",
"forceSegmentVersion": 15,
})

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

@@ -202,11 +202,11 @@ func (_m *MockAppIface) FileReader(path string) (filestore.ReadCloseSeeker, *mod
// GetOrCreateDirectChannel provides a mock function with given fields: c, userId, otherUserId, channelOptions
func (_m *MockAppIface) GetOrCreateDirectChannel(c *request.Context, userId string, otherUserId string, channelOptions ...model.ChannelOption) (*model.Channel, *model.AppError) {
_va := make([]interface{}, len(channelOptions))
_va := make([]any, len(channelOptions))
for _i := range channelOptions {
_va[_i] = channelOptions[_i]
}
var _ca []interface{}
var _ca []any
_ca = append(_ca, c, userId, otherUserId)
_ca = append(_ca, _va...)
ret := _m.Called(_ca...)

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

@@ -72,7 +72,7 @@ type errNotFound interface {
// errInvalidInput allows checking against Store.ErrInvalidInput errors without making Store a dependency.
type errInvalidInput interface {
InvalidInputInfo() (entity string, field string, value interface{})
InvalidInputInfo() (entity string, field string, value any)
}
// Service provides shared channel synchronization.

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

@@ -327,7 +327,7 @@ func (scs *Service) notifyRemoteOffline(posts []*model.Post, rc *model.RemoteClu
T := scs.getUserTranslations(post.UserId)
ephemeral := &model.Post{
ChannelId: post.ChannelId,
Message: T("sharedchannel.cannot_deliver_post", map[string]interface{}{"Remote": rc.DisplayName}),
Message: T("sharedchannel.cannot_deliver_post", map[string]any{"Remote": rc.DisplayName}),
CreateAt: post.CreateAt + 1,
}
scs.app.SendEphemeralPost(post.UserId, ephemeral)

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

@@ -136,42 +136,42 @@ func (si *SlackImporter) SlackImport(fileData multipart.File, fileSize int64, te
for _, file := range zipreader.File {
fileReader, err := file.Open()
if err != nil {
log.WriteString(i18n.T("api.slackimport.slack_import.open.app_error", map[string]interface{}{"Filename": file.Name}))
return model.NewAppError("SlackImport", "api.slackimport.slack_import.open.app_error", map[string]interface{}{"Filename": file.Name}, err.Error(), http.StatusInternalServerError), log
log.WriteString(i18n.T("api.slackimport.slack_import.open.app_error", map[string]any{"Filename": file.Name}))
return model.NewAppError("SlackImport", "api.slackimport.slack_import.open.app_error", map[string]any{"Filename": file.Name}, err.Error(), http.StatusInternalServerError), log
}
reader := utils.NewLimitedReaderWithError(fileReader, slackImportMaxFileSize)
if file.Name == "channels.json" {
publicChannels, err = slackParseChannels(reader, model.ChannelTypeOpen)
if errors.Is(err, utils.SizeLimitExceeded) {
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]interface{}{"Filename": file.Name}))
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]any{"Filename": file.Name}))
continue
}
channels = append(channels, publicChannels...)
} else if file.Name == "dms.json" {
directChannels, err = slackParseChannels(reader, model.ChannelTypeDirect)
if errors.Is(err, utils.SizeLimitExceeded) {
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]interface{}{"Filename": file.Name}))
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]any{"Filename": file.Name}))
continue
}
channels = append(channels, directChannels...)
} else if file.Name == "groups.json" {
privateChannels, err = slackParseChannels(reader, model.ChannelTypePrivate)
if errors.Is(err, utils.SizeLimitExceeded) {
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]interface{}{"Filename": file.Name}))
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]any{"Filename": file.Name}))
continue
}
channels = append(channels, privateChannels...)
} else if file.Name == "mpims.json" {
groupChannels, err = slackParseChannels(reader, model.ChannelTypeGroup)
if errors.Is(err, utils.SizeLimitExceeded) {
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]interface{}{"Filename": file.Name}))
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]any{"Filename": file.Name}))
continue
}
channels = append(channels, groupChannels...)
} else if file.Name == "users.json" {
users, err = slackParseUsers(reader)
if errors.Is(err, utils.SizeLimitExceeded) {
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]interface{}{"Filename": file.Name}))
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]any{"Filename": file.Name}))
continue
}
} else {
@@ -179,7 +179,7 @@ func (si *SlackImporter) SlackImport(fileData multipart.File, fileSize int64, te
if len(spl) == 2 && strings.HasSuffix(spl[1], ".json") {
newposts, err := slackParsePosts(reader)
if errors.Is(err, utils.SizeLimitExceeded) {
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]interface{}{"Filename": file.Name}))
log.WriteString(i18n.T("api.slackimport.slack_import.zip.file_too_large", map[string]any{"Filename": file.Name}))
continue
}
channel := spl[0]
@@ -247,7 +247,7 @@ func (si *SlackImporter) slackAddUsers(teamId string, slackusers []slackUser, im
email := sUser.Profile.Email
if email == "" {
email = sUser.Username + "@example.com"
importerLog.WriteString(i18n.T("api.slackimport.slack_add_users.missing_email_address", map[string]interface{}{"Email": email, "Username": sUser.Username}))
importerLog.WriteString(i18n.T("api.slackimport.slack_add_users.missing_email_address", map[string]any{"Email": email, "Username": sUser.Username}))
mlog.Warn("Slack Import: User does not have an email address in the Slack export. Used username as a placeholder. The user should update their email address once logged in to the system.", mlog.String("user_email", email), mlog.String("user_name", sUser.Username))
}
@@ -257,9 +257,9 @@ func (si *SlackImporter) slackAddUsers(teamId string, slackusers []slackUser, im
if existingUser, err := si.store.User().GetByEmail(email); err == nil {
addedUsers[sUser.Id] = existingUser
if _, err := si.actions.JoinUserToTeam(team, addedUsers[sUser.Id], ""); err != nil {
importerLog.WriteString(i18n.T("api.slackimport.slack_add_users.merge_existing_failed", map[string]interface{}{"Email": existingUser.Email, "Username": existingUser.Username}))
importerLog.WriteString(i18n.T("api.slackimport.slack_add_users.merge_existing_failed", map[string]any{"Email": existingUser.Email, "Username": existingUser.Username}))
} else {
importerLog.WriteString(i18n.T("api.slackimport.slack_add_users.merge_existing", map[string]interface{}{"Email": existingUser.Email, "Username": existingUser.Username}))
importerLog.WriteString(i18n.T("api.slackimport.slack_add_users.merge_existing", map[string]any{"Email": existingUser.Email, "Username": existingUser.Username}))
}
continue
}
@@ -275,11 +275,11 @@ func (si *SlackImporter) slackAddUsers(teamId string, slackusers []slackUser, im
mUser := si.oldImportUser(team, &newUser)
if mUser == nil {
importerLog.WriteString(i18n.T("api.slackimport.slack_add_users.unable_import", map[string]interface{}{"Username": sUser.Username}))
importerLog.WriteString(i18n.T("api.slackimport.slack_add_users.unable_import", map[string]any{"Username": sUser.Username}))
continue
}
addedUsers[sUser.Id] = mUser
importerLog.WriteString(i18n.T("api.slackimport.slack_add_users.email_pwd", map[string]interface{}{"Email": newUser.Email, "Password": password}))
importerLog.WriteString(i18n.T("api.slackimport.slack_add_users.email_pwd", map[string]any{"Email": newUser.Email, "Password": password}))
}
return addedUsers
@@ -306,11 +306,11 @@ func (si *SlackImporter) slackAddBotUser(teamId string, log *bytes.Buffer) *mode
mUser := si.oldImportUser(team, &botUser)
if mUser == nil {
log.WriteString(i18n.T("api.slackimport.slack_add_bot_user.unable_import", map[string]interface{}{"Username": username}))
log.WriteString(i18n.T("api.slackimport.slack_add_bot_user.unable_import", map[string]any{"Username": username}))
return nil
}
log.WriteString(i18n.T("api.slackimport.slack_add_bot_user.email_pwd", map[string]interface{}{"Email": botUser.Email, "Password": password}))
log.WriteString(i18n.T("api.slackimport.slack_add_bot_user.email_pwd", map[string]any{"Email": botUser.Email, "Password": password}))
return mUser
}
@@ -553,11 +553,11 @@ func (si *SlackImporter) addSlackUsersToChannel(members []string, users map[stri
for _, member := range members {
user, ok := users[member]
if !ok {
log.WriteString(i18n.T("api.slackimport.slack_add_channels.failed_to_add_user", map[string]interface{}{"Username": "?"}))
log.WriteString(i18n.T("api.slackimport.slack_add_channels.failed_to_add_user", map[string]any{"Username": "?"}))
continue
}
if _, err := si.actions.AddUserToChannel(user, channel, false); err != nil {
log.WriteString(i18n.T("api.slackimport.slack_add_channels.failed_to_add_user", map[string]interface{}{"Username": user.Username}))
log.WriteString(i18n.T("api.slackimport.slack_add_channels.failed_to_add_user", map[string]any{"Username": user.Username}))
}
}
}
@@ -613,7 +613,7 @@ func (si *SlackImporter) slackAddChannels(teamId string, slackchannels []slackCh
var err error
if mChannel, err = si.store.Channel().GetByName(teamId, sChannel.Name, true); err == nil {
// The channel already exists as an active channel. Merge with the existing one.
importerLog.WriteString(i18n.T("api.slackimport.slack_add_channels.merge", map[string]interface{}{"DisplayName": newChannel.DisplayName}))
importerLog.WriteString(i18n.T("api.slackimport.slack_add_channels.merge", map[string]any{"DisplayName": newChannel.DisplayName}))
} else if _, nErr := si.store.Channel().GetDeletedByName(teamId, sChannel.Name); nErr == nil {
// The channel already exists but has been deleted. Generate a random string for the handle instead.
newChannel.Name = model.NewId()
@@ -625,7 +625,7 @@ func (si *SlackImporter) slackAddChannels(teamId string, slackchannels []slackCh
mChannel = si.oldImportChannel(&newChannel, sChannel, users)
if mChannel == nil {
mlog.Warn("Slack Import: Unable to import Slack channel.", mlog.String("channel_display_name", newChannel.DisplayName))
importerLog.WriteString(i18n.T("api.slackimport.slack_add_channels.import_failed", map[string]interface{}{"DisplayName": newChannel.DisplayName}))
importerLog.WriteString(i18n.T("api.slackimport.slack_add_channels.import_failed", map[string]any{"DisplayName": newChannel.DisplayName}))
continue
}
}

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

@@ -165,12 +165,12 @@ func (ts *TelemetryService) sendDailyTelemetry(override bool) {
}
}
func (ts *TelemetryService) SendTelemetry(event string, properties map[string]interface{}) {
func (ts *TelemetryService) SendTelemetry(event string, properties map[string]any) {
if ts.rudderClient != nil {
var context *rudder.Context
// if we are part of a cloud installation, add it's ID to the tracked event's context
if installationId := os.Getenv("MM_CLOUD_INSTALLATION_ID"); installationId != "" {
context = &rudder.Context{Traits: map[string]interface{}{"installationId": installationId}}
context = &rudder.Context{Traits: map[string]any{"installationId": installationId}}
}
ts.rudderClient.Enqueue(rudder.Track{
Event: event,
@@ -193,11 +193,11 @@ func isDefaultArray(setting, defaultValue []string) bool {
return true
}
func isDefault(setting interface{}, defaultValue interface{}) bool {
func isDefault(setting any, defaultValue any) bool {
return setting == defaultValue
}
func pluginSetting(pluginSettings *model.PluginSettings, plugin, key string, defaultValue interface{}) interface{} {
func pluginSetting(pluginSettings *model.PluginSettings, plugin, key string, defaultValue any) any {
settings, ok := pluginSettings.Plugins[plugin]
if !ok {
return defaultValue
@@ -331,7 +331,7 @@ func (ts *TelemetryService) trackActivity() {
activeUsersMonthlyCount = r.Data.(int64)
}
activity := map[string]interface{}{
activity := map[string]any{
"registered_users": userCount,
"bot_accounts": botAccountsCount,
"guest_accounts": guestAccountsCount,
@@ -365,7 +365,7 @@ func (ts *TelemetryService) trackActivity() {
func (ts *TelemetryService) trackConfig() {
cfg := ts.srv.Config()
ts.SendTelemetry(TrackConfigService, map[string]interface{}{
ts.SendTelemetry(TrackConfigService, map[string]any{
"web_server_mode": *cfg.ServiceSettings.WebserverMode,
"enable_security_fix_alert": *cfg.ServiceSettings.EnableSecurityFixAlert,
"enable_insecure_outgoing_connections": *cfg.ServiceSettings.EnableInsecureOutgoingConnections,
@@ -449,7 +449,7 @@ func (ts *TelemetryService) trackConfig() {
"enable_custom_groups": *cfg.ServiceSettings.EnableCustomGroups,
})
ts.SendTelemetry(TrackConfigTeam, map[string]interface{}{
ts.SendTelemetry(TrackConfigTeam, map[string]any{
"enable_user_creation": cfg.TeamSettings.EnableUserCreation,
"enable_open_server": *cfg.TeamSettings.EnableOpenServer,
"enable_user_deactivation": *cfg.TeamSettings.EnableUserDeactivation,
@@ -472,14 +472,14 @@ func (ts *TelemetryService) trackConfig() {
"experimental_default_channels": len(cfg.TeamSettings.ExperimentalDefaultChannels),
})
ts.SendTelemetry(TrackConfigClientReq, map[string]interface{}{
ts.SendTelemetry(TrackConfigClientReq, map[string]any{
"android_latest_version": cfg.ClientRequirements.AndroidLatestVersion,
"android_min_version": cfg.ClientRequirements.AndroidMinVersion,
"ios_latest_version": cfg.ClientRequirements.IosLatestVersion,
"ios_min_version": cfg.ClientRequirements.IosMinVersion,
})
ts.SendTelemetry(TrackConfigSQL, map[string]interface{}{
ts.SendTelemetry(TrackConfigSQL, map[string]any{
"driver_name": *cfg.SqlSettings.DriverName,
"trace": cfg.SqlSettings.Trace,
"max_idle_conns": *cfg.SqlSettings.MaxIdleConns,
@@ -493,7 +493,7 @@ func (ts *TelemetryService) trackConfig() {
"migrations_statement_timeout_seconds": *cfg.SqlSettings.MigrationsStatementTimeoutSeconds,
})
ts.SendTelemetry(TrackConfigLog, map[string]interface{}{
ts.SendTelemetry(TrackConfigLog, map[string]any{
"enable_console": cfg.LogSettings.EnableConsole,
"console_level": cfg.LogSettings.ConsoleLevel,
"console_json": *cfg.LogSettings.ConsoleJson,
@@ -505,7 +505,7 @@ func (ts *TelemetryService) trackConfig() {
"advanced_logging_config": *cfg.LogSettings.AdvancedLoggingConfig != "",
})
ts.SendTelemetry(TrackConfigAudit, map[string]interface{}{
ts.SendTelemetry(TrackConfigAudit, map[string]any{
"file_enabled": *cfg.ExperimentalAuditSettings.FileEnabled,
"file_max_size_mb": *cfg.ExperimentalAuditSettings.FileMaxSizeMB,
"file_max_age_days": *cfg.ExperimentalAuditSettings.FileMaxAgeDays,
@@ -515,7 +515,7 @@ func (ts *TelemetryService) trackConfig() {
"advanced_logging_config": *cfg.ExperimentalAuditSettings.AdvancedLoggingConfig != "",
})
ts.SendTelemetry(TrackConfigNotificationLog, map[string]interface{}{
ts.SendTelemetry(TrackConfigNotificationLog, map[string]any{
"enable_console": *cfg.NotificationLogSettings.EnableConsole,
"console_level": *cfg.NotificationLogSettings.ConsoleLevel,
"console_json": *cfg.NotificationLogSettings.ConsoleJson,
@@ -526,7 +526,7 @@ func (ts *TelemetryService) trackConfig() {
"advanced_logging_config": *cfg.NotificationLogSettings.AdvancedLoggingConfig != "",
})
ts.SendTelemetry(TrackConfigPassword, map[string]interface{}{
ts.SendTelemetry(TrackConfigPassword, map[string]any{
"minimum_length": *cfg.PasswordSettings.MinimumLength,
"lowercase": *cfg.PasswordSettings.Lowercase,
"number": *cfg.PasswordSettings.Number,
@@ -534,7 +534,7 @@ func (ts *TelemetryService) trackConfig() {
"symbol": *cfg.PasswordSettings.Symbol,
})
ts.SendTelemetry(TrackConfigFile, map[string]interface{}{
ts.SendTelemetry(TrackConfigFile, map[string]any{
"enable_public_links": cfg.FileSettings.EnablePublicLink,
"driver_name": *cfg.FileSettings.DriverName,
"isdefault_directory": isDefault(*cfg.FileSettings.Directory, model.FileSettingsDefaultDirectory),
@@ -553,7 +553,7 @@ func (ts *TelemetryService) trackConfig() {
"enable_mobile_download": *cfg.FileSettings.EnableMobileDownload,
})
ts.SendTelemetry(TrackConfigEmail, map[string]interface{}{
ts.SendTelemetry(TrackConfigEmail, map[string]any{
"enable_sign_up_with_email": cfg.EmailSettings.EnableSignUpWithEmail,
"enable_sign_in_with_email": *cfg.EmailSettings.EnableSignInWithEmail,
"enable_sign_in_with_username": *cfg.EmailSettings.EnableSignInWithUsername,
@@ -581,7 +581,7 @@ func (ts *TelemetryService) trackConfig() {
"enable_inactivity_email": *cfg.EmailSettings.EnableInactivityEmail,
})
ts.SendTelemetry(TrackConfigRate, map[string]interface{}{
ts.SendTelemetry(TrackConfigRate, map[string]any{
"enable_rate_limiter": *cfg.RateLimitSettings.Enable,
"vary_by_remote_address": *cfg.RateLimitSettings.VaryByRemoteAddr,
"vary_by_user": *cfg.RateLimitSettings.VaryByUser,
@@ -591,19 +591,19 @@ func (ts *TelemetryService) trackConfig() {
"isdefault_vary_by_header": isDefault(cfg.RateLimitSettings.VaryByHeader, ""),
})
ts.SendTelemetry(TrackConfigPrivacy, map[string]interface{}{
ts.SendTelemetry(TrackConfigPrivacy, map[string]any{
"show_email_address": cfg.PrivacySettings.ShowEmailAddress,
"show_full_name": cfg.PrivacySettings.ShowFullName,
})
ts.SendTelemetry(TrackConfigTheme, map[string]interface{}{
ts.SendTelemetry(TrackConfigTheme, map[string]any{
"enable_theme_selection": *cfg.ThemeSettings.EnableThemeSelection,
"isdefault_default_theme": isDefault(*cfg.ThemeSettings.DefaultTheme, model.TeamSettingsDefaultTeamText),
"allow_custom_themes": *cfg.ThemeSettings.AllowCustomThemes,
"allowed_themes": len(cfg.ThemeSettings.AllowedThemes),
})
ts.SendTelemetry(TrackConfigOAuth, map[string]interface{}{
ts.SendTelemetry(TrackConfigOAuth, map[string]any{
"enable_gitlab": cfg.GitLabSettings.Enable,
"openid_gitlab": *cfg.GitLabSettings.Enable && strings.Contains(*cfg.GitLabSettings.Scope, model.ServiceOpenid),
"enable_google": cfg.GoogleSettings.Enable,
@@ -613,7 +613,7 @@ func (ts *TelemetryService) trackConfig() {
"enable_openid": cfg.OpenIdSettings.Enable,
})
ts.SendTelemetry(TrackConfigSupport, map[string]interface{}{
ts.SendTelemetry(TrackConfigSupport, map[string]any{
"isdefault_terms_of_service_link": isDefault(*cfg.SupportSettings.TermsOfServiceLink, model.SupportSettingsDefaultTermsOfServiceLink),
"isdefault_privacy_policy_link": isDefault(*cfg.SupportSettings.PrivacyPolicyLink, model.SupportSettingsDefaultPrivacyPolicyLink),
"isdefault_about_link": isDefault(*cfg.SupportSettings.AboutLink, model.SupportSettingsDefaultAboutLink),
@@ -625,7 +625,7 @@ func (ts *TelemetryService) trackConfig() {
"enable_ask_community_link": *cfg.SupportSettings.EnableAskCommunityLink,
})
ts.SendTelemetry(TrackConfigLDAP, map[string]interface{}{
ts.SendTelemetry(TrackConfigLDAP, map[string]any{
"enable": *cfg.LdapSettings.Enable,
"enable_sync": *cfg.LdapSettings.EnableSync,
"enable_admin_filter": *cfg.LdapSettings.EnableAdminFilter,
@@ -656,18 +656,18 @@ func (ts *TelemetryService) trackConfig() {
"isnotempty_private_key": !isDefault(*cfg.LdapSettings.PrivateKeyFile, ""),
})
ts.SendTelemetry(TrackConfigCompliance, map[string]interface{}{
ts.SendTelemetry(TrackConfigCompliance, map[string]any{
"enable": *cfg.ComplianceSettings.Enable,
"enable_daily": *cfg.ComplianceSettings.EnableDaily,
})
ts.SendTelemetry(TrackConfigLocalization, map[string]interface{}{
ts.SendTelemetry(TrackConfigLocalization, map[string]any{
"default_server_locale": *cfg.LocalizationSettings.DefaultServerLocale,
"default_client_locale": *cfg.LocalizationSettings.DefaultClientLocale,
"available_locales": *cfg.LocalizationSettings.AvailableLocales,
})
ts.SendTelemetry(TrackConfigSAML, map[string]interface{}{
ts.SendTelemetry(TrackConfigSAML, map[string]any{
"enable": *cfg.SamlSettings.Enable,
"enable_sync_with_ldap": *cfg.SamlSettings.EnableSyncWithLdap,
"enable_sync_with_ldap_include_auth": *cfg.SamlSettings.EnableSyncWithLdapIncludeAuth,
@@ -696,7 +696,7 @@ func (ts *TelemetryService) trackConfig() {
"isdefault_login_button_text_color": isDefault(*cfg.SamlSettings.LoginButtonTextColor, ""),
})
ts.SendTelemetry(TrackConfigCluster, map[string]interface{}{
ts.SendTelemetry(TrackConfigCluster, map[string]any{
"enable": *cfg.ClusterSettings.Enable,
"network_interface": isDefault(*cfg.ClusterSettings.NetworkInterface, ""),
"bind_address": isDefault(*cfg.ClusterSettings.BindAddress, ""),
@@ -707,19 +707,19 @@ func (ts *TelemetryService) trackConfig() {
"read_only_config": *cfg.ClusterSettings.ReadOnlyConfig,
})
ts.SendTelemetry(TrackConfigMetrics, map[string]interface{}{
ts.SendTelemetry(TrackConfigMetrics, map[string]any{
"enable": *cfg.MetricsSettings.Enable,
"block_profile_rate": *cfg.MetricsSettings.BlockProfileRate,
})
ts.SendTelemetry(TrackConfigNativeApp, map[string]interface{}{
ts.SendTelemetry(TrackConfigNativeApp, map[string]any{
"isdefault_app_custom_url_schemes": isDefaultArray(cfg.NativeAppSettings.AppCustomURLSchemes, model.GetDefaultAppCustomURLSchemes()),
"isdefault_app_download_link": isDefault(*cfg.NativeAppSettings.AppDownloadLink, model.NativeappSettingsDefaultAppDownloadLink),
"isdefault_android_app_download_link": isDefault(*cfg.NativeAppSettings.AndroidAppDownloadLink, model.NativeappSettingsDefaultAndroidAppDownloadLink),
"isdefault_iosapp_download_link": isDefault(*cfg.NativeAppSettings.IosAppDownloadLink, model.NativeappSettingsDefaultIosAppDownloadLink),
})
ts.SendTelemetry(TrackConfigExperimental, map[string]interface{}{
ts.SendTelemetry(TrackConfigExperimental, map[string]any{
"client_side_cert_enable": *cfg.ExperimentalSettings.ClientSideCertEnable,
"isdefault_client_side_cert_check": isDefault(*cfg.ExperimentalSettings.ClientSideCertCheck, model.ClientSideCertCheckPrimaryAuth),
"link_metadata_timeout_milliseconds": *cfg.ExperimentalSettings.LinkMetadataTimeoutMilliseconds,
@@ -731,11 +731,11 @@ func (ts *TelemetryService) trackConfig() {
"enable_app_bar": *cfg.ExperimentalSettings.EnableAppBar,
})
ts.SendTelemetry(TrackConfigAnalytics, map[string]interface{}{
ts.SendTelemetry(TrackConfigAnalytics, map[string]any{
"isdefault_max_users_for_statistics": isDefault(*cfg.AnalyticsSettings.MaxUsersForStatistics, model.AnalyticsSettingsDefaultMaxUsersForStatistics),
})
ts.SendTelemetry(TrackConfigAnnouncement, map[string]interface{}{
ts.SendTelemetry(TrackConfigAnnouncement, map[string]any{
"enable_banner": *cfg.AnnouncementSettings.EnableBanner,
"isdefault_banner_color": isDefault(*cfg.AnnouncementSettings.BannerColor, model.AnnouncementSettingsDefaultBannerColor),
"isdefault_banner_text_color": isDefault(*cfg.AnnouncementSettings.BannerTextColor, model.AnnouncementSettingsDefaultBannerTextColor),
@@ -744,7 +744,7 @@ func (ts *TelemetryService) trackConfig() {
"user_notices_enabled": *cfg.AnnouncementSettings.UserNoticesEnabled,
})
ts.SendTelemetry(TrackConfigElasticsearch, map[string]interface{}{
ts.SendTelemetry(TrackConfigElasticsearch, map[string]any{
"isdefault_connection_url": isDefault(*cfg.ElasticsearchSettings.ConnectionURL, model.ElasticsearchSettingsDefaultConnectionURL),
"isdefault_username": isDefault(*cfg.ElasticsearchSettings.Username, model.ElasticsearchSettingsDefaultUsername),
"isdefault_password": isDefault(*cfg.ElasticsearchSettings.Password, model.ElasticsearchSettingsDefaultPassword),
@@ -768,7 +768,7 @@ func (ts *TelemetryService) trackConfig() {
ts.trackPluginConfig(cfg, model.PluginSettingsDefaultMarketplaceURL)
ts.SendTelemetry(TrackConfigDataRetention, map[string]interface{}{
ts.SendTelemetry(TrackConfigDataRetention, map[string]any{
"enable_message_deletion": *cfg.DataRetentionSettings.EnableMessageDeletion,
"enable_file_deletion": *cfg.DataRetentionSettings.EnableFileDeletion,
"enable_boards_deletion": *cfg.DataRetentionSettings.EnableBoardsDeletion,
@@ -781,7 +781,7 @@ func (ts *TelemetryService) trackConfig() {
"cleanup_config_threshold_days": *cfg.JobSettings.CleanupConfigThresholdDays,
})
ts.SendTelemetry(TrackConfigMessageExport, map[string]interface{}{
ts.SendTelemetry(TrackConfigMessageExport, map[string]any{
"enable_message_export": *cfg.MessageExportSettings.EnableExport,
"export_format": *cfg.MessageExportSettings.ExportFormat,
"daily_run_time": *cfg.MessageExportSettings.DailyRunTime,
@@ -795,39 +795,39 @@ func (ts *TelemetryService) trackConfig() {
"download_export_results": *cfg.MessageExportSettings.DownloadExportResults,
})
ts.SendTelemetry(TrackConfigDisplay, map[string]interface{}{
ts.SendTelemetry(TrackConfigDisplay, map[string]any{
"experimental_timezone": *cfg.DisplaySettings.ExperimentalTimezone,
"isdefault_custom_url_schemes": len(cfg.DisplaySettings.CustomURLSchemes) != 0,
})
ts.SendTelemetry(TrackConfigGuestAccounts, map[string]interface{}{
ts.SendTelemetry(TrackConfigGuestAccounts, map[string]any{
"enable": *cfg.GuestAccountsSettings.Enable,
"allow_email_accounts": *cfg.GuestAccountsSettings.AllowEmailAccounts,
"enforce_multifactor_authentication": *cfg.GuestAccountsSettings.EnforceMultifactorAuthentication,
"isdefault_restrict_creation_to_domains": isDefault(*cfg.GuestAccountsSettings.RestrictCreationToDomains, ""),
})
ts.SendTelemetry(TrackConfigImageProxy, map[string]interface{}{
ts.SendTelemetry(TrackConfigImageProxy, map[string]any{
"enable": *cfg.ImageProxySettings.Enable,
"image_proxy_type": *cfg.ImageProxySettings.ImageProxyType,
"isdefault_remote_image_proxy_url": isDefault(*cfg.ImageProxySettings.RemoteImageProxyURL, ""),
"isdefault_remote_image_proxy_options": isDefault(*cfg.ImageProxySettings.RemoteImageProxyOptions, ""),
})
ts.SendTelemetry(TrackConfigBleve, map[string]interface{}{
ts.SendTelemetry(TrackConfigBleve, map[string]any{
"enable_indexing": *cfg.BleveSettings.EnableIndexing,
"enable_searching": *cfg.BleveSettings.EnableSearching,
"enable_autocomplete": *cfg.BleveSettings.EnableAutocomplete,
"bulk_indexing_batch_size": *cfg.BleveSettings.BatchSize,
})
ts.SendTelemetry(TrackConfigExport, map[string]interface{}{
ts.SendTelemetry(TrackConfigExport, map[string]any{
"retention_days": *cfg.ExportSettings.RetentionDays,
})
// Convert feature flags to map[string]interface{} for sending
// Convert feature flags to map[string]any for sending
flags := cfg.FeatureFlags.ToMap()
interfaceFlags := make(map[string]interface{})
interfaceFlags := make(map[string]any)
for k, v := range flags {
interfaceFlags[k] = v
}
@@ -836,7 +836,7 @@ func (ts *TelemetryService) trackConfig() {
func (ts *TelemetryService) trackLicense() {
if license := ts.srv.License(); license != nil {
data := map[string]interface{}{
data := map[string]any{
"customer_id": license.Customer.Id,
"license_id": license.Id,
"issued": license.IssuedAt,
@@ -911,7 +911,7 @@ func (ts *TelemetryService) trackPlugins() {
totalDisabledCount = -1 // -1 to indicate disabled or error
}
ts.SendTelemetry(TrackPlugins, map[string]interface{}{
ts.SendTelemetry(TrackPlugins, map[string]any{
"enabled_plugins": totalEnabledCount,
"enabled_webapp_plugins": webappEnabledCount,
"enabled_backend_plugins": backendEnabledCount,
@@ -930,7 +930,7 @@ func (ts *TelemetryService) trackPlugins() {
}
func (ts *TelemetryService) trackServer() {
data := map[string]interface{}{
data := map[string]any{
"edition": model.BuildEnterpriseReady,
"version": model.CurrentVersion,
"database_type": *ts.srv.Config().SqlSettings.DriverName,
@@ -960,7 +960,7 @@ func (ts *TelemetryService) trackPermissions() {
phase2Complete = true
}
ts.SendTelemetry(TrackPermissionsGeneral, map[string]interface{}{
ts.SendTelemetry(TrackPermissionsGeneral, map[string]any{
"phase_1_migration_complete": phase1Complete,
"phase_2_migration_complete": phase2Complete,
})
@@ -1038,7 +1038,7 @@ func (ts *TelemetryService) trackPermissions() {
systemReadOnlyAdminCount = 0
}
ts.SendTelemetry(TrackPermissionsSystemScheme, map[string]interface{}{
ts.SendTelemetry(TrackPermissionsSystemScheme, map[string]any{
"system_admin_permissions": systemAdminPermissions,
"system_user_permissions": systemUserPermissions,
"system_manager_permissions": systemManagerPermissions,
@@ -1092,7 +1092,7 @@ func (ts *TelemetryService) trackPermissions() {
count, _ := ts.dbStore.Team().AnalyticsGetTeamCountForScheme(scheme.Id)
ts.SendTelemetry(TrackPermissionsTeamSchemes, map[string]interface{}{
ts.SendTelemetry(TrackPermissionsTeamSchemes, map[string]any{
"scheme_id": scheme.Id,
"team_admin_permissions": teamAdminPermissions,
"team_user_permissions": teamUserPermissions,
@@ -1107,7 +1107,7 @@ func (ts *TelemetryService) trackPermissions() {
}
func (ts *TelemetryService) trackElasticsearch() {
data := map[string]interface{}{}
data := map[string]any{}
for _, engine := range ts.searchEngine.GetActiveEngines() {
if engine.GetVersion() != 0 && engine.GetName() == "elasticsearch" {
@@ -1179,7 +1179,7 @@ func (ts *TelemetryService) trackGroups() {
mlog.Debug("Could not get group_count_with_allow_reference", mlog.Err(err))
}
ts.SendTelemetry(TrackGroups, map[string]interface{}{
ts.SendTelemetry(TrackGroups, map[string]any{
"group_count": groupCount,
"ldap_group_count": ldapGroupCount,
"custom_group_count": customGroupCount,
@@ -1238,7 +1238,7 @@ func (ts *TelemetryService) trackChannelModeration() {
mlog.Debug("Could not get use_channel_mentions_guest_disabled_count", mlog.Err(err))
}
ts.SendTelemetry(TrackChannelModeration, map[string]interface{}{
ts.SendTelemetry(TrackChannelModeration, map[string]any{
"channel_scheme_count": channelSchemeCount,
"create_post_user_disabled_count": createPostUser,
@@ -1322,7 +1322,7 @@ func (ts *TelemetryService) trackWarnMetrics() {
for key, value := range systemDataList {
if strings.HasPrefix(key, model.WarnMetricStatusStorePrefix) {
if _, ok := model.WarnMetricsTable[key]; ok {
ts.SendTelemetry(TrackWarnMetrics, map[string]interface{}{
ts.SendTelemetry(TrackWarnMetrics, map[string]any{
key: value != "false",
})
}
@@ -1331,7 +1331,7 @@ func (ts *TelemetryService) trackWarnMetrics() {
}
func (ts *TelemetryService) trackPluginConfig(cfg *model.Config, marketplaceURL string) {
pluginConfigData := map[string]interface{}{
pluginConfigData := map[string]any{
"enable_nps_survey": pluginSetting(&cfg.PluginSettings, model.PluginIdNPS, "enablesurvey", true),
"enable": *cfg.PluginSettings.Enable,
"enable_uploads": *cfg.PluginSettings.EnableUploads,

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

@@ -44,7 +44,7 @@ type testTelemetryPayload struct {
UserId string
Event string
Timestamp time.Time
Properties map[string]interface{}
Properties map[string]any
}
Context struct {
Library struct {
@@ -59,10 +59,10 @@ type testBatch struct {
UserId string
Event string
Timestamp time.Time
Properties map[string]interface{}
Properties map[string]any
}
func assertPayload(t *testing.T, actual testTelemetryPayload, event string, properties map[string]interface{}) {
func assertPayload(t *testing.T, actual testTelemetryPayload, event string, properties map[string]any) {
t.Helper()
assert.NotEmpty(t, actual.MessageId)
assert.False(t, actual.SentAt.IsZero())
@@ -352,7 +352,7 @@ func TestEnsureTelemetryID(t *testing.T) {
func TestPluginSetting(t *testing.T) {
settings := &model.PluginSettings{
Plugins: map[string]map[string]interface{}{
Plugins: map[string]map[string]any{
"test": {
"foo": "bar",
},
@@ -436,12 +436,12 @@ func TestRudderTelemetry(t *testing.T) {
t.Run("Send", func(t *testing.T) {
testValue := "test-send-value-6789"
service.SendTelemetry("Testing Telemetry", map[string]interface{}{
service.SendTelemetry("Testing Telemetry", map[string]any{
"hey": testValue,
})
select {
case result := <-pchan:
assertPayload(t, result, "Testing Telemetry", map[string]interface{}{
assertPayload(t, result, "Testing Telemetry", map[string]any{
"hey": testValue,
})
case <-time.After(time.Second * 1):

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

@@ -31,7 +31,7 @@ func (LogrusAdapter) Error(msg string) {
}
// Infof - logrus adapter for span info logging
func (LogrusAdapter) Infof(msg string, args ...interface{}) {
func (LogrusAdapter) Infof(msg string, args ...any) {
// we ignore Info messages from opentracing
}