[MM-59519] preserve DM/GM unread/read state over export and import (#27707)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c2c37cea20
Коммит
4b3de1861f
@@ -40,17 +40,17 @@ func ImportLineFromChannel(channel *model.ChannelForExport) *imports.LineImportD
|
||||
}
|
||||
}
|
||||
|
||||
func ImportLineFromDirectChannel(channel *model.DirectChannelForExport, favoritedBy []string) *imports.LineImportData {
|
||||
channelMembers := *channel.Members
|
||||
func ImportLineFromDirectChannel(channel *model.DirectChannelForExport, favoritedBy, shownBy []string) *imports.LineImportData {
|
||||
channelMembers := channel.Members
|
||||
if len(channelMembers) == 1 {
|
||||
channelMembers = []string{channelMembers[0], channelMembers[0]}
|
||||
channelMembers = []*model.ChannelMemberForExport{channelMembers[0], channelMembers[0]}
|
||||
}
|
||||
|
||||
line := &imports.LineImportData{
|
||||
Type: "direct_channel",
|
||||
DirectChannel: &imports.DirectChannelImportData{
|
||||
Header: &channel.Header,
|
||||
Members: &channelMembers,
|
||||
Header: &channel.Header,
|
||||
Participants: importDirectChannelMembersFromChannelMembers(channelMembers),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -58,9 +58,82 @@ func ImportLineFromDirectChannel(channel *model.DirectChannelForExport, favorite
|
||||
line.DirectChannel.FavoritedBy = &favoritedBy
|
||||
}
|
||||
|
||||
if len(shownBy) != 0 {
|
||||
line.DirectChannel.ShownBy = &shownBy
|
||||
}
|
||||
|
||||
return line
|
||||
}
|
||||
|
||||
func importDirectChannelMembersFromChannelMembers(members []*model.ChannelMemberForExport) []*imports.DirectChannelMemberImportData {
|
||||
importedMembers := make([]*imports.DirectChannelMemberImportData, len(members))
|
||||
for i, member := range members {
|
||||
props := member.NotifyProps
|
||||
notifyProps := imports.UserChannelNotifyPropsImportData{}
|
||||
|
||||
desktop, exist := props[model.DesktopNotifyProp]
|
||||
if exist {
|
||||
notifyProps.Desktop = &desktop
|
||||
}
|
||||
mobile, exist := props[model.PushNotifyProp]
|
||||
if exist {
|
||||
notifyProps.Mobile = &mobile
|
||||
}
|
||||
email, exist := props[model.EmailNotifyProp]
|
||||
if exist {
|
||||
notifyProps.Email = &email
|
||||
}
|
||||
ignoreMentions, exist := props[model.IgnoreChannelMentionsNotifyProp]
|
||||
if exist {
|
||||
notifyProps.IgnoreChannelMentions = &ignoreMentions
|
||||
}
|
||||
channelAutoFallow, exist := props[model.ChannelAutoFollowThreads]
|
||||
if exist {
|
||||
notifyProps.ChannelAutoFollowThreads = &channelAutoFallow
|
||||
}
|
||||
markUnread, exist := props[model.MarkUnreadNotifyProp]
|
||||
if exist {
|
||||
notifyProps.MarkUnread = &markUnread
|
||||
}
|
||||
|
||||
dcm := &imports.DirectChannelMemberImportData{
|
||||
Username: &member.Username,
|
||||
NotifyProps: ¬ifyProps,
|
||||
}
|
||||
|
||||
if member.SchemeUser {
|
||||
dcm.SchemeUser = &member.SchemeUser
|
||||
}
|
||||
if member.SchemeAdmin {
|
||||
dcm.SchemeAdmin = &member.SchemeAdmin
|
||||
}
|
||||
if member.SchemeGuest {
|
||||
dcm.SchemeGuest = &member.SchemeGuest
|
||||
}
|
||||
if member.LastViewedAt != 0 {
|
||||
dcm.LastViewedAt = &member.LastViewedAt
|
||||
}
|
||||
if member.MentionCount != 0 {
|
||||
dcm.MentionCount = &member.MentionCount
|
||||
}
|
||||
if member.MentionCountRoot != 0 {
|
||||
dcm.MentionCountRoot = &member.MentionCountRoot
|
||||
}
|
||||
if member.MsgCount != 0 {
|
||||
dcm.MsgCount = &member.MsgCount
|
||||
}
|
||||
if member.MsgCountRoot != 0 {
|
||||
dcm.MsgCountRoot = &member.MsgCountRoot
|
||||
}
|
||||
if member.UrgentMentionCount != 0 {
|
||||
dcm.UrgentMentionCount = &member.UrgentMentionCount
|
||||
}
|
||||
|
||||
importedMembers[i] = dcm
|
||||
}
|
||||
return importedMembers
|
||||
}
|
||||
|
||||
func ImportLineFromUser(user *model.User, exportedPrefs map[string]*string) *imports.LineImportData {
|
||||
// Bulk Importer doesn't accept "empty string" for AuthService.
|
||||
var authService *string
|
||||
|
||||
Ссылка в новой задаче
Block a user