summaryrefslogtreecommitdiffstats
path: root/app/import.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-02-08 16:19:38 +0000
committerCorey Hulen <corey@hulen.com>2017-02-08 08:19:38 -0800
commit82779453631916bcd4d88f987b34cb6246239f6d (patch)
tree898e06b037ed2702e544d7b41599f696e6e4394f /app/import.go
parentff2a36e9c095f2b52a1e5b59af913b8e6ca803b0 (diff)
downloadchat-82779453631916bcd4d88f987b34cb6246239f6d.tar.gz
chat-82779453631916bcd4d88f987b34cb6246239f6d.tar.bz2
chat-82779453631916bcd4d88f987b34cb6246239f6d.zip
PLT-5427: Import ChannelMember Notify Props. (#5329)
Diffstat (limited to 'app/import.go')
-rw-r--r--app/import.go36
1 files changed, 34 insertions, 2 deletions
diff --git a/app/import.go b/app/import.go
index 4a27bcd7e..599c08f9d 100644
--- a/app/import.go
+++ b/app/import.go
@@ -66,8 +66,14 @@ type UserTeamImportData struct {
}
type UserChannelImportData struct {
- Name *string `json:"name"`
- Roles *string `json:"roles"`
+ Name *string `json:"name"`
+ Roles *string `json:"roles"`
+ NotifyProps *UserChannelNotifyPropsImportData `json:"notify_props"`
+}
+
+type UserChannelNotifyPropsImportData struct {
+ Desktop *string `json:"desktop"`
+ MarkUnread *string `json:"mark_unread"`
}
//
@@ -472,6 +478,22 @@ func ImportUserChannels(user *model.User, team *model.Team, data *[]UserChannelI
return err
}
}
+
+ if cdata.NotifyProps != nil {
+ notifyProps := member.NotifyProps
+
+ if cdata.NotifyProps.Desktop != nil {
+ notifyProps["desktop"] = *cdata.NotifyProps.Desktop
+ }
+
+ if cdata.NotifyProps.MarkUnread != nil {
+ notifyProps["mark_unread"] = *cdata.NotifyProps.MarkUnread
+ }
+
+ if _, err := UpdateChannelMemberNotifyProps(notifyProps, channel.Id, user.Id); err != nil {
+ return err
+ }
+ }
}
return nil
@@ -563,6 +585,16 @@ func validateUserChannelsImportData(data *[]UserChannelImportData) *model.AppErr
if cdata.Roles != nil && !model.IsValidUserRoles(*cdata.Roles) {
return model.NewAppError("BulkImport", "app.import.validate_user_channels_import_data.invalid_roles.error", nil, "", http.StatusBadRequest)
}
+
+ if cdata.NotifyProps != nil {
+ if cdata.NotifyProps.Desktop != nil && !model.IsChannelNotifyLevelValid(*cdata.NotifyProps.Desktop) {
+ return model.NewAppError("BulkImport", "app.import.validate_user_channels_import_data.invalid_notify_props_desktop.error", nil, "", http.StatusBadRequest)
+ }
+
+ if cdata.NotifyProps.MarkUnread != nil && !model.IsChannelMarkUnreadLevelValid(*cdata.NotifyProps.MarkUnread) {
+ return model.NewAppError("BulkImport", "app.import.validate_user_channels_import_data.invalid_notify_props_mark_unread.error", nil, "", http.StatusBadRequest)
+ }
+ }
}
return nil