[MM-59519] preserve DM/GM unread/read state over export and import (#27707)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2024-08-26 17:04:48 +02:00
коммит произвёл GitHub
родитель c2c37cea20
Коммит 4b3de1861f
14 изменённых файлов: 1138 добавлений и 556 удалений

Просмотреть файл

@@ -123,10 +123,27 @@ type UserChannelImportData struct {
LastViewedAt *int64 `json:"last_viewed_at,omitempty"`
}
type DirectChannelMemberImportData struct {
Username *string `json:"username"`
NotifyProps *UserChannelNotifyPropsImportData `json:"notify_props,omitempty"`
SchemeUser *bool `json:"scheme_user,omitempty"`
SchemeAdmin *bool `json:"scheme_admin,omitempty"`
SchemeGuest *bool `json:"scheme_guest,omitempty"`
MentionCount *int64 `json:"mention_count,omitempty"`
MentionCountRoot *int64 `json:"mention_count_root,omitempty"`
UrgentMentionCount *int64 `json:"urgend_mention_count,omitempty"`
MsgCount *int64 `json:"msg_count,omitempty"`
MsgCountRoot *int64 `json:"msg_count_root,omitempty"`
LastViewedAt *int64 `json:"last_viewed_at,omitempty"`
}
type UserChannelNotifyPropsImportData struct {
Desktop *string `json:"desktop"`
Mobile *string `json:"mobile"`
MarkUnread *string `json:"mark_unread"`
Desktop *string `json:"desktop"`
Mobile *string `json:"mobile"`
MarkUnread *string `json:"mark_unread"`
Email *string `json:"email,omitempty"`
IgnoreChannelMentions *string `json:"ignore_channel_mentions,omitempty"`
ChannelAutoFollowThreads *string `json:"channel_auto_follow_threads,omitempty"`
}
type EmojiImportData struct {
@@ -173,8 +190,10 @@ type PostImportData struct {
}
type DirectChannelImportData struct {
Members *[]string `json:"members"`
FavoritedBy *[]string `json:"favorited_by"`
Members *[]string `json:"members,omitempty"`
Participants []*DirectChannelMemberImportData `json:"participants,omitempty"`
FavoritedBy *[]string `json:"favorited_by,omitempty"`
ShownBy *[]string `json:"shown_by,omitempty"`
Header *string `json:"header"`
}

Просмотреть файл

@@ -489,11 +489,19 @@ func ValidatePostImportData(data *PostImportData, maxPostSize int) *model.AppErr
}
func ValidateDirectChannelImportData(data *DirectChannelImportData) *model.AppError {
if data.Members == nil {
if data.Participants == nil && data.Members == nil {
return model.NewAppError("BulkImport", "app.import.validate_direct_channel_import_data.members_required.error", nil, "", http.StatusBadRequest)
}
if len(*data.Members) != 2 {
if data.Participants != nil && len(data.Participants) != 2 {
if len(data.Participants) < model.ChannelGroupMinUsers {
return model.NewAppError("BulkImport", "app.import.validate_direct_channel_import_data.members_too_few.error", nil, "", http.StatusBadRequest)
} else if len(data.Participants) > model.ChannelGroupMaxUsers {
return model.NewAppError("BulkImport", "app.import.validate_direct_channel_import_data.members_too_many.error", nil, "", http.StatusBadRequest)
}
}
if data.Members != nil && len(*data.Members) != 2 {
if len(*data.Members) < model.ChannelGroupMinUsers {
return model.NewAppError("BulkImport", "app.import.validate_direct_channel_import_data.members_too_few.error", nil, "", http.StatusBadRequest)
} else if len(*data.Members) > model.ChannelGroupMaxUsers {
@@ -508,12 +516,20 @@ func ValidateDirectChannelImportData(data *DirectChannelImportData) *model.AppEr
if data.FavoritedBy != nil {
for _, favoriter := range *data.FavoritedBy {
found := false
for _, member := range *data.Members {
if favoriter == member {
for _, member := range data.Participants {
if favoriter == *member.Username {
found = true
break
}
}
if data.Members != nil {
for _, member := range *data.Members {
if favoriter == member {
found = true
break
}
}
}
if !found {
return model.NewAppError("BulkImport", "app.import.validate_direct_channel_import_data.unknown_favoriter.error", map[string]any{"Username": favoriter}, "", http.StatusBadRequest)
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу