diff options
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server')
21 files changed, 663 insertions, 94 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/channel_member.go b/vendor/github.com/mattermost/mattermost-server/v6/model/channel_member.go index d0bfc4a5..324c4f89 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/channel_member.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/channel_member.go @@ -60,8 +60,19 @@ type ChannelMember struct { ExplicitRoles string `json:"explicit_roles"` } +// ChannelMemberWithTeamData contains ChannelMember appended with extra team information +// as well. +type ChannelMemberWithTeamData struct { + ChannelMember + TeamDisplayName string `json:"team_display_name"` + TeamName string `json:"team_name"` + TeamUpdateAt int64 `json:"team_update_at"` +} + type ChannelMembers []ChannelMember +type ChannelMembersWithTeamData []ChannelMemberWithTeamData + type ChannelMemberForExport struct { ChannelMember ChannelName string 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 7bbc98e7..dd9de4d0 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/client4.go @@ -3100,6 +3100,24 @@ func (c *Client4) GetChannelsForTeamAndUserWithLastDeleteAt(teamId, userId strin return ch, BuildResponse(r), nil } +// GetChannelsForUserWithLastDeleteAt returns a list channels for a user, additionally filtered with lastDeleteAt. +func (c *Client4) GetChannelsForUserWithLastDeleteAt(userID string, lastDeleteAt int) ([]*Channel, *Response, error) { + route := fmt.Sprintf(c.userRoute(userID) + "/channels") + route += fmt.Sprintf("?last_delete_at=%d", lastDeleteAt) + r, err := c.DoAPIGet(route, "") + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + + var ch []*Channel + err = json.NewDecoder(r.Body).Decode(&ch) + if err != nil { + return nil, BuildResponse(r), NewAppError("GetChannelsForUserWithLastDeleteAt", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) + } + return ch, BuildResponse(r), nil +} + // SearchChannels returns the channels on a team matching the provided search term. func (c *Client4) SearchChannels(teamId string, search *ChannelSearch) ([]*Channel, *Response, error) { searchJSON, jsonErr := json.Marshal(search) @@ -3160,6 +3178,29 @@ func (c *Client4) SearchAllChannels(search *ChannelSearch) (ChannelListWithTeamD return ch, BuildResponse(r), nil } +// SearchAllChannelsForUser search in all the channels for a regular user. +func (c *Client4) SearchAllChannelsForUser(term string) (ChannelListWithTeamData, *Response, error) { + search := &ChannelSearch{ + Term: term, + } + searchJSON, jsonErr := json.Marshal(search) + if jsonErr != nil { + return nil, nil, NewAppError("SearchAllChannelsForUser", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) + } + r, err := c.DoAPIPost(c.channelsRoute()+"/search?system_console=false", string(searchJSON)) + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + + var ch ChannelListWithTeamData + err = json.NewDecoder(r.Body).Decode(&ch) + if err != nil { + return nil, BuildResponse(r), NewAppError("SearchAllChannelsForUser", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) + } + return ch, BuildResponse(r), nil +} + // SearchAllChannelsPaged searches all the channels and returns the results paged with the total count. func (c *Client4) SearchAllChannelsPaged(search *ChannelSearch) (*ChannelsWithCount, *Response, error) { searchJSON, jsonErr := json.Marshal(search) @@ -3304,7 +3345,7 @@ func (c *Client4) GetChannelByNameForTeamNameIncludeDeleted(channelName, teamNam return ch, BuildResponse(r), nil } -// GetChannelMembers gets a page of channel members. +// GetChannelMembers gets a page of channel members specific to a channel. func (c *Client4) GetChannelMembers(channelId string, page, perPage int, etag string) (ChannelMembers, *Response, error) { query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage) r, err := c.DoAPIGet(c.channelMembersRoute(channelId)+query, etag) @@ -3321,6 +3362,23 @@ func (c *Client4) GetChannelMembers(channelId string, page, perPage int, etag st return ch, BuildResponse(r), nil } +// GetChannelMembersWithTeamData gets a page of all channel members for a user. +func (c *Client4) GetChannelMembersWithTeamData(userID string, page, perPage int) (ChannelMembersWithTeamData, *Response, error) { + query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage) + r, err := c.DoAPIGet(c.userRoute(userID)+"/channel_members"+query, "") + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + + var ch ChannelMembersWithTeamData + err = json.NewDecoder(r.Body).Decode(&ch) + if err != nil { + return nil, BuildResponse(r), NewAppError("GetChannelMembersWithTeamData", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) + } + return ch, BuildResponse(r), nil +} + // GetChannelMembersByIds gets the channel members in a channel for a list of user ids. func (c *Client4) GetChannelMembersByIds(channelId string, userIds []string) (ChannelMembers, *Response, error) { r, err := c.DoAPIPost(c.channelMembersRoute(channelId)+"/ids", ArrayToJSON(userIds)) @@ -3710,6 +3768,27 @@ func (c *Client4) GetPostsForChannel(channelId string, page, perPage int, etag s return &list, BuildResponse(r), nil } +// GetPostsByIds gets a list of posts by taking an array of post ids +func (c *Client4) GetPostsByIds(postIds []string) ([]*Post, *Response, error) { + js, jsonErr := json.Marshal(postIds) + if jsonErr != nil { + return nil, nil, NewAppError("SearchFilesWithParams", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) + } + r, err := c.DoAPIPost(c.postsRoute()+"/ids", string(js)) + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + var list []*Post + if r.StatusCode == http.StatusNotModified { + return list, BuildResponse(r), nil + } + if jsonErr := json.NewDecoder(r.Body).Decode(&list); jsonErr != nil { + return nil, nil, NewAppError("GetPostsByIds", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) + } + return list, BuildResponse(r), nil +} + // GetFlaggedPostsForUser returns flagged posts of a user based on user id string. func (c *Client4) GetFlaggedPostsForUser(userId string, page int, perPage int) (*PostList, *Response, error) { query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage) @@ -6096,6 +6175,44 @@ func (c *Client4) UpdateUserStatus(userId string, userStatus *Status) (*Status, return &s, BuildResponse(r), nil } +// UpdateUserCustomStatus sets a user's custom status based on the provided user id string. +func (c *Client4) UpdateUserCustomStatus(userId string, userCustomStatus *CustomStatus) (*CustomStatus, *Response, error) { + buf, err := json.Marshal(userCustomStatus) + if err != nil { + return nil, nil, NewAppError("UpdateUserCustomStatus", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError) + } + r, err := c.DoAPIPutBytes(c.userStatusRoute(userId)+"/custom", buf) + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + var s CustomStatus + if jsonErr := json.NewDecoder(r.Body).Decode(&s); jsonErr != nil { + return nil, nil, NewAppError("UpdateUserCustomStatus", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) + } + return &s, BuildResponse(r), nil +} + +// RemoveUserCustomStatus remove a user's custom status based on the provided user id string. +func (c *Client4) RemoveUserCustomStatus(userId string) (*Response, error) { + r, err := c.DoAPIDelete(c.userStatusRoute(userId) + "/custom") + if err != nil { + return BuildResponse(r), err + } + defer closeBody(r) + return BuildResponse(r), nil +} + +// RemoveRecentUserCustomStatus remove a recent user's custom status based on the provided user id string. +func (c *Client4) RemoveRecentUserCustomStatus(userId string) (*Response, error) { + r, err := c.DoAPIDelete(c.userStatusRoute(userId) + "/custom/recent") + if err != nil { + return BuildResponse(r), err + } + defer closeBody(r) + return BuildResponse(r), nil +} + // Emoji Section // CreateEmoji will save an emoji to the server if the current user has permission @@ -6425,6 +6542,20 @@ func (c *Client4) DownloadJob(jobId string) ([]byte, *Response, error) { // Roles Section +// GetAllRoles returns a list of all the roles. +func (c *Client4) GetAllRoles() ([]*Role, *Response, error) { + r, err := c.DoAPIGet(c.rolesRoute(), "") + if err != nil { + return nil, BuildResponse(r), err + } + defer closeBody(r) + var list []*Role + if jsonErr := json.NewDecoder(r.Body).Decode(&list); jsonErr != nil { + return nil, nil, NewAppError("GetAllRoles", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) + } + return list, BuildResponse(r), nil +} + // GetRole gets a single role by ID. func (c *Client4) GetRole(id string) (*Role, *Response, error) { r, err := c.DoAPIGet(c.rolesRoute()+fmt.Sprintf("/%v", id), "") 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 a2eda9ff..bec5afbe 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/config.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/config.go @@ -106,6 +106,7 @@ const ( ServiceSettingsDefaultListenAndAddress = ":8065" ServiceSettingsDefaultGfycatAPIKey = "2_KtH_W5" ServiceSettingsDefaultGfycatAPISecret = "3wLVZPiswc3DnaiaFoLkDvB4X0IV6CpMkj4tf2inJRsBY6-FnkT08zGmppWFgeof" + ServiceSettingsDefaultDeveloperFlags = "" TeamSettingsDefaultSiteName = "Mattermost" TeamSettingsDefaultMaxUsersPerTeam = 50 @@ -302,6 +303,7 @@ type ServiceSettings struct { RestrictLinkPreviews *string `access:"site_posts"` EnableTesting *bool `access:"environment_developer,write_restrictable,cloud_restrictable"` EnableDeveloper *bool `access:"environment_developer,write_restrictable,cloud_restrictable"` + DeveloperFlags *string `access:"environment_developer"` EnableOpenTracing *bool `access:"write_restrictable,cloud_restrictable"` EnableSecurityFixAlert *bool `access:"environment_smtp,write_restrictable,cloud_restrictable"` EnableInsecureOutgoingConnections *bool `access:"environment_web_server,write_restrictable,cloud_restrictable"` @@ -363,7 +365,6 @@ type ServiceSettings struct { ThreadAutoFollow *bool `access:"experimental_features"` CollapsedThreads *string `access:"experimental_features"` ManagedResourcePaths *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` - EnableReliableWebSockets *bool `access:"experimental_features"` // telemetry: none } func (s *ServiceSettings) SetDefaults(isUpdate bool) { @@ -416,6 +417,10 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) { s.EnableDeveloper = NewBool(false) } + if s.DeveloperFlags == nil { + s.DeveloperFlags = NewString("") + } + if s.EnableOpenTracing == nil { s.EnableOpenTracing = NewBool(false) } @@ -776,10 +781,6 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) { if s.ManagedResourcePaths == nil { s.ManagedResourcePaths = NewString("") } - - if s.EnableReliableWebSockets == nil { - s.EnableReliableWebSockets = NewBool(true) - } } type ClusterSettings struct { @@ -1978,8 +1979,6 @@ func (s *TeamSettings) SetDefaults() { type ClientRequirements struct { AndroidLatestVersion string `access:"write_restrictable,cloud_restrictable"` AndroidMinVersion string `access:"write_restrictable,cloud_restrictable"` - DesktopLatestVersion string `access:"write_restrictable,cloud_restrictable"` - DesktopMinVersion string `access:"write_restrictable,cloud_restrictable"` IosLatestVersion string `access:"write_restrictable,cloud_restrictable"` IosMinVersion string `access:"write_restrictable,cloud_restrictable"` } @@ -2615,8 +2614,8 @@ func (s *DataRetentionSettings) SetDefaults() { } type JobSettings struct { - RunJobs *bool `access:"write_restrictable,cloud_restrictable"` - RunScheduler *bool `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"` } @@ -3025,7 +3024,7 @@ type Config struct { BleveSettings BleveSettings DataRetentionSettings DataRetentionSettings MessageExportSettings MessageExportSettings - JobSettings JobSettings // telemetry: none + JobSettings JobSettings PluginSettings PluginSettings DisplaySettings DisplaySettings GuestAccountsSettings GuestAccountsSettings 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 81b62172..a2d53e34 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 @@ -25,9 +25,12 @@ type FeatureFlags struct { // Enable the remote cluster service for shared channels. EnableRemoteClusterService bool - // AppsEnabled toggle the Apps framework functionalities both in server and client side + // AppsEnabled toggles the Apps framework functionalities both in server and client side AppsEnabled bool + // AppBarEnabled toggles the App Bar component on client side + AppBarEnabled bool + // Feature flags to control plugin versions PluginPlaybooks string `plugin_id:"playbooks"` PluginApps string `plugin_id:"com.mattermost.apps"` @@ -41,14 +44,9 @@ type FeatureFlags struct { // Enable different team menu button treatments, possible values = ("none", "by_team_name", "inverted_sidebar_bg_color") AddChannelButton string - // Enable different treatments for first time users, possible values = ("none", "tour_point", "around_input") - PrewrittenMessages string - - // Enable different treatments for first time users, possible values = ("none", "tips_and_next_steps") - DownloadAppsCTA string - // Determine whether when a user gets created, they'll have noisy notifications e.g. Send desktop notifications for all activity NewAccountNoisy bool + // Enable Boards Unfurl Preview BoardsUnfurl bool @@ -57,6 +55,21 @@ type FeatureFlags struct { // Start A/B tour tips automatically, possible values = ("none", "auto") AutoTour string + + // 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 + + // Determine after which duration in hours to send a second invitation to someone that didn't join after the initial invite, possible values = ("48", "72") + ResendInviteEmailInterval string + + // A/B test for whether radio buttons or toggle button is more effective in in-screen invite to team modal ("none", "toggle") + InviteToTeam string } func (f *FeatureFlags) SetDefaults() { @@ -66,17 +79,21 @@ func (f *FeatureFlags) SetDefaults() { f.CollapsedThreads = true f.EnableRemoteClusterService = false f.AppsEnabled = false + f.AppBarEnabled = false f.PluginApps = "" f.PluginFocalboard = "" f.PermalinkPreviews = true f.GlobalHeader = true f.AddChannelButton = "by_team_name" - f.PrewrittenMessages = "tour_point" - f.DownloadAppsCTA = "tips_and_next_steps" f.NewAccountNoisy = false f.BoardsUnfurl = true f.CallsMobile = false f.AutoTour = "none" + f.BoardsFeatureFlags = "" + f.AddMembersToChannel = "top" + f.GuidedChannelCreation = false + f.ResendInviteEmailInterval = "" + f.InviteToTeam = "none" } func (f *FeatureFlags) Plugins() map[string]string { diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/job.go b/vendor/github.com/mattermost/mattermost-server/v6/model/job.go index 13c6154f..e892b051 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/job.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/job.go @@ -58,15 +58,15 @@ var AllJobTypes = [...]string{ } type Job struct { - Id string `json:"id"` - Type string `json:"type"` - Priority int64 `json:"priority"` - CreateAt int64 `json:"create_at"` - StartAt int64 `json:"start_at"` - LastActivityAt int64 `json:"last_activity_at"` - Status string `json:"status"` - Progress int64 `json:"progress"` - Data map[string]string `json:"data"` + Id string `json:"id"` + Type string `json:"type"` + Priority int64 `json:"priority"` + CreateAt int64 `json:"create_at"` + StartAt int64 `json:"start_at"` + LastActivityAt int64 `json:"last_activity_at"` + Status string `json:"status"` + Progress int64 `json:"progress"` + Data StringMap `json:"data"` } func (j *Job) IsValid() *AppError { 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 d83a61f9..dbdc296e 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/license.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/license.go @@ -52,6 +52,7 @@ type License struct { SkuName string `json:"sku_name"` SkuShortName string `json:"sku_short_name"` IsTrial bool `json:"is_trial"` + IsGovSku bool `json:"is_gov_sku"` } type Customer struct { diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/manifest.go b/vendor/github.com/mattermost/mattermost-server/v6/model/manifest.go index 67b0d120..fda365f2 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/manifest.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/manifest.go @@ -206,7 +206,8 @@ type ManifestServer struct { Executable string `json:"executable" yaml:"executable"` } -// ManifestExecutables is a legacy structure capturing a subet of the known platform executables. +// Deprecated: ManifestExecutables is a legacy structure capturing a subset of the known platform executables. +// It will be remove in v7.0: https://mattermost.atlassian.net/browse/MM-40531 type ManifestExecutables struct { // LinuxAmd64 is the path to your executable binary for the corresponding platform LinuxAmd64 string `json:"linux-amd64,omitempty" yaml:"linux-amd64,omitempty"` diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/migration.go b/vendor/github.com/mattermost/mattermost-server/v6/model/migration.go index 2e0efb46..629189bb 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/migration.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/migration.go @@ -35,4 +35,5 @@ const ( MigrationKeyAddTestEmailAncillaryPermission = "test_email_ancillary_permission" MigrationKeyAddAboutSubsectionPermissions = "about_subsection_permissions" MigrationKeyAddIntegrationsSubsectionPermissions = "integrations_subsection_permissions" + MigrationKeyAddPlaybooksPermissions = "playbooks_permissions" ) diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/permission.go b/vendor/github.com/mattermost/mattermost-server/v6/model/permission.go index 6c10bab0..9a3e4aae 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/permission.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/permission.go @@ -4,9 +4,11 @@ package model const ( - PermissionScopeSystem = "system_scope" - PermissionScopeTeam = "team_scope" - PermissionScopeChannel = "channel_scope" + PermissionScopeSystem = "system_scope" + PermissionScopeTeam = "team_scope" + PermissionScopeChannel = "channel_scope" + PermissionScopePlaybook = "playbook_scope" + PermissionScopeRun = "run_scope" ) type Permission struct { @@ -331,6 +333,23 @@ var PermissionSysconsoleWriteExperimentalFeatureFlags *Permission var PermissionSysconsoleReadExperimentalBleve *Permission var PermissionSysconsoleWriteExperimentalBleve *Permission +var PermissionPublicPlaybookCreate *Permission +var PermissionPublicPlaybookManageProperties *Permission +var PermissionPublicPlaybookManageMembers *Permission +var PermissionPublicPlaybookView *Permission +var PermissionPublicPlaybookMakePrivate *Permission + +var PermissionPrivatePlaybookCreate *Permission +var PermissionPrivatePlaybookManageProperties *Permission +var PermissionPrivatePlaybookManageMembers *Permission +var PermissionPrivatePlaybookView *Permission +var PermissionPrivatePlaybookMakePublic *Permission + +var PermissionRunCreate *Permission +var PermissionRunManageProperties *Permission +var PermissionRunManageMembers *Permission +var PermissionRunView *Permission + // General permission that encompasses all system admin functions // in the future this could be broken up to allow access to some // admin functions but not others @@ -1895,6 +1914,105 @@ func initializePermissions() { PermissionScopeSystem, } + // Playbooks + PermissionPublicPlaybookCreate = &Permission{ + "playbook_public_create", + "", + "", + PermissionScopeTeam, + } + + PermissionPublicPlaybookManageProperties = &Permission{ + "playbook_public_manage_properties", + "", + "", + PermissionScopePlaybook, + } + + PermissionPublicPlaybookManageMembers = &Permission{ + "playbook_public_manage_members", + "", + "", + PermissionScopePlaybook, + } + + PermissionPublicPlaybookView = &Permission{ + "playbook_public_view", + "", + "", + PermissionScopePlaybook, + } + + PermissionPublicPlaybookMakePrivate = &Permission{ + "playbook_public_make_private", + "", + "", + PermissionScopePlaybook, + } + + PermissionPrivatePlaybookCreate = &Permission{ + "playbook_private_create", + "", + "", + PermissionScopeTeam, + } + + PermissionPrivatePlaybookManageProperties = &Permission{ + "playbook_private_manage_properties", + "", + "", + PermissionScopePlaybook, + } + + PermissionPrivatePlaybookManageMembers = &Permission{ + "playbook_private_manage_members", + "", + "", + PermissionScopePlaybook, + } + + PermissionPrivatePlaybookView = &Permission{ + "playbook_private_view", + "", + "", + PermissionScopePlaybook, + } + + PermissionPrivatePlaybookMakePublic = &Permission{ + "playbook_private_make_public", + "", + "", + PermissionScopePlaybook, + } + + PermissionRunCreate = &Permission{ + "run_create", + "", + "", + PermissionScopePlaybook, + } + + PermissionRunManageProperties = &Permission{ + "run_manage_properties", + "", + "", + PermissionScopeRun, + } + + PermissionRunManageMembers = &Permission{ + "run_manage_members", + "", + "", + PermissionScopeRun, + } + + PermissionRunView = &Permission{ + "run_view", + "", + "", + PermissionScopeRun, + } + SysconsoleReadPermissions = []*Permission{ PermissionSysconsoleReadAboutEditionAndLicense, PermissionSysconsoleReadBilling, @@ -2108,6 +2226,8 @@ func initializePermissions() { PermissionViewTeam, PermissionViewMembers, PermissionInviteGuest, + PermissionPublicPlaybookCreate, + PermissionPrivatePlaybookCreate, } ChannelScopedPermissions := []*Permission{ @@ -2163,12 +2283,32 @@ func initializePermissions() { PermissionSysconsoleWriteCompliance, } + PlaybookScopedPermissions := []*Permission{ + PermissionPublicPlaybookManageProperties, + PermissionPublicPlaybookManageMembers, + PermissionPublicPlaybookView, + PermissionPublicPlaybookMakePrivate, + PermissionPrivatePlaybookManageProperties, + PermissionPrivatePlaybookManageMembers, + PermissionPrivatePlaybookView, + PermissionPrivatePlaybookMakePublic, + PermissionRunCreate, + } + + RunScopedPermissions := []*Permission{ + PermissionRunManageProperties, + PermissionRunManageMembers, + PermissionRunView, + } + AllPermissions = []*Permission{} AllPermissions = append(AllPermissions, SystemScopedPermissionsMinusSysconsole...) AllPermissions = append(AllPermissions, TeamScopedPermissions...) AllPermissions = append(AllPermissions, ChannelScopedPermissions...) AllPermissions = append(AllPermissions, SysconsoleReadPermissions...) AllPermissions = append(AllPermissions, SysconsoleWritePermissions...) + AllPermissions = append(AllPermissions, PlaybookScopedPermissions...) + AllPermissions = append(AllPermissions, RunScopedPermissions...) ChannelModeratedPermissions = []string{ PermissionCreatePost.Id, diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/plugin_key_value.go b/vendor/github.com/mattermost/mattermost-server/v6/model/plugin_key_value.go index ad5971dd..c615bcf7 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/plugin_key_value.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/plugin_key_value.go @@ -10,7 +10,7 @@ import ( const ( KeyValuePluginIdMaxRunes = 190 - KeyValueKeyMaxRunes = 50 + KeyValueKeyMaxRunes = 150 ) type PluginKeyValue struct { diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/push_notification.go b/vendor/github.com/mattermost/mattermost-server/v6/model/push_notification.go index cad84f83..d46c24ec 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/push_notification.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/push_notification.go @@ -64,6 +64,7 @@ type PushNotification struct { OverrideIconURL string `json:"override_icon_url,omitempty"` FromWebhook string `json:"from_webhook,omitempty"` Version string `json:"version,omitempty"` + IsCRTEnabled bool `json:"is_crt_enabled"` IsIdLoaded bool `json:"is_id_loaded"` } diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/role.go b/vendor/github.com/mattermost/mattermost-server/v6/model/role.go index 68697838..b8d75d4b 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/role.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/role.go @@ -41,6 +41,11 @@ func init() { ChannelGuestRoleId, ChannelUserRoleId, ChannelAdminRoleId, + + PlaybookAdminRoleId, + PlaybookMemberRoleId, + RunAdminRoleId, + RunMemberRoleId, }, NewSystemRoleIDs...) // When updating the values here, the values in mattermost-redux must also be updated. @@ -362,6 +367,11 @@ const ( ChannelUserRoleId = "channel_user" ChannelAdminRoleId = "channel_admin" + PlaybookAdminRoleId = "playbook_admin" + PlaybookMemberRoleId = "playbook_member" + RunAdminRoleId = "run_admin" + RunMemberRoleId = "run_member" + RoleNameMaxLength = 64 RoleDisplayNameMaxLength = 128 RoleDescriptionMaxLength = 1024 @@ -807,6 +817,61 @@ func MakeDefaultRoles() map[string]*Role { BuiltIn: true, } + roles[PlaybookAdminRoleId] = &Role{ + Name: PlaybookAdminRoleId, + DisplayName: "authentication.roles.playbook_admin.name", + Description: "authentication.roles.playbook_admin.description", + Permissions: []string{ + PermissionPublicPlaybookManageMembers.Id, + PermissionPublicPlaybookManageProperties.Id, + PermissionPrivatePlaybookManageMembers.Id, + PermissionPrivatePlaybookManageProperties.Id, + PermissionPublicPlaybookMakePrivate.Id, + }, + SchemeManaged: true, + BuiltIn: true, + } + + roles[PlaybookMemberRoleId] = &Role{ + Name: PlaybookMemberRoleId, + DisplayName: "authentication.roles.playbook_member.name", + Description: "authentication.roles.playbook_member.description", + Permissions: []string{ + PermissionPublicPlaybookView.Id, + PermissionPublicPlaybookManageMembers.Id, + PermissionPublicPlaybookManageProperties.Id, + PermissionPrivatePlaybookView.Id, + PermissionPrivatePlaybookManageMembers.Id, + PermissionPrivatePlaybookManageProperties.Id, + PermissionRunCreate.Id, + }, + SchemeManaged: true, + BuiltIn: true, + } + + roles[RunAdminRoleId] = &Role{ + Name: RunAdminRoleId, + DisplayName: "authentication.roles.run_admin.name", + Description: "authentication.roles.run_admin.description", + Permissions: []string{ + PermissionRunManageMembers.Id, + PermissionRunManageProperties.Id, + }, + SchemeManaged: true, + BuiltIn: true, + } + + roles[RunMemberRoleId] = &Role{ + Name: RunMemberRoleId, + DisplayName: "authentication.roles.run_member.name", + Description: "authentication.roles.run_member.description", + Permissions: []string{ + PermissionRunView.Id, + }, + SchemeManaged: true, + BuiltIn: true, + } + roles[SystemGuestRoleId] = &Role{ Name: "system_guest", DisplayName: "authentication.roles.global_guest.name", diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/scheme.go b/vendor/github.com/mattermost/mattermost-server/v6/model/scheme.go index c861c1e6..b2bc713c 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/scheme.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/scheme.go @@ -14,23 +14,29 @@ const ( SchemeDescriptionMaxLength = 1024 SchemeScopeTeam = "team" SchemeScopeChannel = "channel" + SchemeScopePlaybook = "playbook" + SchemeScopeRun = "run" ) type Scheme struct { - Id string `json:"id"` - Name string `json:"name"` - DisplayName string `json:"display_name"` - Description string `json:"description"` - CreateAt int64 `json:"create_at"` - UpdateAt int64 `json:"update_at"` - DeleteAt int64 `json:"delete_at"` - Scope string `json:"scope"` - DefaultTeamAdminRole string `json:"default_team_admin_role"` - DefaultTeamUserRole string `json:"default_team_user_role"` - DefaultChannelAdminRole string `json:"default_channel_admin_role"` - DefaultChannelUserRole string `json:"default_channel_user_role"` - DefaultTeamGuestRole string `json:"default_team_guest_role"` - DefaultChannelGuestRole string `json:"default_channel_guest_role"` + Id string `json:"id"` + Name string `json:"name"` + DisplayName string `json:"display_name"` + Description string `json:"description"` + CreateAt int64 `json:"create_at"` + UpdateAt int64 `json:"update_at"` + DeleteAt int64 `json:"delete_at"` + Scope string `json:"scope"` + DefaultTeamAdminRole string `json:"default_team_admin_role"` + DefaultTeamUserRole string `json:"default_team_user_role"` + DefaultChannelAdminRole string `json:"default_channel_admin_role"` + DefaultChannelUserRole string `json:"default_channel_user_role"` + DefaultTeamGuestRole string `json:"default_team_guest_role"` + DefaultChannelGuestRole string `json:"default_channel_guest_role"` + DefaultPlaybookAdminRole string `json:"default_playbook_admin_role"` + DefaultPlaybookMemberRole string `json:"default_playbook_member_role"` + DefaultRunAdminRole string `json:"default_run_admin_role"` + DefaultRunMemberRole string `json:"default_run_member_role"` } type SchemePatch struct { @@ -45,31 +51,39 @@ type SchemeIDPatch struct { // SchemeConveyor is used for importing and exporting a Scheme and its associated Roles. type SchemeConveyor struct { - Name string `json:"name"` - DisplayName string `json:"display_name"` - Description string `json:"description"` - Scope string `json:"scope"` - TeamAdmin string `json:"default_team_admin_role"` - TeamUser string `json:"default_team_user_role"` - TeamGuest string `json:"default_team_guest_role"` - ChannelAdmin string `json:"default_channel_admin_role"` - ChannelUser string `json:"default_channel_user_role"` - ChannelGuest string `json:"default_channel_guest_role"` - Roles []*Role `json:"roles"` + Name string `json:"name"` + DisplayName string `json:"display_name"` + Description string `json:"description"` + Scope string `json:"scope"` + TeamAdmin string `json:"default_team_admin_role"` + TeamUser string `json:"default_team_user_role"` + TeamGuest string `json:"default_team_guest_role"` + ChannelAdmin string `json:"default_channel_admin_role"` + ChannelUser string `json:"default_channel_user_role"` + ChannelGuest string `json:"default_channel_guest_role"` + PlaybookAdmin string `json:"default_playbook_admin_role"` + PlaybookMember string `json:"default_playbook_member_role"` + RunAdmin string `json:"default_run_admin_role"` + RunMember string `json:"default_run_member_role"` + Roles []*Role `json:"roles"` } func (sc *SchemeConveyor) Scheme() *Scheme { return &Scheme{ - DisplayName: sc.DisplayName, - Name: sc.Name, - Description: sc.Description, - Scope: sc.Scope, - DefaultTeamAdminRole: sc.TeamAdmin, - DefaultTeamUserRole: sc.TeamUser, - DefaultTeamGuestRole: sc.TeamGuest, - DefaultChannelAdminRole: sc.ChannelAdmin, - DefaultChannelUserRole: sc.ChannelUser, - DefaultChannelGuestRole: sc.ChannelGuest, + DisplayName: sc.DisplayName, + Name: sc.Name, + Description: sc.Description, + Scope: sc.Scope, + DefaultTeamAdminRole: sc.TeamAdmin, + DefaultTeamUserRole: sc.TeamUser, + DefaultTeamGuestRole: sc.TeamGuest, + DefaultChannelAdminRole: sc.ChannelAdmin, + DefaultChannelUserRole: sc.ChannelUser, + DefaultChannelGuestRole: sc.ChannelGuest, + DefaultPlaybookAdminRole: sc.PlaybookAdmin, + DefaultPlaybookMemberRole: sc.PlaybookMember, + DefaultRunAdminRole: sc.RunAdmin, + DefaultRunMemberRole: sc.RunMember, } } @@ -101,7 +115,7 @@ func (scheme *Scheme) IsValidForCreate() bool { } switch scheme.Scope { - case SchemeScopeTeam, SchemeScopeChannel: + case SchemeScopeTeam, SchemeScopeChannel, SchemeScopePlaybook, SchemeScopeRun: default: return false } @@ -130,6 +144,22 @@ func (scheme *Scheme) IsValidForCreate() bool { if !IsValidRoleName(scheme.DefaultTeamGuestRole) { return false } + + if !IsValidRoleName(scheme.DefaultPlaybookAdminRole) { + return false + } + + if !IsValidRoleName(scheme.DefaultPlaybookMemberRole) { + return false + } + + if !IsValidRoleName(scheme.DefaultRunAdminRole) { + return false + } + + if !IsValidRoleName(scheme.DefaultRunMemberRole) { + return false + } } if scheme.Scope == SchemeScopeChannel { diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/team_member.go b/vendor/github.com/mattermost/mattermost-server/v6/model/team_member.go index c0b3772c..cec0a6a6 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/team_member.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/team_member.go @@ -69,6 +69,10 @@ type TeamMembersGetOptions struct { ViewRestrictions *ViewUsersRestrictions } +type TeamInviteReminderData struct { + Interval string +} + func EmailInviteWithErrorToEmails(o []*EmailInviteWithError) []string { var ret []string for _, o := range o { diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/user.go b/vendor/github.com/mattermost/mattermost-server/v6/model/user.go index 271ccd81..0b691c6c 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/user.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/user.go @@ -621,6 +621,15 @@ func (u *User) SetCustomStatus(cs *CustomStatus) error { return nil } +func (u *User) GetCustomStatus() *CustomStatus { + var o *CustomStatus + + data := u.Props[UserPropsKeyCustomStatus] + _ = json.Unmarshal([]byte(data), &o) + + return o +} + func (u *User) ClearCustomStatus() { u.MakeNonNil() u.Props[UserPropsKeyCustomStatus] = "" 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 c57716f7..e9170588 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go @@ -98,6 +98,43 @@ func (sa *StringArray) Scan(value interface{}) error { return errors.New("received value is neither a byte slice nor string") } +// Scan converts database column value to StringMap +func (m *StringMap) Scan(value interface{}) error { + if value == nil { + return nil + } + + buf, ok := value.([]byte) + if ok { + return json.Unmarshal(buf, m) + } + + str, ok := value.(string) + if ok { + return json.Unmarshal([]byte(str), m) + } + + return errors.New("received value is neither a byte slice nor string") +} + +func (si *StringInterface) Scan(value interface{}) error { + if value == nil { + return nil + } + + buf, ok := value.([]byte) + if ok { + return json.Unmarshal(buf, si) + } + + str, ok := value.(string) + if ok { + return json.Unmarshal([]byte(str), si) + } + + return errors.New("received value is neither a byte slice nor string") +} + var translateFunc i18n.TranslateFunc var translateFuncOnce sync.Once 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 4e578887..6020d5f8 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/version.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/version.go @@ -13,6 +13,8 @@ import ( // It should be maintained in chronological order with most current // release at the front of the list. var versions = []string{ + "6.3.0", + "6.2.0", "6.1.0", "6.0.0", "5.39.0", diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_client.go b/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_client.go index 2bd8a3b7..b80d4777 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_client.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_client.go @@ -6,6 +6,7 @@ package model import ( "bytes" "encoding/json" + "fmt" "net/http" "sync/atomic" "time" @@ -13,6 +14,7 @@ import ( "github.com/mattermost/mattermost-server/v6/shared/mlog" "github.com/gorilla/websocket" + "github.com/vmihailenco/msgpack/v5" ) const ( @@ -25,6 +27,7 @@ type msgType int const ( msgTypeJSON msgType = iota + 1 msgTypePong + msgTypeBinary ) type writeMessage struct { @@ -65,10 +68,26 @@ func NewWebSocketClient(url, authToken string) (*WebSocketClient, error) { return NewWebSocketClientWithDialer(websocket.DefaultDialer, url, authToken) } +func NewReliableWebSocketClientWithDialer(dialer *websocket.Dialer, url, authToken, connID string, seqNo int, withAuthHeader bool) (*WebSocketClient, error) { + connectURL := url + APIURLSuffix + "/websocket" + fmt.Sprintf("?connection_id=%s&sequence_number=%d", connID, seqNo) + var header http.Header + if withAuthHeader { + header = http.Header{ + "Authorization": []string{"Bearer " + authToken}, + } + } + + return makeClient(dialer, url, connectURL, authToken, header) +} + // NewWebSocketClientWithDialer constructs a new WebSocket client with convenience // methods for talking to the server using a custom dialer. func NewWebSocketClientWithDialer(dialer *websocket.Dialer, url, authToken string) (*WebSocketClient, error) { - conn, _, err := dialer.Dial(url+APIURLSuffix+"/websocket", nil) + return makeClient(dialer, url, url+APIURLSuffix+"/websocket", authToken, nil) +} + +func makeClient(dialer *websocket.Dialer, url, connectURL, authToken string, header http.Header) (*WebSocketClient, error) { + conn, _, err := dialer.Dial(connectURL, header) if err != nil { return nil, NewAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError) } @@ -76,7 +95,7 @@ func NewWebSocketClientWithDialer(dialer *websocket.Dialer, url, authToken strin client := &WebSocketClient{ URL: url, APIURL: url + APIURLSuffix, - ConnectURL: url + APIURLSuffix + "/websocket", + ConnectURL: connectURL, Conn: conn, AuthToken: authToken, Sequence: 1, @@ -165,6 +184,10 @@ func (wsc *WebSocketClient) writer() { switch msg.msgType { case msgTypeJSON: wsc.Conn.WriteJSON(msg.data) + case msgTypeBinary: + if data, ok := msg.data.([]byte); ok { + wsc.Conn.WriteMessage(websocket.BinaryMessage, data) + } case msgTypePong: wsc.Conn.WriteMessage(websocket.PongMessage, []byte{}) } @@ -258,6 +281,26 @@ func (wsc *WebSocketClient) SendMessage(action string, data map[string]interface } } +func (wsc *WebSocketClient) SendBinaryMessage(action string, data map[string]interface{}) error { + req := &WebSocketRequest{} + req.Seq = wsc.Sequence + req.Action = action + req.Data = data + + binaryData, err := msgpack.Marshal(req) + if err != nil { + return fmt.Errorf("failed to marshal request to msgpack: %w", err) + } + + wsc.Sequence++ + wsc.writeChan <- writeMessage{ + msgType: msgTypeBinary, + data: binaryData, + } + + return nil +} + // UserTyping will push a user_typing event out to all connected users // who are in the specified channel func (wsc *WebSocketClient) UserTyping(channelId, parentId string) { diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_message.go b/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_message.go index 005eed33..8827a001 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_message.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_message.go @@ -90,12 +90,58 @@ type WebsocketBroadcast struct { ContainsSensitiveData bool `json:"-"` } +func (wb *WebsocketBroadcast) copy() *WebsocketBroadcast { + if wb == nil { + return nil + } + + var c WebsocketBroadcast + if wb.OmitUsers != nil { + c.OmitUsers = make(map[string]bool, len(wb.OmitUsers)) + for k, v := range wb.OmitUsers { + c.OmitUsers[k] = v + } + } + c.UserId = wb.UserId + c.ChannelId = wb.ChannelId + c.TeamId = wb.TeamId + c.ContainsSanitizedData = wb.ContainsSanitizedData + c.ContainsSensitiveData = wb.ContainsSensitiveData + + return &c +} + type precomputedWebSocketEventJSON struct { Event json.RawMessage Data json.RawMessage Broadcast json.RawMessage } +func (p *precomputedWebSocketEventJSON) copy() *precomputedWebSocketEventJSON { + if p == nil { + return nil + } + + var c precomputedWebSocketEventJSON + + if p.Event != nil { + c.Event = make([]byte, len(p.Event)) + copy(c.Event, p.Event) + } + + if p.Data != nil { + c.Data = make([]byte, len(p.Data)) + copy(c.Data, p.Data) + } + + if p.Broadcast != nil { + c.Broadcast = make([]byte, len(p.Broadcast)) + copy(c.Broadcast, p.Broadcast) + } + + return &c +} + // webSocketEventJSON mirrors WebSocketEvent to make some of its unexported fields serializable type webSocketEventJSON struct { Event string `json:"event"` @@ -154,6 +200,25 @@ func (ev *WebSocketEvent) Copy() *WebSocketEvent { return copy } +func (ev *WebSocketEvent) DeepCopy() *WebSocketEvent { + var dataCopy map[string]interface{} + if ev.data != nil { + dataCopy = make(map[string]interface{}, len(ev.data)) + for k, v := range ev.data { + dataCopy[k] = v + } + } + + copy := &WebSocketEvent{ + event: ev.event, + data: dataCopy, + broadcast: ev.broadcast.copy(), + sequence: ev.sequence, + precomputedJSON: ev.precomputedJSON.copy(), + } + return copy +} + func (ev *WebSocketEvent) GetData() map[string]interface{} { return ev.data } diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_request.go b/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_request.go index 9e863978..a7750bce 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_request.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/websocket_request.go @@ -4,31 +4,31 @@ package model import ( - "encoding/json" - "github.com/mattermost/mattermost-server/v6/shared/i18n" + + "github.com/vmihailenco/msgpack/v5" ) // WebSocketRequest represents a request made to the server through a websocket. type WebSocketRequest struct { // Client-provided fields - Seq int64 `json:"seq"` // A counter which is incremented for every request made. - Action string `json:"action"` // The action to perform for a request. For example: get_statuses, user_typing. - Data map[string]interface{} `json:"data"` // The metadata for an action. + Seq int64 `json:"seq" msgpack:"seq"` // A counter which is incremented for every request made. + Action string `json:"action" msgpack:"action"` // The action to perform for a request. For example: get_statuses, user_typing. + Data map[string]interface{} `json:"data" msgpack:"data"` // The metadata for an action. // Server-provided fields - Session Session `json:"-"` - T i18n.TranslateFunc `json:"-"` - Locale string `json:"-"` + Session Session `json:"-" msgpack:"-"` + T i18n.TranslateFunc `json:"-" msgpack:"-"` + Locale string `json:"-" msgpack:"-"` } func (o *WebSocketRequest) Clone() (*WebSocketRequest, error) { - buf, err := json.Marshal(o) + buf, err := msgpack.Marshal(o) if err != nil { return nil, err } var ret WebSocketRequest - err = json.Unmarshal(buf, &ret) + err = msgpack.Unmarshal(buf, &ret) if err != nil { return nil, err } 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 f938f4d5..c45f626a 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 @@ -255,18 +255,25 @@ func (b *S3FileBackend) CopyFile(oldPath, newPath string) error { oldPath = filepath.Join(b.pathPrefix, oldPath) newPath = filepath.Join(b.pathPrefix, newPath) srcOpts := s3.CopySrcOptions{ - Bucket: b.bucket, - Object: oldPath, - Encryption: encrypt.NewSSE(), + Bucket: b.bucket, + Object: oldPath, } + if b.encrypt { + srcOpts.Encryption = encrypt.NewSSE() + } + dstOpts := s3.CopyDestOptions{ - Bucket: b.bucket, - Object: newPath, - Encryption: encrypt.NewSSE(), + Bucket: b.bucket, + Object: newPath, } + if b.encrypt { + dstOpts.Encryption = encrypt.NewSSE() + } + if _, err := b.client.CopyObject(context.Background(), dstOpts, srcOpts); err != nil { return errors.Wrapf(err, "unable to copy file from %s to %s", oldPath, newPath) } + return nil } @@ -274,14 +281,19 @@ func (b *S3FileBackend) MoveFile(oldPath, newPath string) error { oldPath = filepath.Join(b.pathPrefix, oldPath) newPath = filepath.Join(b.pathPrefix, newPath) srcOpts := s3.CopySrcOptions{ - Bucket: b.bucket, - Object: oldPath, - Encryption: encrypt.NewSSE(), + Bucket: b.bucket, + Object: oldPath, + } + if b.encrypt { + srcOpts.Encryption = encrypt.NewSSE() } + dstOpts := s3.CopyDestOptions{ - Bucket: b.bucket, - Object: newPath, - Encryption: encrypt.NewSSE(), + Bucket: b.bucket, + Object: newPath, + } + if b.encrypt { + dstOpts.Encryption = encrypt.NewSSE() } if _, err := b.client.CopyObject(context.Background(), dstOpts, srcOpts); err != nil { |