[MM-12461] Include the per-channel NotifyProps for Users in Bulk Export (#9773)
* Add per channel notify props to bulk export * Check if key exists before assigning
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
e0f5ee97b4
Коммит
2e945e287d
@@ -4,8 +4,9 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mattermost/mattermost-server/model"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/mattermost/mattermost-server/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ImportLineFromTeam(team *model.TeamForExport) *LineImportData {
|
func ImportLineFromTeam(team *model.TeamForExport) *LineImportData {
|
||||||
@@ -78,10 +79,27 @@ func ImportUserChannelDataFromChannelMember(member *model.ChannelMemberForExport
|
|||||||
if member.SchemeUser {
|
if member.SchemeUser {
|
||||||
rolesList = append(rolesList, model.CHANNEL_USER_ROLE_ID)
|
rolesList = append(rolesList, model.CHANNEL_USER_ROLE_ID)
|
||||||
}
|
}
|
||||||
|
props := member.NotifyProps
|
||||||
|
notifyProps := UserChannelNotifyPropsImportData{}
|
||||||
|
|
||||||
|
desktop, exist := props[model.DESKTOP_NOTIFY_PROP]
|
||||||
|
if exist {
|
||||||
|
notifyProps.Desktop = &desktop
|
||||||
|
}
|
||||||
|
mobile, exist := props[model.PUSH_NOTIFY_PROP]
|
||||||
|
if exist {
|
||||||
|
notifyProps.Mobile = &mobile
|
||||||
|
}
|
||||||
|
markUnread, exist := props[model.MARK_UNREAD_NOTIFY_PROP]
|
||||||
|
if exist {
|
||||||
|
notifyProps.MarkUnread = &markUnread
|
||||||
|
}
|
||||||
|
|
||||||
roles := strings.Join(rolesList, " ")
|
roles := strings.Join(rolesList, " ")
|
||||||
return &UserChannelImportData{
|
return &UserChannelImportData{
|
||||||
Name: &member.ChannelName,
|
Name: &member.ChannelName,
|
||||||
Roles: &roles,
|
Roles: &roles,
|
||||||
|
NotifyProps: ¬ifyProps,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,3 +59,34 @@ func TestExportUserNotifyProps(t *testing.T) {
|
|||||||
require.Equal(t, userNotifyProps[model.COMMENTS_NOTIFY_PROP], *exportNotifyProps.CommentsTrigger)
|
require.Equal(t, userNotifyProps[model.COMMENTS_NOTIFY_PROP], *exportNotifyProps.CommentsTrigger)
|
||||||
require.Equal(t, userNotifyProps[model.MENTION_KEYS_NOTIFY_PROP], *exportNotifyProps.MentionKeys)
|
require.Equal(t, userNotifyProps[model.MENTION_KEYS_NOTIFY_PROP], *exportNotifyProps.MentionKeys)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExportUserChannelsNotifyProps(t *testing.T) {
|
||||||
|
th := Setup().InitBasic()
|
||||||
|
defer th.TearDown()
|
||||||
|
channel := th.BasicChannel
|
||||||
|
user := th.BasicUser
|
||||||
|
team := th.BasicTeam
|
||||||
|
channelName := channel.Name
|
||||||
|
notifyProps := model.StringMap{
|
||||||
|
model.DESKTOP_NOTIFY_PROP: model.USER_NOTIFY_ALL,
|
||||||
|
model.PUSH_NOTIFY_PROP: model.USER_NOTIFY_NONE,
|
||||||
|
}
|
||||||
|
channelMember := model.ChannelMember{
|
||||||
|
ChannelId: channel.Id,
|
||||||
|
UserId: user.Id,
|
||||||
|
}
|
||||||
|
th.App.Srv.Store.Channel().SaveMember(&channelMember)
|
||||||
|
th.App.UpdateChannelMemberNotifyProps(notifyProps, channel.Id, user.Id)
|
||||||
|
exportData, _ := th.App.buildUserChannelMemberships(user.Id, team.Id)
|
||||||
|
for _, data := range *exportData {
|
||||||
|
if *data.Name == channelName {
|
||||||
|
assert.Equal(t, *data.NotifyProps.Desktop, "all")
|
||||||
|
assert.Equal(t, *data.NotifyProps.Mobile, "none")
|
||||||
|
assert.Equal(t, *data.NotifyProps.MarkUnread, "all") // default value
|
||||||
|
} else { // default values
|
||||||
|
assert.Equal(t, *data.NotifyProps.Desktop, "default")
|
||||||
|
assert.Equal(t, *data.NotifyProps.Mobile, "default")
|
||||||
|
assert.Equal(t, *data.NotifyProps.MarkUnread, "all")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user