[MM-53245] export/import: add Props to the replies (#29531)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f60694dbef
Коммит
bf4d41954a
@@ -308,6 +308,7 @@ func importReplyFromPost(post *model.ReplyForExport) *imports.ReplyImportData {
|
|||||||
EditAt: &post.EditAt,
|
EditAt: &post.EditAt,
|
||||||
IsPinned: &post.IsPinned,
|
IsPinned: &post.IsPinned,
|
||||||
FlaggedBy: &f,
|
FlaggedBy: &f,
|
||||||
|
Props: &post.Props,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1412,6 +1412,9 @@ func (a *App) importReplies(rctx request.CTX, data []imports.ReplyImportData, po
|
|||||||
rctx.Logger().Warn("Reply CreateAt is before parent post CreateAt, setting it to parent post CreateAt", mlog.Int("reply_create_at", reply.CreateAt), mlog.Int("parent_create_at", post.CreateAt))
|
rctx.Logger().Warn("Reply CreateAt is before parent post CreateAt, setting it to parent post CreateAt", mlog.Int("reply_create_at", reply.CreateAt), mlog.Int("parent_create_at", post.CreateAt))
|
||||||
reply.CreateAt = post.CreateAt
|
reply.CreateAt = post.CreateAt
|
||||||
}
|
}
|
||||||
|
if replyData.Props != nil {
|
||||||
|
reply.Props = *replyData.Props
|
||||||
|
}
|
||||||
if replyData.Type != nil {
|
if replyData.Type != nil {
|
||||||
reply.Type = *replyData.Type
|
reply.Type = *replyData.Type
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2663,6 +2663,7 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
|||||||
User: &user2.Username,
|
User: &user2.Username,
|
||||||
Message: model.NewPointer("Message reply"),
|
Message: model.NewPointer("Message reply"),
|
||||||
CreateAt: &replyTime,
|
CreateAt: &replyTime,
|
||||||
|
Props: &model.StringInterface{"key": "value"},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -2694,6 +2695,10 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
|||||||
replyBool := reply.Message != *(*data.Post.Replies)[0].Message || reply.CreateAt != *(*data.Post.Replies)[0].CreateAt || reply.UserId != user2.Id
|
replyBool := reply.Message != *(*data.Post.Replies)[0].Message || reply.CreateAt != *(*data.Post.Replies)[0].CreateAt || reply.UserId != user2.Id
|
||||||
require.False(t, replyBool, "Post properties not as expected")
|
require.False(t, replyBool, "Post properties not as expected")
|
||||||
|
|
||||||
|
v := reply.GetProp("key")
|
||||||
|
require.NotNil(t, v, "Post prop should exist")
|
||||||
|
require.Equal(t, "value", v, "Post props not as expected")
|
||||||
|
|
||||||
require.Equal(t, post.Id, reply.RootId, "Unexpected reply RootId")
|
require.Equal(t, post.Id, reply.RootId, "Unexpected reply RootId")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -183,10 +183,11 @@ type ReactionImportData struct {
|
|||||||
type ReplyImportData struct {
|
type ReplyImportData struct {
|
||||||
User *string `json:"user"`
|
User *string `json:"user"`
|
||||||
|
|
||||||
Type *string `json:"type"`
|
Type *string `json:"type"`
|
||||||
Message *string `json:"message"`
|
Message *string `json:"message"`
|
||||||
CreateAt *int64 `json:"create_at"`
|
Props *model.StringInterface `json:"props"`
|
||||||
EditAt *int64 `json:"edit_at"`
|
CreateAt *int64 `json:"create_at"`
|
||||||
|
EditAt *int64 `json:"edit_at"`
|
||||||
|
|
||||||
FlaggedBy *[]string `json:"flagged_by,omitempty"`
|
FlaggedBy *[]string `json:"flagged_by,omitempty"`
|
||||||
Reactions *[]ReactionImportData `json:"reactions,omitempty"`
|
Reactions *[]ReactionImportData `json:"reactions,omitempty"`
|
||||||
|
|||||||
@@ -474,6 +474,19 @@ func ValidateReplyImportData(data *ReplyImportData, parentCreateAt int64, maxPos
|
|||||||
mlog.Warn("Reply CreateAt is before parent post CreateAt", mlog.Int("reply_create_at", *data.CreateAt), mlog.Int("parent_create_at", parentCreateAt))
|
mlog.Warn("Reply CreateAt is before parent post CreateAt", mlog.Int("reply_create_at", *data.CreateAt), mlog.Int("parent_create_at", parentCreateAt))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if data.Props != nil && utf8.RuneCountInString(model.StringInterfaceToJSON(*data.Props)) > model.PostPropsMaxRunes {
|
||||||
|
return model.NewAppError("BulkImport", "app.import.validate_post_import_data.props_too_large.error", nil, "", http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.Reactions != nil {
|
||||||
|
for _, reaction := range *data.Reactions {
|
||||||
|
reaction := reaction
|
||||||
|
if err := ValidateReactionImportData(&reaction, *data.CreateAt); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user