MM-12459 Include User Notify Props in the Bulk Export (#9724)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
159c2a44dc
Коммит
54b7a29581
@@ -150,6 +150,8 @@ func (a *App) ExportAllUsers(writer io.Writer) *model.AppError {
|
|||||||
|
|
||||||
userLine := ImportLineFromUser(user)
|
userLine := ImportLineFromUser(user)
|
||||||
|
|
||||||
|
userLine.User.NotifyProps = a.buildUserNotifyProps(user.NotifyProps)
|
||||||
|
|
||||||
// Do the Team Memberships.
|
// Do the Team Memberships.
|
||||||
members, err := a.buildUserTeamAndChannelMemberships(user.Id)
|
members, err := a.buildUserTeamAndChannelMemberships(user.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -218,6 +220,27 @@ func (a *App) buildUserChannelMemberships(userId string, teamId string) (*[]User
|
|||||||
return &memberships, nil
|
return &memberships, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) buildUserNotifyProps(notifyProps model.StringMap) *UserNotifyPropsImportData {
|
||||||
|
|
||||||
|
getProp := func(key string) *string {
|
||||||
|
if v, ok := notifyProps[key]; ok {
|
||||||
|
return &v
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &UserNotifyPropsImportData{
|
||||||
|
Desktop: getProp(model.DESKTOP_NOTIFY_PROP),
|
||||||
|
DesktopSound: getProp(model.DESKTOP_SOUND_NOTIFY_PROP),
|
||||||
|
Email: getProp(model.EMAIL_NOTIFY_PROP),
|
||||||
|
Mobile: getProp(model.MOBILE_NOTIFY_PROP),
|
||||||
|
MobilePushStatus: getProp(model.MOBILE_PUSH_STATUS_NOTIFY_PROP),
|
||||||
|
ChannelTrigger: getProp(model.CHANNEL_MENTIONS_NOTIFY_PROP),
|
||||||
|
CommentsTrigger: getProp(model.COMMENTS_NOTIFY_PROP),
|
||||||
|
MentionKeys: getProp(model.MENTION_KEYS_NOTIFY_PROP),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) ExportAllPosts(writer io.Writer) *model.AppError {
|
func (a *App) ExportAllPosts(writer io.Writer) *model.AppError {
|
||||||
afterId := strings.Repeat("0", 26)
|
afterId := strings.Repeat("0", 26)
|
||||||
for {
|
for {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestReactionsOfPost(t *testing.T) {
|
func TestReactionsOfPost(t *testing.T) {
|
||||||
@@ -30,3 +31,31 @@ func TestReactionsOfPost(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(t, reactionObject.EmojiName, *(*reactionsOfPost)[0].EmojiName)
|
assert.Equal(t, reactionObject.EmojiName, *(*reactionsOfPost)[0].EmojiName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExportUserNotifyProps(t *testing.T) {
|
||||||
|
|
||||||
|
th := Setup().InitBasic()
|
||||||
|
defer th.TearDown()
|
||||||
|
|
||||||
|
userNotifyProps := model.StringMap{
|
||||||
|
model.DESKTOP_NOTIFY_PROP: model.USER_NOTIFY_ALL,
|
||||||
|
model.DESKTOP_SOUND_NOTIFY_PROP: "true",
|
||||||
|
model.EMAIL_NOTIFY_PROP: "true",
|
||||||
|
model.MOBILE_NOTIFY_PROP: model.USER_NOTIFY_ALL,
|
||||||
|
model.MOBILE_PUSH_STATUS_NOTIFY_PROP: model.STATUS_ONLINE,
|
||||||
|
model.CHANNEL_MENTIONS_NOTIFY_PROP: "true",
|
||||||
|
model.COMMENTS_NOTIFY_PROP: model.COMMENTS_NOTIFY_ROOT,
|
||||||
|
model.MENTION_KEYS_NOTIFY_PROP: "valid,misc",
|
||||||
|
}
|
||||||
|
|
||||||
|
exportNotifyProps := th.App.buildUserNotifyProps(userNotifyProps)
|
||||||
|
|
||||||
|
require.Equal(t, userNotifyProps[model.DESKTOP_NOTIFY_PROP], *exportNotifyProps.Desktop)
|
||||||
|
require.Equal(t, userNotifyProps[model.DESKTOP_SOUND_NOTIFY_PROP], *exportNotifyProps.DesktopSound)
|
||||||
|
require.Equal(t, userNotifyProps[model.EMAIL_NOTIFY_PROP], *exportNotifyProps.Email)
|
||||||
|
require.Equal(t, userNotifyProps[model.MOBILE_NOTIFY_PROP], *exportNotifyProps.Mobile)
|
||||||
|
require.Equal(t, userNotifyProps[model.MOBILE_PUSH_STATUS_NOTIFY_PROP], *exportNotifyProps.MobilePushStatus)
|
||||||
|
require.Equal(t, userNotifyProps[model.CHANNEL_MENTIONS_NOTIFY_PROP], *exportNotifyProps.ChannelTrigger)
|
||||||
|
require.Equal(t, userNotifyProps[model.COMMENTS_NOTIFY_PROP], *exportNotifyProps.CommentsTrigger)
|
||||||
|
require.Equal(t, userNotifyProps[model.MENTION_KEYS_NOTIFY_PROP], *exportNotifyProps.MentionKeys)
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,22 +16,24 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ME = "me"
|
ME = "me"
|
||||||
USER_NOTIFY_ALL = "all"
|
USER_NOTIFY_ALL = "all"
|
||||||
USER_NOTIFY_MENTION = "mention"
|
USER_NOTIFY_MENTION = "mention"
|
||||||
USER_NOTIFY_NONE = "none"
|
USER_NOTIFY_NONE = "none"
|
||||||
DESKTOP_NOTIFY_PROP = "desktop"
|
DESKTOP_NOTIFY_PROP = "desktop"
|
||||||
DESKTOP_SOUND_NOTIFY_PROP = "desktop_sound"
|
DESKTOP_SOUND_NOTIFY_PROP = "desktop_sound"
|
||||||
MARK_UNREAD_NOTIFY_PROP = "mark_unread"
|
MARK_UNREAD_NOTIFY_PROP = "mark_unread"
|
||||||
PUSH_NOTIFY_PROP = "push"
|
PUSH_NOTIFY_PROP = "push"
|
||||||
PUSH_STATUS_NOTIFY_PROP = "push_status"
|
PUSH_STATUS_NOTIFY_PROP = "push_status"
|
||||||
EMAIL_NOTIFY_PROP = "email"
|
EMAIL_NOTIFY_PROP = "email"
|
||||||
CHANNEL_MENTIONS_NOTIFY_PROP = "channel"
|
MOBILE_NOTIFY_PROP = "mobile"
|
||||||
COMMENTS_NOTIFY_PROP = "comments"
|
MOBILE_PUSH_STATUS_NOTIFY_PROP = "mobile_push_status"
|
||||||
MENTION_KEYS_NOTIFY_PROP = "mention_keys"
|
CHANNEL_MENTIONS_NOTIFY_PROP = "channel"
|
||||||
COMMENTS_NOTIFY_NEVER = "never"
|
COMMENTS_NOTIFY_PROP = "comments"
|
||||||
COMMENTS_NOTIFY_ROOT = "root"
|
MENTION_KEYS_NOTIFY_PROP = "mention_keys"
|
||||||
COMMENTS_NOTIFY_ANY = "any"
|
COMMENTS_NOTIFY_NEVER = "never"
|
||||||
|
COMMENTS_NOTIFY_ROOT = "root"
|
||||||
|
COMMENTS_NOTIFY_ANY = "any"
|
||||||
|
|
||||||
DEFAULT_LOCALE = "en"
|
DEFAULT_LOCALE = "en"
|
||||||
USER_AUTH_SERVICE_EMAIL = "email"
|
USER_AUTH_SERVICE_EMAIL = "email"
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user