diff options
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server')
21 files changed, 385 insertions, 146 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/channel.go b/vendor/github.com/mattermost/mattermost-server/v6/model/channel.go index 350a9230..32742582 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/channel.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/channel.go @@ -27,7 +27,7 @@ const ( ChannelGroupMinUsers = 3 DefaultChannelName = "town-square" ChannelDisplayNameMaxRunes = 64 - ChannelNameMinLength = 2 + ChannelNameMinLength = 1 ChannelNameMaxLength = 64 ChannelHeaderMaxRunes = 1024 ChannelPurposeMaxRunes = 250 @@ -216,7 +216,7 @@ func (o *Channel) IsValid() *AppError { } if !IsValidChannelIdentifier(o.Name) { - return NewAppError("Channel.IsValid", "model.channel.is_valid.2_or_more.app_error", nil, "id="+o.Id, http.StatusBadRequest) + return NewAppError("Channel.IsValid", "model.channel.is_valid.1_or_more.app_error", nil, "id="+o.Id, http.StatusBadRequest) } if !(o.Type == ChannelTypeOpen || o.Type == ChannelTypePrivate || o.Type == ChannelTypeDirect || o.Type == ChannelTypeGroup) { diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/channel_stats.go b/vendor/github.com/mattermost/mattermost-server/v6/model/channel_stats.go index cf44d541..96631c11 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/channel_stats.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/channel_stats.go @@ -8,4 +8,17 @@ type ChannelStats struct { MemberCount int64 `json:"member_count"` GuestCount int64 `json:"guest_count"` PinnedPostCount int64 `json:"pinnedpost_count"` + FilesCount int64 `json:"files_count"` +} + +func (o *ChannelStats) MemberCount_() float64 { + return float64(o.MemberCount) +} + +func (o *ChannelStats) GuestCount_() float64 { + return float64(o.GuestCount) +} + +func (o *ChannelStats) PinnedPostCount_() float64 { + return float64(o.PinnedPostCount) } diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go b/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go index 000c0b41..c6e7d887 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go @@ -2638,6 +2638,30 @@ func (c *Client4) InviteGuestsToTeam(teamId string, userEmails []string, channel // InviteUsersToTeam invite users by email to the team. func (c *Client4) InviteUsersToTeamGracefully(teamId string, userEmails []string) ([]*EmailInviteWithError, *Response, error) { r, err := c.DoAPIPost(c.teamRoute(teamId)+"/invite/email?graceful="+c.boolString(true), ArrayToJSON(userEmails)) + + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + var list []*EmailInviteWithError + if jsonErr := json.NewDecoder(r.Body).Decode(&list); jsonErr != nil { + return nil, nil, NewAppError("InviteUsersToTeamGracefully", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) + } + return list, BuildResponse(r), nil +} + +// InviteUsersToTeam invite users by email to the team. +func (c *Client4) InviteUsersToTeamAndChannelsGracefully(teamId string, userEmails []string, channelIds []string, message string) ([]*EmailInviteWithError, *Response, error) { + memberInvite := MemberInvite{ + Emails: userEmails, + ChannelIds: channelIds, + Message: message, + } + buf, err := json.Marshal(memberInvite) + if err != nil { + return nil, nil, NewAppError("InviteMembersToTeamAndChannels", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) + } + r, err := c.DoAPIPostBytes(c.teamRoute(teamId)+"/invite/email?graceful="+c.boolString(true), buf) if err != nil { return nil, BuildResponse(r), err } @@ -3748,6 +3772,49 @@ func (c *Client4) GetPostThread(postId string, etag string, collapsedThreads boo return &list, BuildResponse(r), nil } +// GetPostThreadWithOpts gets a post with all the other posts in the same thread. +func (c *Client4) GetPostThreadWithOpts(postID string, etag string, opts GetPostsOptions) (*PostList, *Response, error) { + urlVal := c.postRoute(postID) + "/thread" + + values := url.Values{} + if opts.CollapsedThreads { + values.Set("collapsedThreads", "true") + } + if opts.CollapsedThreadsExtended { + values.Set("collapsedThreadsExtended", "true") + } + if opts.SkipFetchThreads { + values.Set("skipFetchThreads", "true") + } + if opts.PerPage != 0 { + values.Set("perPage", strconv.Itoa(opts.PerPage)) + } + if opts.FromPost != "" { + values.Set("fromPost", opts.FromPost) + } + if opts.FromCreateAt != 0 { + values.Set("fromCreateAt", strconv.FormatInt(opts.FromCreateAt, 10)) + } + if opts.Direction != "" { + values.Set("direction", opts.Direction) + } + urlVal += "?" + values.Encode() + + r, err := c.DoAPIGet(urlVal, etag) + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + var list PostList + if r.StatusCode == http.StatusNotModified { + return &list, BuildResponse(r), nil + } + if jsonErr := json.NewDecoder(r.Body).Decode(&list); jsonErr != nil { + return nil, nil, NewAppError("GetPostThread", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) + } + return &list, BuildResponse(r), nil +} + // GetPostsForChannel gets a page of posts with an array for ordering for a channel. func (c *Client4) GetPostsForChannel(channelId string, page, perPage int, etag string, collapsedThreads bool) (*PostList, *Response, error) { query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage) @@ -6429,6 +6496,39 @@ func (c *Client4) GetBulkReactions(postIds []string) (map[string][]*Reaction, *R return reactions, BuildResponse(r), nil } +func (c *Client4) GetTopReactionsForTeamSince(teamId string, timeRange string, page int, perPage int) (*TopReactionList, *Response, error) { + query := fmt.Sprintf("?time_range=%v&page=%v&per_page=%v", timeRange, page, perPage) + r, err := c.DoAPIGet(c.teamRoute(teamId)+"/top/reactions"+query, "") + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + var topReactions *TopReactionList + if jsonErr := json.NewDecoder(r.Body).Decode(&topReactions); jsonErr != nil { + return nil, nil, NewAppError("GetTopReactionsForTeamSince", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) + } + return topReactions, BuildResponse(r), nil +} + +func (c *Client4) GetTopReactionsForUserSince(teamId string, timeRange string, page int, perPage int) (*TopReactionList, *Response, error) { + query := fmt.Sprintf("?time_range=%v&page=%v&per_page=%v", timeRange, page, perPage) + + if teamId != "" { + query += fmt.Sprintf("&team_id=%v", teamId) + } + + r, err := c.DoAPIGet(c.usersRoute()+"/me/top/reactions"+query, "") + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + var topReactions *TopReactionList + if jsonErr := json.NewDecoder(r.Body).Decode(&topReactions); jsonErr != nil { + return nil, nil, NewAppError("GetTopReactionsForUserSince", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) + } + return topReactions, BuildResponse(r), nil +} + // Timezone Section // GetSupportedTimezone returns a page of supported timezones on the system. @@ -7658,18 +7758,6 @@ func (c *Client4) GetSubscription() (*Subscription, *Response, error) { return subscription, BuildResponse(r), nil } -func (c *Client4) GetSubscriptionStats() (*SubscriptionStats, *Response, error) { - r, err := c.DoAPIGet(c.cloudRoute()+"/subscription/stats", "") - if err != nil { - return nil, BuildResponse(r), err - } - defer closeBody(r) - - var stats *SubscriptionStats - json.NewDecoder(r.Body).Decode(&stats) - return stats, BuildResponse(r), nil -} - func (c *Client4) GetInvoicesForSubscription() ([]*Invoice, *Response, error) { r, err := c.DoAPIGet(c.cloudRoute()+"/subscription/invoices", "") if err != nil { @@ -7782,6 +7870,12 @@ func (c *Client4) GetUserThreads(userId, teamId string, options GetUserThreadsOp if options.Unread { v.Set("unread", "true") } + if options.ThreadsOnly { + v.Set("threadsOnly", "true") + } + if options.TotalsOnly { + v.Set("totalsOnly", "true") + } url := c.userThreadsRoute(userId, teamId) if len(v) > 0 { url += "?" + v.Encode() @@ -7826,6 +7920,18 @@ func (c *Client4) UpdateThreadsReadForUser(userId, teamId string) (*Response, er return BuildResponse(r), nil } +func (c *Client4) SetThreadUnreadByPostId(userId, teamId, threadId, postId string) (*ThreadResponse, *Response, error) { + r, err := c.DoAPIPost(fmt.Sprintf("%s/set_unread/%s", c.userThreadRoute(userId, teamId, threadId), postId), "") + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + var thread ThreadResponse + json.NewDecoder(r.Body).Decode(&thread) + + return &thread, BuildResponse(r), nil +} + func (c *Client4) UpdateThreadReadForUser(userId, teamId, threadId string, timestamp int64) (*ThreadResponse, *Response, error) { r, err := c.DoAPIPut(fmt.Sprintf("%s/read/%d", c.userThreadRoute(userId, teamId, threadId), timestamp), "") if err != nil { @@ -7854,26 +7960,6 @@ func (c *Client4) UpdateThreadFollowForUser(userId, teamId, threadId string, sta return BuildResponse(r), nil } -func (c *Client4) SendAdminUpgradeRequestEmail() (*Response, error) { - r, err := c.DoAPIPost(c.cloudRoute()+"/subscription/limitreached/invite", "") - if err != nil { - return BuildResponse(r), err - } - defer closeBody(r) - - return BuildResponse(r), nil -} - -func (c *Client4) SendAdminUpgradeRequestEmailOnJoin() (*Response, error) { - r, err := c.DoAPIPost(c.cloudRoute()+"/subscription/limitreached/join", "") - if err != nil { - return BuildResponse(r), err - } - defer closeBody(r) - - return BuildResponse(r), nil -} - func (c *Client4) GetAllSharedChannels(teamID string, page, perPage int) ([]*SharedChannel, *Response, error) { url := fmt.Sprintf("%s/%s?page=%d&per_page=%d", c.sharedChannelsRoute(), teamID, page, perPage) r, err := c.DoAPIGet(url, "") diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/cloud.go b/vendor/github.com/mattermost/mattermost-server/v6/model/cloud.go index 90fc7f94..7bab4d86 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/cloud.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/cloud.go @@ -11,8 +11,6 @@ const ( EventTypeSendAdminWelcomeEmail = "send-admin-welcome-email" EventTypeTrialWillEnd = "trial-will-end" EventTypeTrialEnded = "trial-ended" - JoinLimitation = "join" - InviteLimitation = "invite" ) var MockCWS string @@ -180,12 +178,6 @@ type FailedPayment struct { type CloudWorkspaceOwner struct { UserName string `json:"username"` } -type SubscriptionStats struct { - RemainingSeats int `json:"remaining_seats"` - IsPaidTier string `json:"is_paid_tier"` - IsFreeTrial string `json:"is_free_trial"` -} - type SubscriptionChange struct { ProductID string `json:"product_id"` } diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/cluster_message.go b/vendor/github.com/mattermost/mattermost-server/v6/model/cluster_message.go index 9db02ffc..90999ab0 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/cluster_message.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/cluster_message.go @@ -26,6 +26,7 @@ const ( ClusterEventInvalidateCacheForWebhooks ClusterEvent = "inv_webhooks" ClusterEventInvalidateCacheForEmojisById ClusterEvent = "inv_emojis_by_id" ClusterEventInvalidateCacheForEmojisIdByName ClusterEvent = "inv_emojis_id_by_name" + ClusterEventInvalidateCacheForChannelFileCount ClusterEvent = "inv_channel_file_count" ClusterEventInvalidateCacheForChannelPinnedpostsCounts ClusterEvent = "inv_channel_pinnedposts_counts" ClusterEventInvalidateCacheForChannelMemberCounts ClusterEvent = "inv_channel_member_counts" ClusterEventInvalidateCacheForLastPosts ClusterEvent = "inv_last_posts" diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/config.go b/vendor/github.com/mattermost/mattermost-server/v6/model/config.go index 3920bc1e..5fb29be8 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/config.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/config.go @@ -184,24 +184,24 @@ const ( TeamSettingsDefaultTeamText = "default" - ElasticsearchSettingsDefaultConnectionURL = "http://localhost:9200" - ElasticsearchSettingsDefaultUsername = "elastic" - ElasticsearchSettingsDefaultPassword = "changeme" - ElasticsearchSettingsDefaultPostIndexReplicas = 1 - ElasticsearchSettingsDefaultPostIndexShards = 1 - ElasticsearchSettingsDefaultChannelIndexReplicas = 1 - ElasticsearchSettingsDefaultChannelIndexShards = 1 - ElasticsearchSettingsDefaultUserIndexReplicas = 1 - ElasticsearchSettingsDefaultUserIndexShards = 1 - ElasticsearchSettingsDefaultAggregatePostsAfterDays = 365 - ElasticsearchSettingsDefaultPostsAggregatorJobStartTime = "03:00" - ElasticsearchSettingsDefaultIndexPrefix = "" - ElasticsearchSettingsDefaultLiveIndexingBatchSize = 1 - ElasticsearchSettingsDefaultBulkIndexingTimeWindowSeconds = 3600 - ElasticsearchSettingsDefaultRequestTimeoutSeconds = 30 - - BleveSettingsDefaultIndexDir = "" - BleveSettingsDefaultBulkIndexingTimeWindowSeconds = 3600 + ElasticsearchSettingsDefaultConnectionURL = "http://localhost:9200" + ElasticsearchSettingsDefaultUsername = "elastic" + ElasticsearchSettingsDefaultPassword = "changeme" + ElasticsearchSettingsDefaultPostIndexReplicas = 1 + ElasticsearchSettingsDefaultPostIndexShards = 1 + ElasticsearchSettingsDefaultChannelIndexReplicas = 1 + ElasticsearchSettingsDefaultChannelIndexShards = 1 + ElasticsearchSettingsDefaultUserIndexReplicas = 1 + ElasticsearchSettingsDefaultUserIndexShards = 1 + ElasticsearchSettingsDefaultAggregatePostsAfterDays = 365 + ElasticsearchSettingsDefaultPostsAggregatorJobStartTime = "03:00" + ElasticsearchSettingsDefaultIndexPrefix = "" + ElasticsearchSettingsDefaultLiveIndexingBatchSize = 1 + ElasticsearchSettingsDefaultRequestTimeoutSeconds = 30 + ElasticsearchSettingsDefaultBatchSize = 10000 + + BleveSettingsDefaultIndexDir = "" + BleveSettingsDefaultBatchSize = 10000 DataRetentionSettingsDefaultMessageRetentionDays = 365 DataRetentionSettingsDefaultFileRetentionDays = 365 @@ -275,15 +275,16 @@ var ServerTLSSupportedCiphers = map[string]uint16{ } type ServiceSettings struct { - SiteURL *string `access:"environment_web_server,authentication_saml,write_restrictable"` - WebsocketURL *string `access:"write_restrictable,cloud_restrictable"` - LicenseFileLocation *string `access:"write_restrictable,cloud_restrictable"` // telemetry: none - ListenAddress *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` // telemetry: none - ConnectionSecurity *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` - TLSCertFile *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` - TLSKeyFile *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` - TLSMinVer *string `access:"write_restrictable,cloud_restrictable"` // telemetry: none - TLSStrictTransport *bool `access:"write_restrictable,cloud_restrictable"` + SiteURL *string `access:"environment_web_server,authentication_saml,write_restrictable"` + WebsocketURL *string `access:"write_restrictable,cloud_restrictable"` + LicenseFileLocation *string `access:"write_restrictable,cloud_restrictable"` // telemetry: none + ListenAddress *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` // telemetry: none + ConnectionSecurity *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` + TLSCertFile *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` + TLSKeyFile *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` + TLSMinVer *string `access:"write_restrictable,cloud_restrictable"` // telemetry: none + TLSStrictTransport *bool `access:"write_restrictable,cloud_restrictable"` + // In seconds. TLSStrictTransportMaxAge *int64 `access:"write_restrictable,cloud_restrictable"` // telemetry: none TLSOverwriteCiphers []string `access:"write_restrictable,cloud_restrictable"` // telemetry: none UseLetsEncrypt *bool `access:"environment_web_server,write_restrictable,cloud_restrictable"` @@ -904,7 +905,6 @@ type ExperimentalSettings struct { LinkMetadataTimeoutMilliseconds *int64 `access:"experimental_features,write_restrictable,cloud_restrictable"` RestrictSystemAdmin *bool `access:"experimental_features,write_restrictable"` UseNewSAMLLibrary *bool `access:"experimental_features,cloud_restrictable"` - CloudUserLimit *int64 `access:"experimental_features,write_restrictable"` CloudBilling *bool `access:"experimental_features,write_restrictable"` EnableSharedChannels *bool `access:"experimental_features"` EnableRemoteClusterService *bool `access:"experimental_features"` @@ -931,11 +931,6 @@ func (s *ExperimentalSettings) SetDefaults() { s.RestrictSystemAdmin = NewBool(false) } - if s.CloudUserLimit == nil { - // User limit 0 is treated as no limit - s.CloudUserLimit = NewInt64(0) - } - if s.CloudBilling == nil { s.CloudBilling = NewBool(false) } @@ -1541,6 +1536,7 @@ type EmailSettings struct { LoginButtonColor *string `access:"experimental_features"` LoginButtonBorderColor *string `access:"experimental_features"` LoginButtonTextColor *string `access:"experimental_features"` + EnableInactivityEmail *bool } func (s *EmailSettings) SetDefaults(isUpdate bool) { @@ -1683,6 +1679,10 @@ func (s *EmailSettings) SetDefaults(isUpdate bool) { if s.LoginButtonTextColor == nil { s.LoginButtonTextColor = NewString("#2389D7") } + + if s.EnableInactivityEmail == nil { + s.EnableInactivityEmail = NewBool(true) + } } type RateLimitSettings struct { @@ -1885,17 +1885,18 @@ func (s *ThemeSettings) SetDefaults() { } type TeamSettings struct { - SiteName *string `access:"site_customization"` - MaxUsersPerTeam *int `access:"site_users_and_teams"` - EnableUserCreation *bool `access:"authentication_signup"` - EnableOpenServer *bool `access:"authentication_signup"` - EnableUserDeactivation *bool `access:"experimental_features"` - RestrictCreationToDomains *string `access:"authentication_signup"` // telemetry: none - EnableCustomUserStatuses *bool `access:"site_users_and_teams"` - EnableCustomBrand *bool `access:"site_customization"` - CustomBrandText *string `access:"site_customization"` - CustomDescriptionText *string `access:"site_customization"` - RestrictDirectMessage *string `access:"site_users_and_teams"` + SiteName *string `access:"site_customization"` + MaxUsersPerTeam *int `access:"site_users_and_teams"` + EnableUserCreation *bool `access:"authentication_signup"` + EnableOpenServer *bool `access:"authentication_signup"` + EnableUserDeactivation *bool `access:"experimental_features"` + RestrictCreationToDomains *string `access:"authentication_signup"` // telemetry: none + EnableCustomUserStatuses *bool `access:"site_users_and_teams"` + EnableCustomBrand *bool `access:"site_customization"` + CustomBrandText *string `access:"site_customization"` + CustomDescriptionText *string `access:"site_customization"` + RestrictDirectMessage *string `access:"site_users_and_teams"` + // In seconds. UserStatusAwayTimeout *int64 `access:"experimental_features"` MaxChannelsPerTeam *int64 `access:"site_users_and_teams"` MaxNotificationsPerChannel *int64 `access:"environment_push_notification_server"` @@ -2475,7 +2476,8 @@ type ElasticsearchSettings struct { PostsAggregatorJobStartTime *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` // telemetry: none IndexPrefix *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` LiveIndexingBatchSize *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` - BulkIndexingTimeWindowSeconds *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` + BulkIndexingTimeWindowSeconds *int `json:",omitempty"` // telemetry: none + BatchSize *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` RequestTimeoutSeconds *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` SkipTLSVerification *bool `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` Trace *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` @@ -2550,8 +2552,8 @@ func (s *ElasticsearchSettings) SetDefaults() { s.LiveIndexingBatchSize = NewInt(ElasticsearchSettingsDefaultLiveIndexingBatchSize) } - if s.BulkIndexingTimeWindowSeconds == nil { - s.BulkIndexingTimeWindowSeconds = NewInt(ElasticsearchSettingsDefaultBulkIndexingTimeWindowSeconds) + if s.BatchSize == nil { + s.BatchSize = NewInt(ElasticsearchSettingsDefaultBatchSize) } if s.RequestTimeoutSeconds == nil { @@ -2572,7 +2574,8 @@ type BleveSettings struct { EnableIndexing *bool `access:"experimental_bleve"` EnableSearching *bool `access:"experimental_bleve"` EnableAutocomplete *bool `access:"experimental_bleve"` - BulkIndexingTimeWindowSeconds *int `access:"experimental_bleve"` + BulkIndexingTimeWindowSeconds *int `json:",omitempty"` // telemetry: none + BatchSize *int `access:"experimental_bleve"` } func (bs *BleveSettings) SetDefaults() { @@ -2592,8 +2595,8 @@ func (bs *BleveSettings) SetDefaults() { bs.EnableAutocomplete = NewBool(false) } - if bs.BulkIndexingTimeWindowSeconds == nil { - bs.BulkIndexingTimeWindowSeconds = NewInt(BleveSettingsDefaultBulkIndexingTimeWindowSeconds) + if bs.BatchSize == nil { + bs.BatchSize = NewInt(BleveSettingsDefaultBatchSize) } } @@ -2643,9 +2646,10 @@ func (s *DataRetentionSettings) SetDefaults() { } type JobSettings struct { - RunJobs *bool `access:"write_restrictable,cloud_restrictable"` // telemetry: none - RunScheduler *bool `access:"write_restrictable,cloud_restrictable"` // telemetry: none - CleanupJobsThresholdDays *int `access:"write_restrictable,cloud_restrictable"` + RunJobs *bool `access:"write_restrictable,cloud_restrictable"` // telemetry: none + RunScheduler *bool `access:"write_restrictable,cloud_restrictable"` // telemetry: none + CleanupJobsThresholdDays *int `access:"write_restrictable,cloud_restrictable"` + CleanupConfigThresholdDays *int `access:"write_restrictable,cloud_restrictable"` } func (s *JobSettings) SetDefaults() { @@ -2660,6 +2664,10 @@ func (s *JobSettings) SetDefaults() { if s.CleanupJobsThresholdDays == nil { s.CleanupJobsThresholdDays = NewInt(-1) } + + if s.CleanupConfigThresholdDays == nil { + s.CleanupConfigThresholdDays = NewInt(-1) + } } type CloudSettings struct { @@ -3564,13 +3572,13 @@ func (s *ServiceSettings) isValid() *AppError { if *s.SiteURL != "" { if _, err := url.ParseRequestURI(*s.SiteURL); err != nil { - return NewAppError("Config.IsValid", "model.config.is_valid.site_url.app_error", nil, "", http.StatusBadRequest) + return NewAppError("Config.IsValid", "model.config.is_valid.site_url.app_error", nil, err.Error(), http.StatusBadRequest) } } if *s.WebsocketURL != "" { if _, err := url.ParseRequestURI(*s.WebsocketURL); err != nil { - return NewAppError("Config.IsValid", "model.config.is_valid.websocket_url.app_error", nil, "", http.StatusBadRequest) + return NewAppError("Config.IsValid", "model.config.is_valid.websocket_url.app_error", nil, err.Error(), http.StatusBadRequest) } } @@ -3632,8 +3640,9 @@ func (s *ElasticsearchSettings) isValid() *AppError { return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.live_indexing_batch_size.app_error", nil, "", http.StatusBadRequest) } - if *s.BulkIndexingTimeWindowSeconds < 1 { - return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.bulk_indexing_time_window_seconds.app_error", nil, "", http.StatusBadRequest) + minBatchSize := 1 + if *s.BatchSize < minBatchSize { + return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.bulk_indexing_batch_size.app_error", map[string]interface{}{"BatchSize": minBatchSize}, "", http.StatusBadRequest) } if *s.RequestTimeoutSeconds < 1 { @@ -3656,8 +3665,9 @@ func (bs *BleveSettings) isValid() *AppError { return NewAppError("Config.IsValid", "model.config.is_valid.bleve_search.enable_autocomplete.app_error", nil, "", http.StatusBadRequest) } } - if *bs.BulkIndexingTimeWindowSeconds < 1 { - return NewAppError("Config.IsValid", "model.config.is_valid.bleve_search.bulk_indexing_time_window_seconds.app_error", nil, "", http.StatusBadRequest) + minBatchSize := 1 + if *bs.BatchSize < minBatchSize { + return NewAppError("Config.IsValid", "model.config.is_valid.bleve_search.bulk_indexing_batch_size.app_error", map[string]interface{}{"BatchSize": minBatchSize}, "", http.StatusBadRequest) } return nil diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/data_retention_policy.go b/vendor/github.com/mattermost/mattermost-server/v6/model/data_retention_policy.go index 32102517..549b9801 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/data_retention_policy.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/data_retention_policy.go @@ -13,9 +13,9 @@ type GlobalRetentionPolicy struct { } type RetentionPolicy struct { - ID string `db:"Id" json:"id"` - DisplayName string `json:"display_name"` - PostDuration *int64 `json:"post_duration"` + ID string `db:"Id" json:"id"` + DisplayName string `json:"display_name"` + PostDurationDays *int64 `db:"PostDuration" json:"post_duration"` } type RetentionPolicyWithTeamAndChannelIDs struct { @@ -46,8 +46,8 @@ type RetentionPolicyWithTeamAndChannelCountsList struct { } type RetentionPolicyForTeam struct { - TeamID string `db:"Id" json:"team_id"` - PostDuration int64 `json:"post_duration"` + TeamID string `db:"Id" json:"team_id"` + PostDurationDays int64 `db:"PostDuration" json:"post_duration"` } type RetentionPolicyForTeamList struct { @@ -56,8 +56,8 @@ type RetentionPolicyForTeamList struct { } type RetentionPolicyForChannel struct { - ChannelID string `db:"Id" json:"channel_id"` - PostDuration int64 `json:"post_duration"` + ChannelID string `db:"Id" json:"channel_id"` + PostDurationDays int64 `db:"PostDuration" json:"post_duration"` } type RetentionPolicyForChannelList struct { diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/feature_flags.go b/vendor/github.com/mattermost/mattermost-server/v6/model/feature_flags.go index d89dd7c3..3fc7294f 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/feature_flags.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/feature_flags.go @@ -16,9 +16,6 @@ type FeatureFlags struct { // all other values as false. TestBoolFeature bool - // Toggle on and off scheduled jobs for cloud user limit emails see MM-29999 - CloudDelinquentEmailJobsEnabled bool - // Toggle on and off support for Collapsed Threads CollapsedThreads bool @@ -38,18 +35,12 @@ type FeatureFlags struct { PermalinkPreviews bool - // Determine whether when a user gets created, they'll have noisy notifications e.g. Send desktop notifications for all activity - NewAccountNoisy bool - // Enable Calls plugin support in the mobile app CallsMobile bool // A dash separated list for feature flags to turn on for Boards BoardsFeatureFlags string - // A/B test for the add members to channel button, possible values = ("top", "bottom") - AddMembersToChannel string - // Enable Create First Channel GuidedChannelCreation bool @@ -70,12 +61,15 @@ type FeatureFlags struct { // Enable GraphQL feature GraphQL bool + + InsightsEnabled bool + + CommandPalette bool } func (f *FeatureFlags) SetDefaults() { f.TestFeature = "off" f.TestBoolFeature = false - f.CloudDelinquentEmailJobsEnabled = false f.CollapsedThreads = true f.EnableRemoteClusterService = false f.AppsEnabled = true @@ -83,10 +77,8 @@ func (f *FeatureFlags) SetDefaults() { f.PluginApps = "" f.PluginFocalboard = "" f.PermalinkPreviews = true - f.NewAccountNoisy = false f.CallsMobile = false f.BoardsFeatureFlags = "" - f.AddMembersToChannel = "top" f.GuidedChannelCreation = false f.InviteToTeam = "none" f.CustomGroups = true @@ -95,6 +87,8 @@ func (f *FeatureFlags) SetDefaults() { f.EnableInactivityCheckJob = true f.UseCaseOnboarding = true f.GraphQL = false + f.InsightsEnabled = false + f.CommandPalette = false } func (f *FeatureFlags) Plugins() map[string]string { rFFVal := reflect.ValueOf(f).Elem() diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/insights.go b/vendor/github.com/mattermost/mattermost-server/v6/model/insights.go new file mode 100644 index 00000000..e274bb83 --- /dev/null +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/insights.go @@ -0,0 +1,76 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +package model + +import ( + "net/http" + "time" +) + +const ( + TimeRangeToday string = "today" + TimeRange7Day string = "7_day" + TimeRange28Day string = "28_day" +) + +type InsightsOpts struct { + StartUnixMilli int64 + Page int + PerPage int +} + +type InsightsListData struct { + HasNext bool `json:"has_next"` +} + +type InsightsData struct { + Rank int `json:"rank"` +} + +type TopReactionList struct { + InsightsListData + Items []*TopReaction `json:"items"` +} + +type TopReaction struct { + InsightsData + EmojiName string `json:"emoji_name"` + Count int64 `json:"count"` +} + +// GetStartUnixMilliForTimeRange gets the unix start time in milliseconds from the given time range. +// Time range can be one of: "1_day", "7_day", or "28_day". +func GetStartUnixMilliForTimeRange(timeRange string) (int64, *AppError) { + now := time.Now() + _, offset := now.Zone() + switch timeRange { + case TimeRangeToday: + return GetStartOfDayMillis(now, offset), nil + case TimeRange7Day: + return GetStartOfDayMillis(now.Add(time.Hour*time.Duration(-168)), offset), nil + case TimeRange28Day: + return GetStartOfDayMillis(now.Add(time.Hour*time.Duration(-672)), offset), nil + } + + return GetStartOfDayMillis(now, offset), NewAppError("Insights.IsValidRequest", "model.insights.time_range.app_error", nil, "", http.StatusBadRequest) +} + +// GetTopReactionListWithRankAndPagination adds a rank to each item in the given list of TopReaction and checks if there is +// another page that can be fetched based on the given limit and offset. The given list of TopReaction is assumed to be +// sorted by Count. Returns a TopReactionList. +func GetTopReactionListWithRankAndPagination(reactions []*TopReaction, limit int, offset int) *TopReactionList { + // Add pagination support + var hasNext bool + if (limit != 0) && (len(reactions) == limit+1) { + hasNext = true + reactions = reactions[:len(reactions)-1] + } + + // Assign rank to each reaction + for i, reaction := range reactions { + reaction.Rank = offset + i + 1 + } + + return &TopReactionList{InsightsListData: InsightsListData{HasNext: hasNext}, Items: reactions} +} diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/license.go b/vendor/github.com/mattermost/mattermost-server/v6/model/license.go index c8a95305..c647faca 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/license.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/license.go @@ -11,9 +11,12 @@ import ( ) const ( + DayInSeconds = 24 * 60 * 60 + DayInMilliseconds = DayInSeconds * 1000 + ExpiredLicenseError = "api.license.add_license.expired.app_error" InvalidLicenseError = "api.license.add_license.invalid.app_error" - LicenseGracePeriod = 1000 * 60 * 60 * 24 * 10 //10 days + LicenseGracePeriod = DayInMilliseconds * 10 //10 days LicenseRenewalLink = "https://mattermost.com/renew/" LicenseShortSkuE10 = "E10" @@ -307,7 +310,7 @@ func (l *License) HasEnterpriseMarketplacePlugins() bool { // NewTestLicense returns a license that expires in the future and has the given features. func NewTestLicense(features ...string) *License { ret := &License{ - ExpiresAt: GetMillis() + 90*24*60*60*1000, + ExpiresAt: GetMillis() + 90*DayInMilliseconds, Customer: &Customer{}, Features: &Features{}, } diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/member_invite.go b/vendor/github.com/mattermost/mattermost-server/v6/model/member_invite.go new file mode 100644 index 00000000..94258dbe --- /dev/null +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/member_invite.go @@ -0,0 +1,49 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +package model + +import ( + "encoding/json" + "net/http" +) + +type MemberInvite struct { + Emails []string `json:"emails"` + ChannelIds []string `json:"channelIds,omitempty"` + Message string `json:"message"` +} + +// IsValid validates that the invitation info is loaded correctly and with the correct structure +func (i *MemberInvite) IsValid() *AppError { + if len(i.Emails) == 0 { + return NewAppError("MemberInvite.IsValid", "model.member.is_valid.emails.app_error", nil, "", http.StatusBadRequest) + } + + if len(i.ChannelIds) > 0 { + for _, channel := range i.ChannelIds { + if len(channel) != 26 { + return NewAppError("MemberInvite.IsValid", "model.member.is_valid.channel.app_error", nil, "channel="+channel, http.StatusBadRequest) + } + } + } + + return nil +} + +func (i *MemberInvite) UnmarshalJSON(b []byte) error { + var emails []string + if err := json.Unmarshal(b, &emails); err == nil { + *i = MemberInvite{} + i.Emails = emails + return nil + } + + type TempMemberInvite MemberInvite + var o2 TempMemberInvite + if err := json.Unmarshal(b, &o2); err != nil { + return err + } + *i = MemberInvite(o2) + return nil +} diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/permalink.go b/vendor/github.com/mattermost/mattermost-server/v6/model/permalink.go index 6a19fb75..12645646 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/permalink.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/permalink.go @@ -8,10 +8,12 @@ type Permalink struct { } type PreviewPost struct { - PostID string `json:"post_id"` - Post *Post `json:"post"` - TeamName string `json:"team_name"` - ChannelDisplayName string `json:"channel_display_name"` + PostID string `json:"post_id"` + Post *Post `json:"post"` + TeamName string `json:"team_name"` + ChannelDisplayName string `json:"channel_display_name"` + ChannelType ChannelType `json:"channel_type"` + ChannelID string `json:"channel_id"` } func NewPreviewPost(post *Post, team *Team, channel *Channel) *PreviewPost { @@ -23,5 +25,7 @@ func NewPreviewPost(post *Post, team *Team, channel *Channel) *PreviewPost { Post: post, TeamName: team.Name, ChannelDisplayName: channel.DisplayName, + ChannelType: channel.Type, + ChannelID: channel.Id, } } diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/post.go b/vendor/github.com/mattermost/mattermost-server/v6/model/post.go index 8736de3a..039f761e 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/post.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/post.go @@ -263,6 +263,9 @@ type GetPostsOptions struct { SkipFetchThreads bool CollapsedThreads bool CollapsedThreadsExtended bool + FromPost string // PostId after which to send the items + FromCreateAt int64 // CreateAt after which to send the items + Direction string // Only accepts up|down. Indicates the order in which to send the items. } func (o *Post) Etag() string { diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/post_list.go b/vendor/github.com/mattermost/mattermost-server/v6/model/post_list.go index bb28063a..614bbf8f 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/post_list.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/post_list.go @@ -14,6 +14,8 @@ type PostList struct { Posts map[string]*Post `json:"posts"` NextPostId string `json:"next_post_id"` PrevPostId string `json:"prev_post_id"` + // HasNext indicates whether there are more items to be fetched or not. + HasNext bool `json:"has_next"` } func NewPostList() *PostList { @@ -39,6 +41,7 @@ func (o *PostList) Clone() *PostList { Posts: postsCopy, NextPostId: o.NextPostId, PrevPostId: o.PrevPostId, + HasNext: o.HasNext, } } diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/shared_channel.go b/vendor/github.com/mattermost/mattermost-server/v6/model/shared_channel.go index ed069b28..453d18e4 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/shared_channel.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/shared_channel.go @@ -51,7 +51,7 @@ func (sc *SharedChannel) IsValid() *AppError { } if !IsValidChannelIdentifier(sc.ShareName) { - return NewAppError("SharedChannel.IsValid", "model.channel.is_valid.2_or_more.app_error", nil, "id="+sc.ChannelId, http.StatusBadRequest) + return NewAppError("SharedChannel.IsValid", "model.channel.is_valid.1_or_more.app_error", nil, "id="+sc.ChannelId, http.StatusBadRequest) } if utf8.RuneCountInString(sc.ShareHeader) > ChannelHeaderMaxRunes { diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/system.go b/vendor/github.com/mattermost/mattermost-server/v6/model/system.go index 29fef336..b84a8dad 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/system.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/system.go @@ -12,7 +12,6 @@ const ( SystemRanUnitTests = "RanUnitTests" SystemLastSecurityTime = "LastSecurityTime" SystemActiveLicenseId = "ActiveLicenseId" - SystemLicenseRenewalToken = "LicenseRenewalToken" SystemLastComplianceTime = "LastComplianceTime" SystemAsymmetricSigningKeyKey = "AsymmetricSigningKey" SystemPostActionCookieSecretKey = "PostActionCookieSecret" @@ -34,9 +33,6 @@ const ( SystemFirstAdminSetupComplete = "FirstAdminSetupComplete" AwsMeteringReportInterval = 1 AwsMeteringDimensionUsageHrs = "UsageHrs" - UserLimitOverageCycleEndDate = "UserLimitOverageCycleEndDate" - OverUserLimitForgivenCount = "OverUserLimitForgivenCount" - OverUserLimitLastEmailSent = "OverUserLimitLastEmailSent" ) const ( diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/team.go b/vendor/github.com/mattermost/mattermost-server/v6/model/team.go index 7a21ffc7..92b6f7fc 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/team.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/team.go @@ -252,6 +252,12 @@ func (o *Team) IsGroupConstrained() bool { return o.GroupConstrained != nil && *o.GroupConstrained } +// ShallowCopy returns a shallow copy of team. +func (o *Team) ShallowCopy() *Team { + c := *o + return &c +} + // The following are some GraphQL methods necessary to return the // data in float64 type. The spec doesn't support 64 bit integers, // so we have to pass the data in float64. The _ at the end is diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/thread.go b/vendor/github.com/mattermost/mattermost-server/v6/model/thread.go index 89985709..17fffddd 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/thread.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/thread.go @@ -67,6 +67,9 @@ type GetUserThreadsOpts struct { // TotalsOnly will not fetch any threads and just fetch the total counts TotalsOnly bool + // ThreadsOnly will fetch threads but not calculate totals and will return 0 + ThreadsOnly bool + // TeamOnly will only fetch threads and unreads for the specified team and excludes DMs/GMs TeamOnly bool } diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go b/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go index 4a6f633e..636e707e 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go @@ -33,6 +33,7 @@ const ( UppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" NUMBERS = "0123456789" SYMBOLS = " !\"\\#$%&'()*+,-./:;<=>?@[]^_`|~" + BinaryParamKey = "MM_BINARY_PARAMETERS" ) type StringInterface map[string]interface{} @@ -124,12 +125,19 @@ func (m *StringMap) Scan(value interface{}) error { // Value converts StringMap to database value func (m StringMap) Value() (driver.Value, error) { - j, err := json.Marshal(m) + ok := m[BinaryParamKey] + delete(m, BinaryParamKey) + buf, err := json.Marshal(m) if err != nil { return nil, err } - // non utf8 characters are not supported https://mattermost.atlassian.net/browse/MM-41066 - return string(j), err + if ok == "true" { + return append([]byte{0x01}, buf...), nil + } else if ok == "false" { + return buf, nil + } + // Key wasn't found. We fall back to the default case. + return string(buf), nil } func (StringMap) ImplementsGraphQLType(name string) bool { @@ -502,21 +510,13 @@ var reservedName = []string{ } func IsValidChannelIdentifier(s string) bool { - - if !IsValidAlphaNumHyphenUnderscore(s, true) { - return false - } - - if len(s) < ChannelNameMinLength { - return false - } - - return true + return validSimpleAlphaNum.MatchString(s) && len(s) >= ChannelNameMinLength } var ( validAlphaNum = regexp.MustCompile(`^[a-z0-9]+([a-z\-0-9]+|(__)?)[a-z0-9]+$`) validAlphaNumHyphenUnderscore = regexp.MustCompile(`^[a-z0-9]+([a-z\-\_0-9]+|(__)?)[a-z0-9]+$`) + validSimpleAlphaNum = regexp.MustCompile(`^[a-z0-9]+([a-z\-\_0-9]+|(__)?)[a-z0-9]*$`) validSimpleAlphaNumHyphenUnderscore = regexp.MustCompile(`^[a-zA-Z0-9\-_]+$`) validSimpleAlphaNumHyphenUnderscorePlus = regexp.MustCompile(`^[a-zA-Z0-9+_-]+$`) ) diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/version.go b/vendor/github.com/mattermost/mattermost-server/v6/model/version.go index 7400c373..4e255826 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/version.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/version.go @@ -13,7 +13,7 @@ import ( // It should be maintained in chronological order with most current // release at the front of the list. var versions = []string{ - "6.6.1", + "6.7.0", "6.6.0", "6.5.0", "6.4.0", diff --git a/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/s3store.go b/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/s3store.go index 5ab6f1ce..d162daa2 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/s3store.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/shared/filestore/s3store.go @@ -297,7 +297,7 @@ func (b *S3FileBackend) MoveFile(oldPath, newPath string) error { } if _, err := b.client.CopyObject(context.Background(), dstOpts, srcOpts); err != nil { - return errors.Wrapf(err, "unable to copy the file to %s to the new destionation", newPath) + return errors.Wrapf(err, "unable to copy the file to %s to the new destination", newPath) } if err := b.client.RemoveObject(context.Background(), b.bucket, oldPath, s3.RemoveObjectOptions{}); err != nil { |