[MM-16751] golint model (#17896)
Этот коммит содержится в:
коммит произвёл
Claudio Costa
родитель
953eebdef4
Коммит
97ccf0bdf6
@@ -98,7 +98,7 @@ func (awsm *AwsMeter) GetUserCategoryUsage(dimensions []string, startTime time.T
|
||||
var err error
|
||||
|
||||
switch dimension {
|
||||
case model.AWS_METERING_DIMENSION_USAGE_HRS:
|
||||
case model.AwsMeteringDimensionUsageHrs:
|
||||
userCount, err = awsm.store.User().AnalyticsActiveCountForPeriod(model.GetMillisForTime(startTime), model.GetMillisForTime(endTime), model.UserCountOptions{})
|
||||
if err != nil {
|
||||
mlog.Warn("Failed to obtain usage data", mlog.String("dimension", dimension), mlog.String("start", startTime.String()), mlog.Int64("count", userCount), mlog.Err(err))
|
||||
|
||||
@@ -42,7 +42,7 @@ func String(i string) *string {
|
||||
func TestAwsMeterUsage(t *testing.T) {
|
||||
startTime := time.Now()
|
||||
endTime := time.Now()
|
||||
dimensions := []string{model.AWS_METERING_DIMENSION_USAGE_HRS}
|
||||
dimensions := []string{model.AwsMeteringDimensionUsageHrs}
|
||||
|
||||
userStoreMock := mocks.UserStore{}
|
||||
userStoreMock.On("AnalyticsActiveCountForPeriod", model.GetMillisForTime(startTime), model.GetMillisForTime(endTime), mock.AnythingOfType("model.UserCountOptions")).Return(int64(2), nil)
|
||||
@@ -52,7 +52,7 @@ func TestAwsMeterUsage(t *testing.T) {
|
||||
|
||||
reports := make([]*AWSMeterReport, 1)
|
||||
reports[0] = &AWSMeterReport{
|
||||
Dimension: model.AWS_METERING_DIMENSION_USAGE_HRS,
|
||||
Dimension: model.AwsMeteringDimensionUsageHrs,
|
||||
Value: 2,
|
||||
Timestamp: startTime,
|
||||
}
|
||||
@@ -108,7 +108,7 @@ func TestAwsMeterUsage(t *testing.T) {
|
||||
func TestAwsMeterUsageWithDBError(t *testing.T) {
|
||||
startTime := time.Now()
|
||||
endTime := time.Now()
|
||||
dimensions := []string{model.AWS_METERING_DIMENSION_USAGE_HRS}
|
||||
dimensions := []string{model.AwsMeteringDimensionUsageHrs}
|
||||
|
||||
userStoreMock := mocks.UserStore{}
|
||||
userStoreMock.On("AnalyticsActiveCountForPeriod", model.GetMillisForTime(startTime), model.GetMillisForTime(endTime), mock.AnythingOfType("model.UserCountOptions")).Return(int64(0), errors.New("error"))
|
||||
@@ -118,7 +118,7 @@ func TestAwsMeterUsageWithDBError(t *testing.T) {
|
||||
|
||||
reports := make([]*AWSMeterReport, 1)
|
||||
reports[0] = &AWSMeterReport{
|
||||
Dimension: model.AWS_METERING_DIMENSION_USAGE_HRS,
|
||||
Dimension: model.AwsMeteringDimensionUsageHrs,
|
||||
Value: 2,
|
||||
Timestamp: startTime,
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func makeTestAtmosCamoProxy() *ImageProxy {
|
||||
},
|
||||
ImageProxySettings: model.ImageProxySettings{
|
||||
Enable: model.NewBool(true),
|
||||
ImageProxyType: model.NewString(model.IMAGE_PROXY_TYPE_ATMOS_CAMO),
|
||||
ImageProxyType: model.NewString(model.ImageProxyTypeAtmosCamo),
|
||||
RemoteImageProxyURL: model.NewString("http://images.example.com"),
|
||||
RemoteImageProxyOptions: model.NewString("7e5f3fab20b94782b43cdb022a66985ef28ba355df2c5d5da3c9a05e4b697bac"),
|
||||
},
|
||||
|
||||
@@ -70,9 +70,9 @@ func (proxy *ImageProxy) makeBackend(enable bool, proxyType string) ImageProxyBa
|
||||
}
|
||||
|
||||
switch proxyType {
|
||||
case model.IMAGE_PROXY_TYPE_LOCAL:
|
||||
case model.ImageProxyTypeLocal:
|
||||
return makeLocalBackend(proxy)
|
||||
case model.IMAGE_PROXY_TYPE_ATMOS_CAMO:
|
||||
case model.ImageProxyTypeAtmosCamo:
|
||||
return makeAtmosCamoBackend(proxy)
|
||||
default:
|
||||
return nil
|
||||
|
||||
@@ -27,7 +27,7 @@ func makeTestLocalProxy() *ImageProxy {
|
||||
},
|
||||
ImageProxySettings: model.ImageProxySettings{
|
||||
Enable: model.NewBool(true),
|
||||
ImageProxyType: model.NewString(model.IMAGE_PROXY_TYPE_LOCAL),
|
||||
ImageProxyType: model.NewString(model.ImageProxyTypeLocal),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -98,15 +98,15 @@ func (rcs *Service) sendFileToRemote(timeout time.Duration, task sendFileTask) (
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid siteURL while sending file to remote %s: %w", task.rc.RemoteId, err)
|
||||
}
|
||||
u.Path = path.Join(u.Path, model.API_URL_SUFFIX, "remotecluster", "upload", task.us.Id)
|
||||
u.Path = path.Join(u.Path, model.ApiUrlSuffix, "remotecluster", "upload", task.us.Id)
|
||||
|
||||
req, err := http.NewRequest("POST", u.String(), r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Set(model.HEADER_REMOTECLUSTER_ID, task.rc.RemoteId)
|
||||
req.Header.Set(model.HEADER_REMOTECLUSTER_TOKEN, task.rc.RemoteToken)
|
||||
req.Header.Set(model.HeaderRemoteclusterId, task.rc.RemoteId)
|
||||
req.Header.Set(model.HeaderRemoteclusterToken, task.rc.RemoteToken)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
@@ -148,8 +148,8 @@ func (rcs *Service) sendFrameToRemote(timeout time.Duration, rc *model.RemoteClu
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set(model.HEADER_REMOTECLUSTER_ID, rc.RemoteId)
|
||||
req.Header.Set(model.HEADER_REMOTECLUSTER_TOKEN, rc.RemoteToken)
|
||||
req.Header.Set(model.HeaderRemoteclusterId, rc.RemoteId)
|
||||
req.Header.Set(model.HeaderRemoteclusterToken, rc.RemoteToken)
|
||||
|
||||
resp, err := rcs.httpClient.Do(req.WithContext(ctx))
|
||||
if metrics := rcs.server.GetMetrics(); metrics != nil {
|
||||
|
||||
@@ -99,7 +99,7 @@ func (rcs *Service) sendProfileImageToRemote(timeout time.Duration, task sendPro
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid siteURL while sending file to remote %s: %w", task.rc.RemoteId, err)
|
||||
}
|
||||
u.Path = path.Join(u.Path, model.API_URL_SUFFIX, "remotecluster", task.userID, "image")
|
||||
u.Path = path.Join(u.Path, model.ApiUrlSuffix, "remotecluster", task.userID, "image")
|
||||
|
||||
body := &bytes.Buffer{}
|
||||
writer := multipart.NewWriter(body)
|
||||
@@ -122,8 +122,8 @@ func (rcs *Service) sendProfileImageToRemote(timeout time.Duration, task sendPro
|
||||
return err
|
||||
}
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
req.Header.Set(model.HEADER_REMOTECLUSTER_ID, task.rc.RemoteId)
|
||||
req.Header.Set(model.HEADER_REMOTECLUSTER_TOKEN, task.rc.RemoteToken)
|
||||
req.Header.Set(model.HeaderRemoteclusterId, task.rc.RemoteId)
|
||||
req.Header.Set(model.HeaderRemoteclusterToken, task.rc.RemoteToken)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
@@ -40,14 +40,14 @@ func TestService_sendProfileImageToRemote(t *testing.T) {
|
||||
if shouldError.get() {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
resp := make(map[string]string)
|
||||
resp[model.STATUS] = model.STATUS_FAIL
|
||||
resp[model.STATUS] = model.StatusFail
|
||||
w.Write([]byte(model.MapToJson(resp)))
|
||||
return
|
||||
}
|
||||
|
||||
status := model.STATUS_OK
|
||||
status := model.StatusOk
|
||||
defer func(s *string) {
|
||||
if *s != model.STATUS_OK {
|
||||
if *s != model.StatusOk {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
resp := make(map[string]string)
|
||||
@@ -56,20 +56,20 @@ func TestService_sendProfileImageToRemote(t *testing.T) {
|
||||
}(&status)
|
||||
|
||||
if err := r.ParseMultipartForm(1024 * 1024); err != nil {
|
||||
status = model.STATUS_FAIL
|
||||
status = model.StatusFail
|
||||
assert.Fail(t, "connect parse multipart form", err)
|
||||
return
|
||||
}
|
||||
m := r.MultipartForm
|
||||
if m == nil {
|
||||
status = model.STATUS_FAIL
|
||||
status = model.StatusFail
|
||||
assert.Fail(t, "multipart form missing")
|
||||
return
|
||||
}
|
||||
|
||||
imageArray, ok := m.File["image"]
|
||||
if !ok || len(imageArray) != 1 {
|
||||
status = model.STATUS_FAIL
|
||||
status = model.StatusFail
|
||||
assert.Fail(t, "image missing")
|
||||
return
|
||||
}
|
||||
@@ -77,7 +77,7 @@ func TestService_sendProfileImageToRemote(t *testing.T) {
|
||||
imageData := imageArray[0]
|
||||
file, err := imageData.Open()
|
||||
if err != nil {
|
||||
status = model.STATUS_FAIL
|
||||
status = model.StatusFail
|
||||
assert.Fail(t, "cannot open multipart form file")
|
||||
return
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func TestService_sendProfileImageToRemote(t *testing.T) {
|
||||
|
||||
img, err := png.Decode(file)
|
||||
if err != nil || imageWidth != img.Bounds().Max.X || imageHeight != img.Bounds().Max.Y {
|
||||
status = model.STATUS_FAIL
|
||||
status = model.StatusFail
|
||||
assert.Fail(t, "cannot decode png", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ const (
|
||||
ConfirmInviteURL = "api/v4/remotecluster/confirm_invite"
|
||||
InvitationTopic = "invitation"
|
||||
PingTopic = "ping"
|
||||
ResponseStatusOK = model.STATUS_OK
|
||||
ResponseStatusFail = model.STATUS_FAIL
|
||||
ResponseStatusOK = model.StatusOk
|
||||
ResponseStatusFail = model.StatusFail
|
||||
InviteExpiresAfter = time.Hour * 48
|
||||
)
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s *BleveEngineTestSuite) setupIndexes() {
|
||||
func (s *BleveEngineTestSuite) setupStore() {
|
||||
driverName := os.Getenv("MM_SQLSETTINGS_DRIVERNAME")
|
||||
if driverName == "" {
|
||||
driverName = model.DATABASE_DRIVER_POSTGRES
|
||||
driverName = model.DatabaseDriverPostgres
|
||||
}
|
||||
s.SQLSettings = storetest.MakeSqlSettings(driverName, false)
|
||||
s.SQLStore = sqlstore.New(*s.SQLSettings, nil)
|
||||
|
||||
@@ -25,12 +25,12 @@ func TestBleveIndexer(t *testing.T) {
|
||||
job := &model.Job{
|
||||
Id: model.NewId(),
|
||||
CreateAt: model.GetMillis(),
|
||||
Status: model.JOB_STATUS_PENDING,
|
||||
Type: model.JOB_TYPE_BLEVE_POST_INDEXING,
|
||||
Status: model.JobStatusPending,
|
||||
Type: model.JobTypeBlevePostIndexing,
|
||||
}
|
||||
|
||||
mockStore.JobStore.On("UpdateStatusOptimistically", job.Id, model.JOB_STATUS_PENDING, model.JOB_STATUS_IN_PROGRESS).Return(true, nil)
|
||||
mockStore.JobStore.On("UpdateOptimistically", job, model.JOB_STATUS_IN_PROGRESS).Return(true, nil)
|
||||
mockStore.JobStore.On("UpdateStatusOptimistically", job.Id, model.JobStatusPending, model.JobStatusInProgress).Return(true, nil)
|
||||
mockStore.JobStore.On("UpdateOptimistically", job, model.JobStatusInProgress).Return(true, nil)
|
||||
mockStore.PostStore.On("GetOldestEntityCreationTime").Return(int64(1), errors.New("")) // intentionally return error to return from function
|
||||
|
||||
tempDir, err := ioutil.TempDir("", "setupConfigFile")
|
||||
|
||||
@@ -326,7 +326,7 @@ func (b *BleveEngine) SearchChannels(teamId, term string) ([]string, *model.AppE
|
||||
}
|
||||
|
||||
query := bleve.NewSearchRequest(bleve.NewConjunctionQuery(queries...))
|
||||
query.Size = model.CHANNEL_SEARCH_DEFAULT_LIMIT
|
||||
query.Size = model.ChannelSearchDefaultLimit
|
||||
results, err := b.ChannelIndex.Search(query)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("Bleveengine.SearchChannels", "bleveengine.search_channels.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
@@ -180,7 +180,7 @@ func (scs *Service) onReceiveChannelInvite(msg model.RemoteClusterMsg, rc *model
|
||||
}
|
||||
|
||||
func (scs *Service) handleChannelCreation(invite channelInviteMsg, rc *model.RemoteCluster) (*model.Channel, error) {
|
||||
if invite.Type == model.CHANNEL_DIRECT {
|
||||
if invite.Type == model.ChannelTypeDirect {
|
||||
return scs.createDirectChannel(invite)
|
||||
}
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ func TestOnReceiveChannelInvite(t *testing.T) {
|
||||
|
||||
mockServer = scs.server.(*MockServerIface)
|
||||
mockServer.On("GetStore").Return(mockStore)
|
||||
createPostPermission := model.ChannelModeratedPermissionsMap[model.PERMISSION_CREATE_POST.Id]
|
||||
createReactionPermission := model.ChannelModeratedPermissionsMap[model.PERMISSION_ADD_REACTION.Id]
|
||||
createPostPermission := model.ChannelModeratedPermissionsMap[model.PermissionCreatePost.Id]
|
||||
createReactionPermission := model.ChannelModeratedPermissionsMap[model.PermissionAddReaction.Id]
|
||||
updateMap := model.ChannelModeratedRolesPatch{
|
||||
Guests: model.NewBool(false),
|
||||
Members: model.NewBool(false),
|
||||
@@ -166,7 +166,7 @@ func TestOnReceiveChannelInvite(t *testing.T) {
|
||||
ChannelId: model.NewId(),
|
||||
TeamId: model.NewId(),
|
||||
ReadOnly: false,
|
||||
Type: model.CHANNEL_DIRECT,
|
||||
Type: model.ChannelTypeDirect,
|
||||
DirectParticipantIDs: []string{model.NewId(), model.NewId()},
|
||||
}
|
||||
payload, err := json.Marshal(invitation)
|
||||
|
||||
@@ -211,8 +211,8 @@ func (scs *Service) pause() {
|
||||
|
||||
// Makes the remote channel to be read-only(announcement mode, only admins can create posts and reactions).
|
||||
func (scs *Service) makeChannelReadOnly(channel *model.Channel) *model.AppError {
|
||||
createPostPermission := model.ChannelModeratedPermissionsMap[model.PERMISSION_CREATE_POST.Id]
|
||||
createReactionPermission := model.ChannelModeratedPermissionsMap[model.PERMISSION_ADD_REACTION.Id]
|
||||
createPostPermission := model.ChannelModeratedPermissionsMap[model.PermissionCreatePost.Id]
|
||||
createReactionPermission := model.ChannelModeratedPermissionsMap[model.PermissionAddReaction.Id]
|
||||
updateMap := model.ChannelModeratedRolesPatch{
|
||||
Guests: model.NewBool(false),
|
||||
Members: model.NewBool(false),
|
||||
|
||||
@@ -99,7 +99,7 @@ func (scs *Service) processSyncMessage(syncMsg *syncMsg, rc *model.RemoteCluster
|
||||
continue
|
||||
}
|
||||
|
||||
if channel.Type != model.CHANNEL_DIRECT && team == nil {
|
||||
if channel.Type != model.ChannelTypeDirect && team == nil {
|
||||
var err2 error
|
||||
team, err2 = scs.server.GetStore().Channel().GetTeamForChannel(syncMsg.ChannelId)
|
||||
if err2 != nil {
|
||||
@@ -244,8 +244,8 @@ func (scs *Service) insertSyncUser(user *model.User, channel *model.Channel, rc
|
||||
suffix = strconv.FormatInt(int64(i), 10)
|
||||
}
|
||||
|
||||
user.Username = mungUsername(user.Username, rc.Name, suffix, model.USER_NAME_MAX_LENGTH)
|
||||
user.Email = mungEmail(rc.Name, model.USER_EMAIL_MAX_LENGTH)
|
||||
user.Username = mungUsername(user.Username, rc.Name, suffix, model.UserNameMaxLength)
|
||||
user.Email = mungEmail(rc.Name, model.UserEmailMaxLength)
|
||||
|
||||
if userSaved, err = scs.server.GetStore().User().Save(user); err != nil {
|
||||
e, ok := err.(errInvalidInput)
|
||||
@@ -298,8 +298,8 @@ func (scs *Service) updateSyncUser(patch *model.UserPatch, user *model.User, cha
|
||||
if i > 1 {
|
||||
suffix = strconv.FormatInt(int64(i), 10)
|
||||
}
|
||||
user.Username = mungUsername(user.Username, rc.Name, suffix, model.USER_NAME_MAX_LENGTH)
|
||||
user.Email = mungEmail(rc.Name, model.USER_EMAIL_MAX_LENGTH)
|
||||
user.Username = mungUsername(user.Username, rc.Name, suffix, model.UserNameMaxLength)
|
||||
user.Email = mungEmail(rc.Name, model.UserEmailMaxLength)
|
||||
|
||||
if update, err = scs.server.GetStore().User().Update(user, false); err != nil {
|
||||
e, ok := err.(errInvalidInput)
|
||||
|
||||
@@ -361,7 +361,7 @@ func (scs *Service) getUserTranslations(userId string) i18n.TranslateFunc {
|
||||
}
|
||||
|
||||
if locale == "" {
|
||||
locale = model.DEFAULT_LOCALE
|
||||
locale = model.DefaultLocale
|
||||
}
|
||||
return i18n.GetUserTranslations(locale)
|
||||
}
|
||||
|
||||
@@ -143,16 +143,16 @@ func (si *SlackImporter) SlackImport(fileData multipart.File, fileSize int64, te
|
||||
return model.NewAppError("SlackImport", "api.slackimport.slack_import.open.app_error", map[string]interface{}{"Filename": file.Name}, err.Error(), http.StatusInternalServerError), log
|
||||
}
|
||||
if file.Name == "channels.json" {
|
||||
publicChannels, _ = slackParseChannels(reader, model.CHANNEL_OPEN)
|
||||
publicChannels, _ = slackParseChannels(reader, model.ChannelTypeOpen)
|
||||
channels = append(channels, publicChannels...)
|
||||
} else if file.Name == "dms.json" {
|
||||
directChannels, _ = slackParseChannels(reader, model.CHANNEL_DIRECT)
|
||||
directChannels, _ = slackParseChannels(reader, model.ChannelTypeDirect)
|
||||
channels = append(channels, directChannels...)
|
||||
} else if file.Name == "groups.json" {
|
||||
privateChannels, _ = slackParseChannels(reader, model.CHANNEL_PRIVATE)
|
||||
privateChannels, _ = slackParseChannels(reader, model.ChannelTypePrivate)
|
||||
channels = append(channels, privateChannels...)
|
||||
} else if file.Name == "mpims.json" {
|
||||
groupChannels, _ = slackParseChannels(reader, model.CHANNEL_GROUP)
|
||||
groupChannels, _ = slackParseChannels(reader, model.ChannelTypeGroup)
|
||||
channels = append(channels, groupChannels...)
|
||||
} else if file.Name == "users.json" {
|
||||
users, _ = slackParseUsers(reader)
|
||||
@@ -378,7 +378,7 @@ func (si *SlackImporter) slackAddPosts(teamId string, channel *model.Channel, po
|
||||
ChannelId: channel.Id,
|
||||
CreateAt: slackConvertTimeStamp(sPost.TimeStamp),
|
||||
Message: sPost.Text,
|
||||
Type: model.POST_SLACK_ATTACHMENT,
|
||||
Type: model.PostTypeSlackAttachment,
|
||||
}
|
||||
|
||||
postId := si.oldImportIncomingWebhookPost(post, props)
|
||||
@@ -398,9 +398,9 @@ func (si *SlackImporter) slackAddPosts(teamId string, channel *model.Channel, po
|
||||
|
||||
var postType string
|
||||
if sPost.SubType == "channel_join" {
|
||||
postType = model.POST_JOIN_CHANNEL
|
||||
postType = model.PostTypeJoinChannel
|
||||
} else {
|
||||
postType = model.POST_LEAVE_CHANNEL
|
||||
postType = model.PostTypeLeaveChannel
|
||||
}
|
||||
|
||||
newPost := model.Post{
|
||||
@@ -448,7 +448,7 @@ func (si *SlackImporter) slackAddPosts(teamId string, channel *model.Channel, po
|
||||
ChannelId: channel.Id,
|
||||
Message: sPost.Text,
|
||||
CreateAt: slackConvertTimeStamp(sPost.TimeStamp),
|
||||
Type: model.POST_HEADER_CHANGE,
|
||||
Type: model.PostTypeHeaderChange,
|
||||
}
|
||||
si.oldImportPost(&newPost)
|
||||
case sPost.Type == "message" && sPost.SubType == "channel_purpose":
|
||||
@@ -465,7 +465,7 @@ func (si *SlackImporter) slackAddPosts(teamId string, channel *model.Channel, po
|
||||
ChannelId: channel.Id,
|
||||
Message: sPost.Text,
|
||||
CreateAt: slackConvertTimeStamp(sPost.TimeStamp),
|
||||
Type: model.POST_PURPOSE_CHANGE,
|
||||
Type: model.PostTypePurposeChange,
|
||||
}
|
||||
si.oldImportPost(&newPost)
|
||||
case sPost.Type == "message" && sPost.SubType == "channel_name":
|
||||
@@ -482,7 +482,7 @@ func (si *SlackImporter) slackAddPosts(teamId string, channel *model.Channel, po
|
||||
ChannelId: channel.Id,
|
||||
Message: sPost.Text,
|
||||
CreateAt: slackConvertTimeStamp(sPost.TimeStamp),
|
||||
Type: model.POST_DISPLAYNAME_CHANGE,
|
||||
Type: model.PostTypeDisplaynameChange,
|
||||
}
|
||||
si.oldImportPost(&newPost)
|
||||
default:
|
||||
@@ -542,24 +542,24 @@ func (si *SlackImporter) addSlackUsersToChannel(members []string, users map[stri
|
||||
}
|
||||
|
||||
func slackSanitiseChannelProperties(channel model.Channel) model.Channel {
|
||||
if utf8.RuneCountInString(channel.DisplayName) > model.CHANNEL_DISPLAY_NAME_MAX_RUNES {
|
||||
if utf8.RuneCountInString(channel.DisplayName) > model.ChannelDisplayNameMaxRunes {
|
||||
mlog.Warn("Slack Import: Channel display name exceeds the maximum length. It will be truncated when imported.", mlog.String("channel_display_name", channel.DisplayName))
|
||||
channel.DisplayName = truncateRunes(channel.DisplayName, model.CHANNEL_DISPLAY_NAME_MAX_RUNES)
|
||||
channel.DisplayName = truncateRunes(channel.DisplayName, model.ChannelDisplayNameMaxRunes)
|
||||
}
|
||||
|
||||
if len(channel.Name) > model.CHANNEL_NAME_MAX_LENGTH {
|
||||
if len(channel.Name) > model.ChannelNameMaxLength {
|
||||
mlog.Warn("Slack Import: Channel handle exceeds the maximum length. It will be truncated when imported.", mlog.String("channel_display_name", channel.DisplayName))
|
||||
channel.Name = channel.Name[0:model.CHANNEL_NAME_MAX_LENGTH]
|
||||
channel.Name = channel.Name[0:model.ChannelNameMaxLength]
|
||||
}
|
||||
|
||||
if utf8.RuneCountInString(channel.Purpose) > model.CHANNEL_PURPOSE_MAX_RUNES {
|
||||
if utf8.RuneCountInString(channel.Purpose) > model.ChannelPurposeMaxRunes {
|
||||
mlog.Warn("Slack Import: Channel purpose exceeds the maximum length. It will be truncated when imported.", mlog.String("channel_display_name", channel.DisplayName))
|
||||
channel.Purpose = truncateRunes(channel.Purpose, model.CHANNEL_PURPOSE_MAX_RUNES)
|
||||
channel.Purpose = truncateRunes(channel.Purpose, model.ChannelPurposeMaxRunes)
|
||||
}
|
||||
|
||||
if utf8.RuneCountInString(channel.Header) > model.CHANNEL_HEADER_MAX_RUNES {
|
||||
if utf8.RuneCountInString(channel.Header) > model.ChannelHeaderMaxRunes {
|
||||
mlog.Warn("Slack Import: Channel header exceeds the maximum length. It will be truncated when imported.", mlog.String("channel_display_name", channel.DisplayName))
|
||||
channel.Header = truncateRunes(channel.Header, model.CHANNEL_HEADER_MAX_RUNES)
|
||||
channel.Header = truncateRunes(channel.Header, model.ChannelHeaderMaxRunes)
|
||||
}
|
||||
|
||||
return channel
|
||||
@@ -582,7 +582,7 @@ func (si *SlackImporter) slackAddChannels(teamId string, slackchannels []slackCh
|
||||
}
|
||||
|
||||
// Direct message channels in Slack don't have a name so we set the id as name or else the messages won't get imported.
|
||||
if newChannel.Type == model.CHANNEL_DIRECT {
|
||||
if newChannel.Type == model.ChannelTypeDirect {
|
||||
sChannel.Name = sChannel.Id
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ func (si *SlackImporter) slackAddChannels(teamId string, slackchannels []slackCh
|
||||
}
|
||||
|
||||
// Members for direct and group channels are added during the creation of the channel in the oldImportChannel function
|
||||
if sChannel.Type == model.CHANNEL_OPEN || sChannel.Type == model.CHANNEL_PRIVATE {
|
||||
if sChannel.Type == model.ChannelTypeOpen || sChannel.Type == model.ChannelTypePrivate {
|
||||
si.addSlackUsersToChannel(sChannel.Members, users, mChannel, importerLog)
|
||||
}
|
||||
importerLog.WriteString(newChannel.DisplayName + "\r\n")
|
||||
@@ -683,7 +683,7 @@ func (si *SlackImporter) oldImportPost(post *model.Post) string {
|
||||
func (si *SlackImporter) oldImportUser(team *model.Team, user *model.User) *model.User {
|
||||
user.MakeNonNil()
|
||||
|
||||
user.Roles = model.SYSTEM_USER_ROLE_ID
|
||||
user.Roles = model.SystemUserRoleId
|
||||
|
||||
ruser, nErr := si.store.User().Save(user)
|
||||
if nErr != nil {
|
||||
@@ -704,7 +704,7 @@ func (si *SlackImporter) oldImportUser(team *model.Team, user *model.User) *mode
|
||||
|
||||
func (si *SlackImporter) oldImportChannel(channel *model.Channel, sChannel slackChannel, users map[string]*model.User) *model.Channel {
|
||||
switch {
|
||||
case channel.Type == model.CHANNEL_DIRECT:
|
||||
case channel.Type == model.ChannelTypeDirect:
|
||||
if len(sChannel.Members) < 2 {
|
||||
return nil
|
||||
}
|
||||
@@ -721,7 +721,7 @@ func (si *SlackImporter) oldImportChannel(channel *model.Channel, sChannel slack
|
||||
|
||||
return sc
|
||||
// check if direct channel has less than 8 members and if not import as private channel instead
|
||||
case channel.Type == model.CHANNEL_GROUP && len(sChannel.Members) < 8:
|
||||
case channel.Type == model.ChannelTypeGroup && len(sChannel.Members) < 8:
|
||||
members := make([]string, len(sChannel.Members))
|
||||
|
||||
for i := range sChannel.Members {
|
||||
@@ -743,8 +743,8 @@ func (si *SlackImporter) oldImportChannel(channel *model.Channel, sChannel slack
|
||||
}
|
||||
|
||||
return sc
|
||||
case channel.Type == model.CHANNEL_GROUP:
|
||||
channel.Type = model.CHANNEL_PRIVATE
|
||||
case channel.Type == model.ChannelTypeGroup:
|
||||
channel.Type = model.ChannelTypePrivate
|
||||
sc, err := si.actions.CreateChannel(channel, false)
|
||||
if err != nil {
|
||||
return nil
|
||||
@@ -791,7 +791,7 @@ func (si *SlackImporter) oldImportIncomingWebhookPost(post *model.Post, props mo
|
||||
post.AddProp("from_webhook", "true")
|
||||
|
||||
if _, ok := props["override_username"]; !ok {
|
||||
post.AddProp("override_username", model.DEFAULT_WEBHOOK_USERNAME)
|
||||
post.AddProp("override_username", model.DefaultWebhookUsername)
|
||||
}
|
||||
|
||||
if len(props) > 0 {
|
||||
|
||||
@@ -329,7 +329,7 @@ func TestOldImportChannel(t *testing.T) {
|
||||
t.Run("No panic on direct channel", func(t *testing.T) {
|
||||
//ch := th.CreateDmChannel(u1)
|
||||
ch := &model.Channel{
|
||||
Type: model.CHANNEL_DIRECT,
|
||||
Type: model.ChannelTypeDirect,
|
||||
Name: "test-channel",
|
||||
}
|
||||
users := map[string]*model.User{
|
||||
@@ -349,7 +349,7 @@ func TestOldImportChannel(t *testing.T) {
|
||||
|
||||
t.Run("No panic on direct channel with 1 member", func(t *testing.T) {
|
||||
ch := &model.Channel{
|
||||
Type: model.CHANNEL_DIRECT,
|
||||
Type: model.ChannelTypeDirect,
|
||||
Name: "test-channel",
|
||||
}
|
||||
users := map[string]*model.User{
|
||||
@@ -369,7 +369,7 @@ func TestOldImportChannel(t *testing.T) {
|
||||
|
||||
t.Run("No panic on group channel", func(t *testing.T) {
|
||||
ch := &model.Channel{
|
||||
Type: model.CHANNEL_GROUP,
|
||||
Type: model.ChannelTypeGroup,
|
||||
Name: "test-channel",
|
||||
}
|
||||
users := map[string]*model.User{
|
||||
|
||||
@@ -44,7 +44,7 @@ const (
|
||||
TrackConfigEmail = "config_email"
|
||||
TrackConfigPrivacy = "config_privacy"
|
||||
TrackConfigTheme = "config_theme"
|
||||
TrackConfigOauth = "config_oauth"
|
||||
TrackConfigOAuth = "config_oauth"
|
||||
TrackConfigLDAP = "config_ldap"
|
||||
TrackConfigCompliance = "config_compliance"
|
||||
TrackConfigLocalization = "config_localization"
|
||||
@@ -128,10 +128,10 @@ func (ts *TelemetryService) ensureTelemetryID() {
|
||||
return
|
||||
}
|
||||
|
||||
id := props[model.SYSTEM_TELEMETRY_ID]
|
||||
id := props[model.SystemTelemetryId]
|
||||
if id == "" {
|
||||
id = model.NewId()
|
||||
systemID := &model.System{Name: model.SYSTEM_TELEMETRY_ID, Value: id}
|
||||
systemID := &model.System{Name: model.SystemTelemetryId, Value: id}
|
||||
ts.dbStore.System().Save(systemID)
|
||||
}
|
||||
|
||||
@@ -373,8 +373,8 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"enable_custom_emoji": *cfg.ServiceSettings.EnableCustomEmoji,
|
||||
"enable_emoji_picker": *cfg.ServiceSettings.EnableEmojiPicker,
|
||||
"enable_gif_picker": *cfg.ServiceSettings.EnableGifPicker,
|
||||
"gfycat_api_key": isDefault(*cfg.ServiceSettings.GfycatApiKey, model.SERVICE_SETTINGS_DEFAULT_GFYCAT_API_KEY),
|
||||
"gfycat_api_secret": isDefault(*cfg.ServiceSettings.GfycatApiSecret, model.SERVICE_SETTINGS_DEFAULT_GFYCAT_API_SECRET),
|
||||
"gfycat_api_key": isDefault(*cfg.ServiceSettings.GfycatApiKey, model.ServiceSettingsDefaultGfycatApiKey),
|
||||
"gfycat_api_secret": isDefault(*cfg.ServiceSettings.GfycatApiSecret, model.ServiceSettingsDefaultGfycatApiSecret),
|
||||
"experimental_enable_authentication_transfer": *cfg.ServiceSettings.ExperimentalEnableAuthenticationTransfer,
|
||||
"restrict_custom_emoji_creation": *cfg.ServiceSettings.DEPRECATED_DO_NOT_USE_RestrictCustomEmojiCreation,
|
||||
"enable_testing": cfg.ServiceSettings.EnableTesting,
|
||||
@@ -393,14 +393,14 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"session_length_sso_in_days": *cfg.ServiceSettings.SessionLengthSSOInDays,
|
||||
"session_cache_in_minutes": *cfg.ServiceSettings.SessionCacheInMinutes,
|
||||
"session_idle_timeout_in_minutes": *cfg.ServiceSettings.SessionIdleTimeoutInMinutes,
|
||||
"isdefault_site_url": isDefault(*cfg.ServiceSettings.SiteURL, model.SERVICE_SETTINGS_DEFAULT_SITE_URL),
|
||||
"isdefault_tls_cert_file": isDefault(*cfg.ServiceSettings.TLSCertFile, model.SERVICE_SETTINGS_DEFAULT_TLS_CERT_FILE),
|
||||
"isdefault_tls_key_file": isDefault(*cfg.ServiceSettings.TLSKeyFile, model.SERVICE_SETTINGS_DEFAULT_TLS_KEY_FILE),
|
||||
"isdefault_read_timeout": isDefault(*cfg.ServiceSettings.ReadTimeout, model.SERVICE_SETTINGS_DEFAULT_READ_TIMEOUT),
|
||||
"isdefault_write_timeout": isDefault(*cfg.ServiceSettings.WriteTimeout, model.SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT),
|
||||
"isdefault_idle_timeout": isDefault(*cfg.ServiceSettings.IdleTimeout, model.SERVICE_SETTINGS_DEFAULT_IDLE_TIMEOUT),
|
||||
"isdefault_site_url": isDefault(*cfg.ServiceSettings.SiteURL, model.ServiceSettingsDefaultSiteUrl),
|
||||
"isdefault_tls_cert_file": isDefault(*cfg.ServiceSettings.TLSCertFile, model.ServiceSettingsDefaultTlsCertFile),
|
||||
"isdefault_tls_key_file": isDefault(*cfg.ServiceSettings.TLSKeyFile, model.ServiceSettingsDefaultTlsKeyFile),
|
||||
"isdefault_read_timeout": isDefault(*cfg.ServiceSettings.ReadTimeout, model.ServiceSettingsDefaultReadTimeout),
|
||||
"isdefault_write_timeout": isDefault(*cfg.ServiceSettings.WriteTimeout, model.ServiceSettingsDefaultWriteTimeout),
|
||||
"isdefault_idle_timeout": isDefault(*cfg.ServiceSettings.IdleTimeout, model.ServiceSettingsDefaultIdleTimeout),
|
||||
"isdefault_google_developer_key": isDefault(cfg.ServiceSettings.GoogleDeveloperKey, ""),
|
||||
"isdefault_allow_cors_from": isDefault(*cfg.ServiceSettings.AllowCorsFrom, model.SERVICE_SETTINGS_DEFAULT_ALLOW_CORS_FROM),
|
||||
"isdefault_allow_cors_from": isDefault(*cfg.ServiceSettings.AllowCorsFrom, model.ServiceSettingsDefaultAllowCorsFrom),
|
||||
"isdefault_cors_exposed_headers": isDefault(cfg.ServiceSettings.CorsExposedHeaders, ""),
|
||||
"cors_allow_credentials": *cfg.ServiceSettings.CorsAllowCredentials,
|
||||
"cors_debug": *cfg.ServiceSettings.CorsDebug,
|
||||
@@ -468,9 +468,9 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"experimental_view_archived_channels": *cfg.TeamSettings.ExperimentalViewArchivedChannels,
|
||||
"lock_teammate_name_display": *cfg.TeamSettings.LockTeammateNameDisplay,
|
||||
"isdefault_site_name": isDefault(cfg.TeamSettings.SiteName, "Mattermost"),
|
||||
"isdefault_custom_brand_text": isDefault(*cfg.TeamSettings.CustomBrandText, model.TEAM_SETTINGS_DEFAULT_CUSTOM_BRAND_TEXT),
|
||||
"isdefault_custom_description_text": isDefault(*cfg.TeamSettings.CustomDescriptionText, model.TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT),
|
||||
"isdefault_user_status_away_timeout": isDefault(*cfg.TeamSettings.UserStatusAwayTimeout, model.TEAM_SETTINGS_DEFAULT_USER_STATUS_AWAY_TIMEOUT),
|
||||
"isdefault_custom_brand_text": isDefault(*cfg.TeamSettings.CustomBrandText, model.TeamSettingsDefaultCustomBrandText),
|
||||
"isdefault_custom_description_text": isDefault(*cfg.TeamSettings.CustomDescriptionText, model.TeamSettingsDefaultCustomDescriptionText),
|
||||
"isdefault_user_status_away_timeout": isDefault(*cfg.TeamSettings.UserStatusAwayTimeout, model.TeamSettingsDefaultUserStatusAwayTimeout),
|
||||
"restrict_private_channel_manage_members": *cfg.TeamSettings.DEPRECATED_DO_NOT_USE_RestrictPrivateChannelManageMembers,
|
||||
"enable_X_to_leave_channels_from_LHS": *cfg.TeamSettings.EnableXToLeaveChannelsFromLHS,
|
||||
"experimental_enable_automatic_replies": *cfg.TeamSettings.ExperimentalEnableAutomaticReplies,
|
||||
@@ -546,7 +546,7 @@ func (ts *TelemetryService) trackConfig() {
|
||||
ts.sendTelemetry(TrackConfigFile, map[string]interface{}{
|
||||
"enable_public_links": cfg.FileSettings.EnablePublicLink,
|
||||
"driver_name": *cfg.FileSettings.DriverName,
|
||||
"isdefault_directory": isDefault(*cfg.FileSettings.Directory, model.FILE_SETTINGS_DEFAULT_DIRECTORY),
|
||||
"isdefault_directory": isDefault(*cfg.FileSettings.Directory, model.FileSettingsDefaultDirectory),
|
||||
"isabsolute_directory": filepath.IsAbs(*cfg.FileSettings.Directory),
|
||||
"extract_content": *cfg.FileSettings.ExtractContent,
|
||||
"archive_recursion": *cfg.FileSettings.ArchiveRecursion,
|
||||
@@ -579,7 +579,7 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"isdefault_feedback_name": isDefault(cfg.EmailSettings.FeedbackName, ""),
|
||||
"isdefault_feedback_email": isDefault(cfg.EmailSettings.FeedbackEmail, ""),
|
||||
"isdefault_reply_to_address": isDefault(cfg.EmailSettings.ReplyToAddress, ""),
|
||||
"isdefault_feedback_organization": isDefault(*cfg.EmailSettings.FeedbackOrganization, model.EMAIL_SETTINGS_DEFAULT_FEEDBACK_ORGANIZATION),
|
||||
"isdefault_feedback_organization": isDefault(*cfg.EmailSettings.FeedbackOrganization, model.EmailSettingsDefaultFeedbackOrganization),
|
||||
"skip_server_certificate_verification": *cfg.EmailSettings.SkipServerCertificateVerification,
|
||||
"isdefault_login_button_color": isDefault(*cfg.EmailSettings.LoginButtonColor, ""),
|
||||
"isdefault_login_button_border_color": isDefault(*cfg.EmailSettings.LoginButtonBorderColor, ""),
|
||||
@@ -604,28 +604,28 @@ func (ts *TelemetryService) trackConfig() {
|
||||
|
||||
ts.sendTelemetry(TrackConfigTheme, map[string]interface{}{
|
||||
"enable_theme_selection": *cfg.ThemeSettings.EnableThemeSelection,
|
||||
"isdefault_default_theme": isDefault(*cfg.ThemeSettings.DefaultTheme, model.TEAM_SETTINGS_DEFAULT_TEAM_TEXT),
|
||||
"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]interface{}{
|
||||
"enable_gitlab": cfg.GitLabSettings.Enable,
|
||||
"openid_gitlab": *cfg.GitLabSettings.Enable && strings.Contains(*cfg.GitLabSettings.Scope, model.SERVICE_OPENID),
|
||||
"openid_gitlab": *cfg.GitLabSettings.Enable && strings.Contains(*cfg.GitLabSettings.Scope, model.ServiceOpenid),
|
||||
"enable_google": cfg.GoogleSettings.Enable,
|
||||
"openid_google": *cfg.GoogleSettings.Enable && strings.Contains(*cfg.GoogleSettings.Scope, model.SERVICE_OPENID),
|
||||
"openid_google": *cfg.GoogleSettings.Enable && strings.Contains(*cfg.GoogleSettings.Scope, model.ServiceOpenid),
|
||||
"enable_office365": cfg.Office365Settings.Enable,
|
||||
"openid_office365": *cfg.Office365Settings.Enable && strings.Contains(*cfg.Office365Settings.Scope, model.SERVICE_OPENID),
|
||||
"openid_office365": *cfg.Office365Settings.Enable && strings.Contains(*cfg.Office365Settings.Scope, model.ServiceOpenid),
|
||||
"enable_openid": cfg.OpenIdSettings.Enable,
|
||||
})
|
||||
|
||||
ts.sendTelemetry(TrackConfigSupport, map[string]interface{}{
|
||||
"isdefault_terms_of_service_link": isDefault(*cfg.SupportSettings.TermsOfServiceLink, model.SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK),
|
||||
"isdefault_privacy_policy_link": isDefault(*cfg.SupportSettings.PrivacyPolicyLink, model.SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK),
|
||||
"isdefault_about_link": isDefault(*cfg.SupportSettings.AboutLink, model.SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK),
|
||||
"isdefault_help_link": isDefault(*cfg.SupportSettings.HelpLink, model.SUPPORT_SETTINGS_DEFAULT_HELP_LINK),
|
||||
"isdefault_report_a_problem_link": isDefault(*cfg.SupportSettings.ReportAProblemLink, model.SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK),
|
||||
"isdefault_support_email": isDefault(*cfg.SupportSettings.SupportEmail, model.SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL),
|
||||
"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),
|
||||
"isdefault_help_link": isDefault(*cfg.SupportSettings.HelpLink, model.SupportSettingsDefaultHelpLink),
|
||||
"isdefault_report_a_problem_link": isDefault(*cfg.SupportSettings.ReportAProblemLink, model.SupportSettingsDefaultReportAProblemLink),
|
||||
"isdefault_support_email": isDefault(*cfg.SupportSettings.SupportEmail, model.SupportSettingsDefaultSupportEmail),
|
||||
"custom_terms_of_service_enabled": *cfg.SupportSettings.CustomTermsOfServiceEnabled,
|
||||
"custom_terms_of_service_re_acceptance_period": *cfg.SupportSettings.CustomTermsOfServiceReAcceptancePeriod,
|
||||
"enable_ask_community_link": *cfg.SupportSettings.EnableAskCommunityLink,
|
||||
@@ -640,21 +640,21 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"sync_interval_minutes": *cfg.LdapSettings.SyncIntervalMinutes,
|
||||
"query_timeout": *cfg.LdapSettings.QueryTimeout,
|
||||
"max_page_size": *cfg.LdapSettings.MaxPageSize,
|
||||
"isdefault_first_name_attribute": isDefault(*cfg.LdapSettings.FirstNameAttribute, model.LDAP_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE),
|
||||
"isdefault_last_name_attribute": isDefault(*cfg.LdapSettings.LastNameAttribute, model.LDAP_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE),
|
||||
"isdefault_email_attribute": isDefault(*cfg.LdapSettings.EmailAttribute, model.LDAP_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE),
|
||||
"isdefault_username_attribute": isDefault(*cfg.LdapSettings.UsernameAttribute, model.LDAP_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE),
|
||||
"isdefault_nickname_attribute": isDefault(*cfg.LdapSettings.NicknameAttribute, model.LDAP_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE),
|
||||
"isdefault_id_attribute": isDefault(*cfg.LdapSettings.IdAttribute, model.LDAP_SETTINGS_DEFAULT_ID_ATTRIBUTE),
|
||||
"isdefault_position_attribute": isDefault(*cfg.LdapSettings.PositionAttribute, model.LDAP_SETTINGS_DEFAULT_POSITION_ATTRIBUTE),
|
||||
"isdefault_first_name_attribute": isDefault(*cfg.LdapSettings.FirstNameAttribute, model.LdapSettingsDefaultFirstNameAttribute),
|
||||
"isdefault_last_name_attribute": isDefault(*cfg.LdapSettings.LastNameAttribute, model.LdapSettingsDefaultLastNameAttribute),
|
||||
"isdefault_email_attribute": isDefault(*cfg.LdapSettings.EmailAttribute, model.LdapSettingsDefaultEmailAttribute),
|
||||
"isdefault_username_attribute": isDefault(*cfg.LdapSettings.UsernameAttribute, model.LdapSettingsDefaultUsernameAttribute),
|
||||
"isdefault_nickname_attribute": isDefault(*cfg.LdapSettings.NicknameAttribute, model.LdapSettingsDefaultNicknameAttribute),
|
||||
"isdefault_id_attribute": isDefault(*cfg.LdapSettings.IdAttribute, model.LdapSettingsDefaultIdAttribute),
|
||||
"isdefault_position_attribute": isDefault(*cfg.LdapSettings.PositionAttribute, model.LdapSettingsDefaultPositionAttribute),
|
||||
"isdefault_login_id_attribute": isDefault(*cfg.LdapSettings.LoginIdAttribute, ""),
|
||||
"isdefault_login_field_name": isDefault(*cfg.LdapSettings.LoginFieldName, model.LDAP_SETTINGS_DEFAULT_LOGIN_FIELD_NAME),
|
||||
"isdefault_login_field_name": isDefault(*cfg.LdapSettings.LoginFieldName, model.LdapSettingsDefaultLoginFieldName),
|
||||
"isdefault_login_button_color": isDefault(*cfg.LdapSettings.LoginButtonColor, ""),
|
||||
"isdefault_login_button_border_color": isDefault(*cfg.LdapSettings.LoginButtonBorderColor, ""),
|
||||
"isdefault_login_button_text_color": isDefault(*cfg.LdapSettings.LoginButtonTextColor, ""),
|
||||
"isempty_group_filter": isDefault(*cfg.LdapSettings.GroupFilter, ""),
|
||||
"isdefault_group_display_name_attribute": isDefault(*cfg.LdapSettings.GroupDisplayNameAttribute, model.LDAP_SETTINGS_DEFAULT_GROUP_DISPLAY_NAME_ATTRIBUTE),
|
||||
"isdefault_group_id_attribute": isDefault(*cfg.LdapSettings.GroupIdAttribute, model.LDAP_SETTINGS_DEFAULT_GROUP_ID_ATTRIBUTE),
|
||||
"isdefault_group_display_name_attribute": isDefault(*cfg.LdapSettings.GroupDisplayNameAttribute, model.LdapSettingsDefaultGroupDisplayNameAttribute),
|
||||
"isdefault_group_id_attribute": isDefault(*cfg.LdapSettings.GroupIdAttribute, model.LdapSettingsDefaultGroupIdAttribute),
|
||||
"isempty_guest_filter": isDefault(*cfg.LdapSettings.GuestFilter, ""),
|
||||
"isempty_admin_filter": isDefault(*cfg.LdapSettings.AdminFilter, ""),
|
||||
"isnotempty_picture_attribute": !isDefault(*cfg.LdapSettings.PictureAttribute, ""),
|
||||
@@ -686,17 +686,17 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"isdefault_canonical_algorithm": isDefault(*cfg.SamlSettings.CanonicalAlgorithm, ""),
|
||||
"isdefault_scoping_idp_provider_id": isDefault(*cfg.SamlSettings.ScopingIDPProviderId, ""),
|
||||
"isdefault_scoping_idp_name": isDefault(*cfg.SamlSettings.ScopingIDPName, ""),
|
||||
"isdefault_id_attribute": isDefault(*cfg.SamlSettings.IdAttribute, model.SAML_SETTINGS_DEFAULT_ID_ATTRIBUTE),
|
||||
"isdefault_guest_attribute": isDefault(*cfg.SamlSettings.GuestAttribute, model.SAML_SETTINGS_DEFAULT_GUEST_ATTRIBUTE),
|
||||
"isdefault_admin_attribute": isDefault(*cfg.SamlSettings.AdminAttribute, model.SAML_SETTINGS_DEFAULT_ADMIN_ATTRIBUTE),
|
||||
"isdefault_first_name_attribute": isDefault(*cfg.SamlSettings.FirstNameAttribute, model.SAML_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE),
|
||||
"isdefault_last_name_attribute": isDefault(*cfg.SamlSettings.LastNameAttribute, model.SAML_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE),
|
||||
"isdefault_email_attribute": isDefault(*cfg.SamlSettings.EmailAttribute, model.SAML_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE),
|
||||
"isdefault_username_attribute": isDefault(*cfg.SamlSettings.UsernameAttribute, model.SAML_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE),
|
||||
"isdefault_nickname_attribute": isDefault(*cfg.SamlSettings.NicknameAttribute, model.SAML_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE),
|
||||
"isdefault_locale_attribute": isDefault(*cfg.SamlSettings.LocaleAttribute, model.SAML_SETTINGS_DEFAULT_LOCALE_ATTRIBUTE),
|
||||
"isdefault_position_attribute": isDefault(*cfg.SamlSettings.PositionAttribute, model.SAML_SETTINGS_DEFAULT_POSITION_ATTRIBUTE),
|
||||
"isdefault_login_button_text": isDefault(*cfg.SamlSettings.LoginButtonText, model.USER_AUTH_SERVICE_SAML_TEXT),
|
||||
"isdefault_id_attribute": isDefault(*cfg.SamlSettings.IdAttribute, model.SamlSettingsDefaultIdAttribute),
|
||||
"isdefault_guest_attribute": isDefault(*cfg.SamlSettings.GuestAttribute, model.SamlSettingsDefaultGuestAttribute),
|
||||
"isdefault_admin_attribute": isDefault(*cfg.SamlSettings.AdminAttribute, model.SamlSettingsDefaultAdminAttribute),
|
||||
"isdefault_first_name_attribute": isDefault(*cfg.SamlSettings.FirstNameAttribute, model.SamlSettingsDefaultFirstNameAttribute),
|
||||
"isdefault_last_name_attribute": isDefault(*cfg.SamlSettings.LastNameAttribute, model.SamlSettingsDefaultLastNameAttribute),
|
||||
"isdefault_email_attribute": isDefault(*cfg.SamlSettings.EmailAttribute, model.SamlSettingsDefaultEmailAttribute),
|
||||
"isdefault_username_attribute": isDefault(*cfg.SamlSettings.UsernameAttribute, model.SamlSettingsDefaultUsernameAttribute),
|
||||
"isdefault_nickname_attribute": isDefault(*cfg.SamlSettings.NicknameAttribute, model.SamlSettingsDefaultNicknameAttribute),
|
||||
"isdefault_locale_attribute": isDefault(*cfg.SamlSettings.LocaleAttribute, model.SamlSettingsDefaultLocaleAttribute),
|
||||
"isdefault_position_attribute": isDefault(*cfg.SamlSettings.PositionAttribute, model.SamlSettingsDefaultPositionAttribute),
|
||||
"isdefault_login_button_text": isDefault(*cfg.SamlSettings.LoginButtonText, model.UserAuthServiceSamlText),
|
||||
"isdefault_login_button_color": isDefault(*cfg.SamlSettings.LoginButtonColor, ""),
|
||||
"isdefault_login_button_border_color": isDefault(*cfg.SamlSettings.LoginButtonBorderColor, ""),
|
||||
"isdefault_login_button_text_color": isDefault(*cfg.SamlSettings.LoginButtonTextColor, ""),
|
||||
@@ -720,14 +720,14 @@ func (ts *TelemetryService) trackConfig() {
|
||||
|
||||
ts.sendTelemetry(TrackConfigNativeApp, map[string]interface{}{
|
||||
"isdefault_app_custom_url_schemes": isDefaultArray(cfg.NativeAppSettings.AppCustomURLSchemes, model.GetDefaultAppCustomURLSchemes()),
|
||||
"isdefault_app_download_link": isDefault(*cfg.NativeAppSettings.AppDownloadLink, model.NATIVEAPP_SETTINGS_DEFAULT_APP_DOWNLOAD_LINK),
|
||||
"isdefault_android_app_download_link": isDefault(*cfg.NativeAppSettings.AndroidAppDownloadLink, model.NATIVEAPP_SETTINGS_DEFAULT_ANDROID_APP_DOWNLOAD_LINK),
|
||||
"isdefault_iosapp_download_link": isDefault(*cfg.NativeAppSettings.IosAppDownloadLink, model.NATIVEAPP_SETTINGS_DEFAULT_IOS_APP_DOWNLOAD_LINK),
|
||||
"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{}{
|
||||
"client_side_cert_enable": *cfg.ExperimentalSettings.ClientSideCertEnable,
|
||||
"isdefault_client_side_cert_check": isDefault(*cfg.ExperimentalSettings.ClientSideCertCheck, model.CLIENT_SIDE_CERT_CHECK_PRIMARY_AUTH),
|
||||
"isdefault_client_side_cert_check": isDefault(*cfg.ExperimentalSettings.ClientSideCertCheck, model.ClientSideCertCheckPrimaryAuth),
|
||||
"link_metadata_timeout_milliseconds": *cfg.ExperimentalSettings.LinkMetadataTimeoutMilliseconds,
|
||||
"enable_click_to_reply": *cfg.ExperimentalSettings.EnableClickToReply,
|
||||
"restrict_system_admin": *cfg.ExperimentalSettings.RestrictSystemAdmin,
|
||||
@@ -739,22 +739,22 @@ func (ts *TelemetryService) trackConfig() {
|
||||
})
|
||||
|
||||
ts.sendTelemetry(TrackConfigAnalytics, map[string]interface{}{
|
||||
"isdefault_max_users_for_statistics": isDefault(*cfg.AnalyticsSettings.MaxUsersForStatistics, model.ANALYTICS_SETTINGS_DEFAULT_MAX_USERS_FOR_STATISTICS),
|
||||
"isdefault_max_users_for_statistics": isDefault(*cfg.AnalyticsSettings.MaxUsersForStatistics, model.AnalyticsSettingsDefaultMaxUsersForStatistics),
|
||||
})
|
||||
|
||||
ts.sendTelemetry(TrackConfigAnnouncement, map[string]interface{}{
|
||||
"enable_banner": *cfg.AnnouncementSettings.EnableBanner,
|
||||
"isdefault_banner_color": isDefault(*cfg.AnnouncementSettings.BannerColor, model.ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_COLOR),
|
||||
"isdefault_banner_text_color": isDefault(*cfg.AnnouncementSettings.BannerTextColor, model.ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_TEXT_COLOR),
|
||||
"isdefault_banner_color": isDefault(*cfg.AnnouncementSettings.BannerColor, model.AnnouncementSettingsDefaultBannerColor),
|
||||
"isdefault_banner_text_color": isDefault(*cfg.AnnouncementSettings.BannerTextColor, model.AnnouncementSettingsDefaultBannerTextColor),
|
||||
"allow_banner_dismissal": *cfg.AnnouncementSettings.AllowBannerDismissal,
|
||||
"admin_notices_enabled": *cfg.AnnouncementSettings.AdminNoticesEnabled,
|
||||
"user_notices_enabled": *cfg.AnnouncementSettings.UserNoticesEnabled,
|
||||
})
|
||||
|
||||
ts.sendTelemetry(TrackConfigElasticsearch, map[string]interface{}{
|
||||
"isdefault_connection_url": isDefault(*cfg.ElasticsearchSettings.ConnectionUrl, model.ELASTICSEARCH_SETTINGS_DEFAULT_CONNECTION_URL),
|
||||
"isdefault_username": isDefault(*cfg.ElasticsearchSettings.Username, model.ELASTICSEARCH_SETTINGS_DEFAULT_USERNAME),
|
||||
"isdefault_password": isDefault(*cfg.ElasticsearchSettings.Password, model.ELASTICSEARCH_SETTINGS_DEFAULT_PASSWORD),
|
||||
"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),
|
||||
"enable_indexing": *cfg.ElasticsearchSettings.EnableIndexing,
|
||||
"enable_searching": *cfg.ElasticsearchSettings.EnableSearching,
|
||||
"enable_autocomplete": *cfg.ElasticsearchSettings.EnableAutocomplete,
|
||||
@@ -765,7 +765,7 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"channel_index_shards": *cfg.ElasticsearchSettings.ChannelIndexShards,
|
||||
"user_index_replicas": *cfg.ElasticsearchSettings.UserIndexReplicas,
|
||||
"user_index_shards": *cfg.ElasticsearchSettings.UserIndexShards,
|
||||
"isdefault_index_prefix": isDefault(*cfg.ElasticsearchSettings.IndexPrefix, model.ELASTICSEARCH_SETTINGS_DEFAULT_INDEX_PREFIX),
|
||||
"isdefault_index_prefix": isDefault(*cfg.ElasticsearchSettings.IndexPrefix, model.ElasticsearchSettingsDefaultIndexPrefix),
|
||||
"live_indexing_batch_size": *cfg.ElasticsearchSettings.LiveIndexingBatchSize,
|
||||
"bulk_indexing_time_window_seconds": *cfg.ElasticsearchSettings.BulkIndexingTimeWindowSeconds,
|
||||
"request_timeout_seconds": *cfg.ElasticsearchSettings.RequestTimeoutSeconds,
|
||||
@@ -773,7 +773,7 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"trace": *cfg.ElasticsearchSettings.Trace,
|
||||
})
|
||||
|
||||
ts.trackPluginConfig(cfg, model.PLUGIN_SETTINGS_DEFAULT_MARKETPLACE_URL)
|
||||
ts.trackPluginConfig(cfg, model.PluginSettingsDefaultMarketplaceUrl)
|
||||
|
||||
ts.sendTelemetry(TrackConfigDataRetention, map[string]interface{}{
|
||||
"enable_message_deletion": *cfg.DataRetentionSettings.EnableMessageDeletion,
|
||||
@@ -943,12 +943,12 @@ func (ts *TelemetryService) trackServer() {
|
||||
|
||||
func (ts *TelemetryService) trackPermissions() {
|
||||
phase1Complete := false
|
||||
if _, err := ts.dbStore.System().GetByName(model.ADVANCED_PERMISSIONS_MIGRATION_KEY); err == nil {
|
||||
if _, err := ts.dbStore.System().GetByName(model.AdvancedPermissionsMigrationKey); err == nil {
|
||||
phase1Complete = true
|
||||
}
|
||||
|
||||
phase2Complete := false
|
||||
if _, err := ts.dbStore.System().GetByName(model.MIGRATION_KEY_ADVANCED_PERMISSIONS_PHASE_2); err == nil {
|
||||
if _, err := ts.dbStore.System().GetByName(model.MigrationKeyAdvancedPermissionsPhase2); err == nil {
|
||||
phase2Complete = true
|
||||
}
|
||||
|
||||
@@ -958,74 +958,74 @@ func (ts *TelemetryService) trackPermissions() {
|
||||
})
|
||||
|
||||
systemAdminPermissions := ""
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.SYSTEM_ADMIN_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.SystemAdminRoleId); err == nil {
|
||||
systemAdminPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
|
||||
systemUserPermissions := ""
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.SYSTEM_USER_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.SystemUserRoleId); err == nil {
|
||||
systemUserPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
|
||||
teamAdminPermissions := ""
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.TEAM_ADMIN_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.TeamAdminRoleId); err == nil {
|
||||
teamAdminPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
|
||||
teamUserPermissions := ""
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.TEAM_USER_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.TeamUserRoleId); err == nil {
|
||||
teamUserPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
|
||||
teamGuestPermissions := ""
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.TEAM_GUEST_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.TeamGuestRoleId); err == nil {
|
||||
teamGuestPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
|
||||
channelAdminPermissions := ""
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.CHANNEL_ADMIN_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.ChannelAdminRoleId); err == nil {
|
||||
channelAdminPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
|
||||
channelUserPermissions := ""
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.CHANNEL_USER_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.ChannelUserRoleId); err == nil {
|
||||
channelUserPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
|
||||
channelGuestPermissions := ""
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.CHANNEL_GUEST_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.ChannelGuestRoleId); err == nil {
|
||||
channelGuestPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
|
||||
systemManagerPermissions := ""
|
||||
systemManagerPermissionsModified := false
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.SYSTEM_MANAGER_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.SystemManagerRoleId); err == nil {
|
||||
systemManagerPermissionsModified = len(model.PermissionsChangedByPatch(role, &model.RolePatch{Permissions: &model.SystemManagerDefaultPermissions})) > 0
|
||||
systemManagerPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
systemManagerCount, countErr := ts.dbStore.User().Count(model.UserCountOptions{Roles: []string{model.SYSTEM_MANAGER_ROLE_ID}})
|
||||
systemManagerCount, countErr := ts.dbStore.User().Count(model.UserCountOptions{Roles: []string{model.SystemManagerRoleId}})
|
||||
if countErr != nil {
|
||||
systemManagerCount = 0
|
||||
}
|
||||
|
||||
systemUserManagerPermissions := ""
|
||||
systemUserManagerPermissionsModified := false
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.SYSTEM_USER_MANAGER_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.SystemUserManagerRoleId); err == nil {
|
||||
systemUserManagerPermissionsModified = len(model.PermissionsChangedByPatch(role, &model.RolePatch{Permissions: &model.SystemUserManagerDefaultPermissions})) > 0
|
||||
systemUserManagerPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
systemUserManagerCount, countErr := ts.dbStore.User().Count(model.UserCountOptions{Roles: []string{model.SYSTEM_USER_MANAGER_ROLE_ID}})
|
||||
systemUserManagerCount, countErr := ts.dbStore.User().Count(model.UserCountOptions{Roles: []string{model.SystemUserManagerRoleId}})
|
||||
if countErr != nil {
|
||||
systemManagerCount = 0
|
||||
}
|
||||
|
||||
systemReadOnlyAdminPermissions := ""
|
||||
systemReadOnlyAdminPermissionsModified := false
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.SYSTEM_READ_ONLY_ADMIN_ROLE_ID); err == nil {
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), model.SystemReadOnlyAdminRoleId); err == nil {
|
||||
systemReadOnlyAdminPermissionsModified = len(model.PermissionsChangedByPatch(role, &model.RolePatch{Permissions: &model.SystemReadOnlyAdminDefaultPermissions})) > 0
|
||||
systemReadOnlyAdminPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
systemReadOnlyAdminCount, countErr := ts.dbStore.User().Count(model.UserCountOptions{Roles: []string{model.SYSTEM_READ_ONLY_ADMIN_ROLE_ID}})
|
||||
systemReadOnlyAdminCount, countErr := ts.dbStore.User().Count(model.UserCountOptions{Roles: []string{model.SystemReadOnlyAdminRoleId}})
|
||||
if countErr != nil {
|
||||
systemReadOnlyAdminCount = 0
|
||||
}
|
||||
@@ -1050,7 +1050,7 @@ func (ts *TelemetryService) trackPermissions() {
|
||||
"system_read_only_admin_count": systemReadOnlyAdminCount,
|
||||
})
|
||||
|
||||
if schemes, err := ts.srv.GetSchemes(model.SCHEME_SCOPE_TEAM, 0, 100); err == nil {
|
||||
if schemes, err := ts.srv.GetSchemes(model.SchemeScopeTeam, 0, 100); err == nil {
|
||||
for _, scheme := range schemes {
|
||||
teamAdminPermissions := ""
|
||||
if role, err := ts.srv.GetRoleByName(context.Background(), scheme.DefaultTeamAdminRole); err == nil {
|
||||
@@ -1164,44 +1164,44 @@ func (ts *TelemetryService) trackGroups() {
|
||||
}
|
||||
|
||||
func (ts *TelemetryService) trackChannelModeration() {
|
||||
channelSchemeCount, err := ts.dbStore.Scheme().CountByScope(model.SCHEME_SCOPE_CHANNEL)
|
||||
channelSchemeCount, err := ts.dbStore.Scheme().CountByScope(model.SchemeScopeChannel)
|
||||
if err != nil {
|
||||
mlog.Debug("Could not get channel_scheme_count", mlog.Err(err))
|
||||
}
|
||||
|
||||
createPostUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_CREATE_POST.Id, model.RoleScopeChannel, model.RoleTypeUser)
|
||||
createPostUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SchemeScopeChannel, model.PermissionCreatePost.Id, model.RoleScopeChannel, model.RoleTypeUser)
|
||||
if err != nil {
|
||||
mlog.Debug("Could not get create_post_user_disabled_count", mlog.Err(err))
|
||||
}
|
||||
|
||||
createPostGuest, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_CREATE_POST.Id, model.RoleScopeChannel, model.RoleTypeGuest)
|
||||
createPostGuest, err := ts.dbStore.Scheme().CountWithoutPermission(model.SchemeScopeChannel, model.PermissionCreatePost.Id, model.RoleScopeChannel, model.RoleTypeGuest)
|
||||
if err != nil {
|
||||
mlog.Debug("Could not get create_post_guest_disabled_count", mlog.Err(err))
|
||||
}
|
||||
|
||||
// only need to track one of 'add_reaction' or 'remove_reaction` because they're both toggled together by the channel moderation feature
|
||||
postReactionsUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_ADD_REACTION.Id, model.RoleScopeChannel, model.RoleTypeUser)
|
||||
postReactionsUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SchemeScopeChannel, model.PermissionAddReaction.Id, model.RoleScopeChannel, model.RoleTypeUser)
|
||||
if err != nil {
|
||||
mlog.Debug("Could not get post_reactions_user_disabled_count", mlog.Err(err))
|
||||
}
|
||||
|
||||
postReactionsGuest, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_ADD_REACTION.Id, model.RoleScopeChannel, model.RoleTypeGuest)
|
||||
postReactionsGuest, err := ts.dbStore.Scheme().CountWithoutPermission(model.SchemeScopeChannel, model.PermissionAddReaction.Id, model.RoleScopeChannel, model.RoleTypeGuest)
|
||||
if err != nil {
|
||||
mlog.Debug("Could not get post_reactions_guest_disabled_count", mlog.Err(err))
|
||||
}
|
||||
|
||||
// only need to track one of 'manage_public_channel_members' or 'manage_private_channel_members` because they're both toggled together by the channel moderation feature
|
||||
manageMembersUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_MANAGE_PUBLIC_CHANNEL_MEMBERS.Id, model.RoleScopeChannel, model.RoleTypeUser)
|
||||
manageMembersUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SchemeScopeChannel, model.PermissionManagePublicChannelMembers.Id, model.RoleScopeChannel, model.RoleTypeUser)
|
||||
if err != nil {
|
||||
mlog.Debug("Could not get manage_members_user_disabled_count", mlog.Err(err))
|
||||
}
|
||||
|
||||
useChannelMentionsUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_USE_CHANNEL_MENTIONS.Id, model.RoleScopeChannel, model.RoleTypeUser)
|
||||
useChannelMentionsUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SchemeScopeChannel, model.PermissionUseChannelMentions.Id, model.RoleScopeChannel, model.RoleTypeUser)
|
||||
if err != nil {
|
||||
mlog.Debug("Could not get use_channel_mentions_user_disabled_count", mlog.Err(err))
|
||||
}
|
||||
|
||||
useChannelMentionsGuest, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_USE_CHANNEL_MENTIONS.Id, model.RoleScopeChannel, model.RoleTypeGuest)
|
||||
useChannelMentionsGuest, err := ts.dbStore.Scheme().CountWithoutPermission(model.SchemeScopeChannel, model.PermissionUseChannelMentions.Id, model.RoleScopeChannel, model.RoleTypeGuest)
|
||||
if err != nil {
|
||||
mlog.Debug("Could not get use_channel_mentions_guest_disabled_count", mlog.Err(err))
|
||||
}
|
||||
@@ -1288,7 +1288,7 @@ func (ts *TelemetryService) trackWarnMetrics() {
|
||||
return
|
||||
}
|
||||
for key, value := range systemDataList {
|
||||
if strings.HasPrefix(key, model.WARN_METRIC_STATUS_STORE_PREFIX) {
|
||||
if strings.HasPrefix(key, model.WarnMetricStatusStorePrefix) {
|
||||
if _, ok := model.WarnMetricsTable[key]; ok {
|
||||
ts.sendTelemetry(TrackWarnMetrics, map[string]interface{}{
|
||||
key: value != "false",
|
||||
@@ -1309,7 +1309,7 @@ func (ts *TelemetryService) trackPluginConfig(cfg *model.Config, marketplaceURL
|
||||
"require_pluginSignature": *cfg.PluginSettings.RequirePluginSignature,
|
||||
"enable_remote_marketplace": *cfg.PluginSettings.EnableRemoteMarketplace,
|
||||
"automatic_prepackaged_plugins": *cfg.PluginSettings.AutomaticPrepackagedPlugins,
|
||||
"is_default_marketplace_url": isDefault(*cfg.PluginSettings.MarketplaceUrl, model.PLUGIN_SETTINGS_DEFAULT_MARKETPLACE_URL),
|
||||
"is_default_marketplace_url": isDefault(*cfg.PluginSettings.MarketplaceUrl, model.PluginSettingsDefaultMarketplaceUrl),
|
||||
"signature_public_key_files": len(cfg.PluginSettings.SignaturePublicKeyFiles),
|
||||
"chimera_oauth_proxy_url": *cfg.PluginSettings.ChimeraOAuthProxyUrl,
|
||||
}
|
||||
|
||||
@@ -80,17 +80,17 @@ func initializeMocks(cfg *model.Config) (*mocks.ServerIface, *storeMocks.Store,
|
||||
|
||||
systemStore := storeMocks.SystemStore{}
|
||||
props := model.StringMap{}
|
||||
props[model.SYSTEM_TELEMETRY_ID] = "test"
|
||||
props[model.SystemTelemetryId] = "test"
|
||||
systemStore.On("Get").Return(props, nil)
|
||||
systemStore.On("GetByName", model.ADVANCED_PERMISSIONS_MIGRATION_KEY).Return(nil, nil)
|
||||
systemStore.On("GetByName", model.MIGRATION_KEY_ADVANCED_PERMISSIONS_PHASE_2).Return(nil, nil)
|
||||
systemStore.On("GetByName", model.AdvancedPermissionsMigrationKey).Return(nil, nil)
|
||||
systemStore.On("GetByName", model.MigrationKeyAdvancedPermissionsPhase2).Return(nil, nil)
|
||||
|
||||
userStore := storeMocks.UserStore{}
|
||||
userStore.On("Count", model.UserCountOptions{IncludeBotAccounts: false, IncludeDeleted: true, ExcludeRegularUsers: false, TeamId: "", ViewRestrictions: nil}).Return(int64(10), nil)
|
||||
userStore.On("Count", model.UserCountOptions{IncludeBotAccounts: true, IncludeDeleted: false, ExcludeRegularUsers: true, TeamId: "", ViewRestrictions: nil}).Return(int64(100), nil)
|
||||
userStore.On("Count", model.UserCountOptions{Roles: []string{model.SYSTEM_MANAGER_ROLE_ID}}).Return(int64(5), nil)
|
||||
userStore.On("Count", model.UserCountOptions{Roles: []string{model.SYSTEM_USER_MANAGER_ROLE_ID}}).Return(int64(10), nil)
|
||||
userStore.On("Count", model.UserCountOptions{Roles: []string{model.SYSTEM_READ_ONLY_ADMIN_ROLE_ID}}).Return(int64(15), nil)
|
||||
userStore.On("Count", model.UserCountOptions{Roles: []string{model.SystemManagerRoleId}}).Return(int64(5), nil)
|
||||
userStore.On("Count", model.UserCountOptions{Roles: []string{model.SystemUserManagerRoleId}}).Return(int64(10), nil)
|
||||
userStore.On("Count", model.UserCountOptions{Roles: []string{model.SystemReadOnlyAdminRoleId}}).Return(int64(15), nil)
|
||||
userStore.On("AnalyticsGetGuestCount").Return(int64(11), nil)
|
||||
userStore.On("AnalyticsActiveCount", mock.Anything, model.UserCountOptions{IncludeBotAccounts: false, IncludeDeleted: false, ExcludeRegularUsers: false, TeamId: "", ViewRestrictions: nil}).Return(int64(5), nil)
|
||||
userStore.On("AnalyticsGetInactiveUsersCount").Return(int64(8), nil)
|
||||
@@ -361,7 +361,7 @@ func TestRudderTelemetry(t *testing.T) {
|
||||
TrackConfigRate,
|
||||
TrackConfigEmail,
|
||||
TrackConfigPrivacy,
|
||||
TrackConfigOauth,
|
||||
TrackConfigOAuth,
|
||||
TrackConfigLDAP,
|
||||
TrackConfigCompliance,
|
||||
TrackConfigLocalization,
|
||||
@@ -404,7 +404,7 @@ func TestRudderTelemetry(t *testing.T) {
|
||||
TrackConfigRate,
|
||||
TrackConfigEmail,
|
||||
TrackConfigPrivacy,
|
||||
TrackConfigOauth,
|
||||
TrackConfigOAuth,
|
||||
TrackConfigLDAP,
|
||||
TrackConfigCompliance,
|
||||
TrackConfigLocalization,
|
||||
|
||||
@@ -76,7 +76,7 @@ func setupTestHelper(s store.Store, includeCacheLayer bool, tb testing.TB) *Test
|
||||
buffer := &bytes.Buffer{}
|
||||
provider := cache.NewProvider()
|
||||
cache, err := provider.NewCache(&cache.CacheOptions{
|
||||
Size: model.SESSION_CACHE_SIZE,
|
||||
Size: model.SessionCacheSize,
|
||||
Striped: true,
|
||||
StripedBuckets: maxInt(runtime.NumCPU()-1, 1),
|
||||
})
|
||||
|
||||
@@ -52,12 +52,12 @@ func IsPasswordValidWithSettings(password string, settings *model.PasswordSettin
|
||||
id := "model.user.is_valid.pwd"
|
||||
isError := false
|
||||
|
||||
if len(password) < *settings.MinimumLength || len(password) > model.PASSWORD_MAXIMUM_LENGTH {
|
||||
if len(password) < *settings.MinimumLength || len(password) > model.PasswordMaximumLength {
|
||||
isError = true
|
||||
}
|
||||
|
||||
if *settings.Lowercase {
|
||||
if !strings.ContainsAny(password, model.LOWERCASE_LETTERS) {
|
||||
if !strings.ContainsAny(password, model.LowercaseLetters) {
|
||||
isError = true
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func IsPasswordValidWithSettings(password string, settings *model.PasswordSettin
|
||||
}
|
||||
|
||||
if *settings.Uppercase {
|
||||
if !strings.ContainsAny(password, model.UPPERCASE_LETTERS) {
|
||||
if !strings.ContainsAny(password, model.UppercaseLetters) {
|
||||
isError = true
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestIsPasswordValidWithSettings(t *testing.T) {
|
||||
},
|
||||
},
|
||||
"Long": {
|
||||
Password: strings.Repeat("x", model.PASSWORD_MAXIMUM_LENGTH),
|
||||
Password: strings.Repeat("x", model.PasswordMaximumLength),
|
||||
Settings: &model.PasswordSettings{
|
||||
Lowercase: model.NewBool(false),
|
||||
Uppercase: model.NewBool(false),
|
||||
@@ -57,7 +57,7 @@ func TestIsPasswordValidWithSettings(t *testing.T) {
|
||||
ExpectedError: "model.user.is_valid.pwd.app_error",
|
||||
},
|
||||
"TooLong": {
|
||||
Password: strings.Repeat("x", model.PASSWORD_MAXIMUM_LENGTH+1),
|
||||
Password: strings.Repeat("x", model.PasswordMaximumLength+1),
|
||||
Settings: &model.PasswordSettings{
|
||||
Lowercase: model.NewBool(false),
|
||||
Uppercase: model.NewBool(false),
|
||||
|
||||
@@ -51,7 +51,7 @@ func New(c ServiceConfig) (*UserService, error) {
|
||||
}
|
||||
|
||||
sessionCache, err := cacheProvider.NewCache(&cache.CacheOptions{
|
||||
Size: model.SESSION_CACHE_SIZE,
|
||||
Size: model.SessionCacheSize,
|
||||
Striped: true,
|
||||
StripedBuckets: maxInt(runtime.NumCPU()-1, 1),
|
||||
})
|
||||
|
||||
@@ -97,8 +97,8 @@ func (us *UserService) ClearUserSessionCache(userID string) {
|
||||
|
||||
if us.cluster != nil {
|
||||
msg := &model.ClusterMessage{
|
||||
Event: model.CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_USER,
|
||||
SendType: model.CLUSTER_SEND_RELIABLE,
|
||||
Event: model.ClusterEventClearSessionCacheForUser,
|
||||
SendType: model.ClusterSendReliable,
|
||||
Data: userID,
|
||||
}
|
||||
us.cluster.SendClusterMessage(msg)
|
||||
@@ -110,8 +110,8 @@ func (us *UserService) ClearAllUsersSessionCache() {
|
||||
|
||||
if us.cluster != nil {
|
||||
msg := &model.ClusterMessage{
|
||||
Event: model.CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_ALL_USERS,
|
||||
SendType: model.CLUSTER_SEND_RELIABLE,
|
||||
Event: model.ClusterEventClearSessionCacheForAllUsers,
|
||||
SendType: model.ClusterSendReliable,
|
||||
}
|
||||
us.cluster.SendClusterMessage(msg)
|
||||
}
|
||||
@@ -217,7 +217,7 @@ func (us *UserService) UpdateSessionsIsGuest(userID string, isGuest bool) error
|
||||
}
|
||||
|
||||
for _, session := range sessions {
|
||||
session.AddProp(model.SESSION_PROP_IS_GUEST, fmt.Sprintf("%t", isGuest))
|
||||
session.AddProp(model.SessionPropIsGuest, fmt.Sprintf("%t", isGuest))
|
||||
err := us.sessionStore.UpdateProps(session)
|
||||
if err != nil {
|
||||
mlog.Warn("Unable to update isGuest session", mlog.Err(err))
|
||||
|
||||
@@ -111,7 +111,7 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
|
||||
session.CreateAt = model.GetMillis()
|
||||
session.UserId = model.NewId()
|
||||
session.Token = model.NewId()
|
||||
session.Roles = model.SYSTEM_USER_ROLE_ID
|
||||
session.Roles = model.SystemUserRoleId
|
||||
th.service.SetSessionExpireInDays(session, 1)
|
||||
|
||||
session, _ = th.service.CreateSession(session)
|
||||
|
||||
@@ -26,9 +26,9 @@ func (us *UserService) CreateUser(user *model.User, opts UserCreateOptions) (*mo
|
||||
return us.createUser(user)
|
||||
}
|
||||
|
||||
user.Roles = model.SYSTEM_USER_ROLE_ID
|
||||
user.Roles = model.SystemUserRoleId
|
||||
if opts.Guest {
|
||||
user.Roles = model.SYSTEM_GUEST_ROLE_ID
|
||||
user.Roles = model.SystemGuestRoleId
|
||||
}
|
||||
|
||||
if !user.IsLDAPUser() && !user.IsSAMLUser() && !user.IsGuest() && !CheckUserDomain(user, *us.config().TeamSettings.RestrictCreationToDomains) {
|
||||
@@ -46,7 +46,7 @@ func (us *UserService) CreateUser(user *model.User, opts UserCreateOptions) (*mo
|
||||
return nil, UserCountError
|
||||
}
|
||||
if count <= 0 {
|
||||
user.Roles = model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID
|
||||
user.Roles = model.SystemAdminRoleId + " " + model.SystemUserRoleId
|
||||
}
|
||||
|
||||
if _, ok := i18n.GetSupportedLocales()[user.Locale]; !ok {
|
||||
@@ -214,8 +214,8 @@ func (us *UserService) InvalidateCacheForUser(userID string) {
|
||||
|
||||
if us.cluster != nil {
|
||||
msg := &model.ClusterMessage{
|
||||
Event: model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER,
|
||||
SendType: model.CLUSTER_SEND_BEST_EFFORT,
|
||||
Event: model.ClusterEventInvalidateCacheForUser,
|
||||
SendType: model.ClusterSendBestEffort,
|
||||
Data: userID,
|
||||
}
|
||||
us.cluster.SendClusterMessage(msg)
|
||||
|
||||
Ссылка в новой задаче
Block a user