summaryrefslogtreecommitdiffstats
path: root/app/import.go
diff options
context:
space:
mode:
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