mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-57824: Export/import custom status (#27361)
https://mattermost.atlassian.net/browse/MM-57824 ```release-note NONE ``` Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
b596430920
commit
db45c0132e
@ -469,6 +469,11 @@ func (a *App) exportAllUsers(ctx request.CTX, job *model.Job, writer io.Writer,
|
||||
|
||||
userLine.User.NotifyProps = a.buildUserNotifyProps(user.NotifyProps)
|
||||
|
||||
// Adding custom status
|
||||
if cs := user.GetCustomStatus(); cs != nil {
|
||||
userLine.User.CustomStatus = cs
|
||||
}
|
||||
|
||||
// Do the Team Memberships.
|
||||
members, err := a.buildUserTeamAndChannelMemberships(ctx, user.Id, includeArchivedChannels)
|
||||
if err != nil {
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -574,6 +575,40 @@ func TestExportPostWithProps(t *testing.T) {
|
||||
assert.Contains(t, posts[1].Props["attachments"].([]any)[0], "footer")
|
||||
}
|
||||
|
||||
func TestExportUserCustomStatus(t *testing.T) {
|
||||
th1 := Setup(t).InitBasic()
|
||||
|
||||
cs := &model.CustomStatus{
|
||||
Emoji: "palm_tree",
|
||||
Text: "on a vacation",
|
||||
Duration: "this_week",
|
||||
ExpiresAt: time.Now().Add(24 * time.Hour),
|
||||
}
|
||||
appErr := th1.App.SetCustomStatus(th1.Context, th1.BasicUser.Id, cs)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
uname := th1.BasicUser.Username
|
||||
|
||||
var b bytes.Buffer
|
||||
appErr = th1.App.BulkExport(th1.Context, &b, "somePath", nil, model.BulkExportOpts{})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
th1.TearDown()
|
||||
|
||||
th2 := Setup(t)
|
||||
defer th2.TearDown()
|
||||
|
||||
appErr, i := th2.App.BulkImport(th2.Context, &b, nil, false, 1)
|
||||
require.Nil(t, appErr)
|
||||
assert.Equal(t, 0, i)
|
||||
|
||||
gotUser, err := th2.Server.Store().User().GetByUsername(uname)
|
||||
require.NoError(t, err)
|
||||
gotCs := gotUser.GetCustomStatus()
|
||||
require.Equal(t, cs.Emoji, gotCs.Emoji)
|
||||
require.Equal(t, cs.Text, gotCs.Text)
|
||||
}
|
||||
|
||||
func TestExportDMPostWithSelf(t *testing.T) {
|
||||
th1 := Setup(t).InitBasic()
|
||||
|
||||
|
@ -536,6 +536,12 @@ func (a *App) importUser(rctx request.CTX, data *imports.UserImportData, dryRun
|
||||
}
|
||||
}
|
||||
|
||||
if data.CustomStatus != nil {
|
||||
if err := user.SetCustomStatus(data.CustomStatus); err != nil {
|
||||
return model.NewAppError("importUser", "app.import.custom_status.error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
}
|
||||
|
||||
var savedUser *model.User
|
||||
var err error
|
||||
if user.Id == "" {
|
||||
|
@ -86,6 +86,7 @@ type UserImportData struct {
|
||||
EmailInterval *string `json:"email_interval,omitempty"`
|
||||
|
||||
NotifyProps *UserNotifyPropsImportData `json:"notify_props,omitempty"`
|
||||
CustomStatus *model.CustomStatus `json:"custom_status,omitempty"`
|
||||
}
|
||||
|
||||
type UserNotifyPropsImportData struct {
|
||||
|
@ -5122,6 +5122,10 @@
|
||||
"id": "app.import.bulk_import.unsupported_version.error",
|
||||
"translation": "Incorrect or missing version in the data import file. Make sure version is the first object in your import file and try again."
|
||||
},
|
||||
{
|
||||
"id": "app.import.custom_status.error",
|
||||
"translation": "Unable to set custom status."
|
||||
},
|
||||
{
|
||||
"id": "app.import.emoji.bad_file.error",
|
||||
"translation": "Error reading import emoji image file. Emoji with name: \"{{.EmojiName}}\""
|
||||
|
Loading…
Reference in New Issue
Block a user