[MM-29217] Remove Posts.ParentId (#17923)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
757dc96461
Коммит
d181ae9262
@@ -271,7 +271,6 @@ func TestSendAutoResponseSuccess(t *testing.T) {
|
||||
if post.Type == model.PostTypeAutoResponder {
|
||||
autoResponderPostFound = true
|
||||
assert.Equal(t, savedPost.Id, post.RootId)
|
||||
assert.Equal(t, savedPost.Id, post.ParentId)
|
||||
}
|
||||
}
|
||||
assert.True(t, autoResponderPostFound)
|
||||
@@ -304,7 +303,7 @@ func TestSendAutoResponseSuccessOnThread(t *testing.T) {
|
||||
Message: "zz" + model.NewId() + "a",
|
||||
UserId: th.BasicUser.Id,
|
||||
RootId: parentPost.Id,
|
||||
ParentId: parentPost.Id},
|
||||
},
|
||||
th.BasicChannel,
|
||||
false, true)
|
||||
|
||||
@@ -321,7 +320,6 @@ func TestSendAutoResponseSuccessOnThread(t *testing.T) {
|
||||
if post.Type == model.PostTypeAutoResponder {
|
||||
autoResponderPostFound = true
|
||||
assert.Equal(t, savedPost.RootId, post.RootId)
|
||||
assert.Equal(t, savedPost.ParentId, post.ParentId)
|
||||
}
|
||||
}
|
||||
assert.True(t, autoResponderPostFound)
|
||||
|
||||
@@ -74,7 +74,6 @@ func (a *App) CreateCommandPost(c *request.Context, post *model.Post, teamID str
|
||||
}
|
||||
|
||||
if (response.ResponseType == "" || response.ResponseType == model.CommandResponseTypeEphemeral) && (response.Text != "" || response.Attachments != nil) {
|
||||
post.ParentId = ""
|
||||
a.SendEphemeralPost(post.UserId, post)
|
||||
}
|
||||
|
||||
@@ -570,7 +569,6 @@ func (a *App) HandleCommandResponsePost(c *request.Context, command *model.Comma
|
||||
post := &model.Post{}
|
||||
post.ChannelId = args.ChannelId
|
||||
post.RootId = args.RootId
|
||||
post.ParentId = args.ParentId
|
||||
post.UserId = args.UserId
|
||||
post.Type = response.Type
|
||||
post.SetProps(response.Props)
|
||||
|
||||
@@ -267,7 +267,6 @@ func (a *App) getDynamicListArgument(c *request.Context, commandArgs *model.Comm
|
||||
params.Add("channel_id", commandArgs.ChannelId)
|
||||
params.Add("team_id", commandArgs.TeamId)
|
||||
params.Add("root_id", commandArgs.RootId)
|
||||
params.Add("parent_id", commandArgs.ParentId)
|
||||
params.Add("user_id", commandArgs.UserId)
|
||||
params.Add("site_url", commandArgs.SiteURL)
|
||||
|
||||
|
||||
@@ -1093,7 +1093,6 @@ func (a *App) importReplies(c *request.Context, data []ReplyImportData, post *mo
|
||||
}
|
||||
reply.UserId = user.Id
|
||||
reply.ChannelId = post.ChannelId
|
||||
reply.ParentId = post.Id
|
||||
reply.RootId = post.Id
|
||||
reply.Message = *replyData.Message
|
||||
reply.CreateAt = *replyData.CreateAt
|
||||
|
||||
@@ -569,7 +569,6 @@ func (a *App) sendNoUsersNotifiedByGroupInChannel(sender *model.User, post *mode
|
||||
ephemeralPost := &model.Post{
|
||||
UserId: sender.Id,
|
||||
RootId: post.RootId,
|
||||
ParentId: post.ParentId,
|
||||
ChannelId: channel.Id,
|
||||
Message: T("api.post.check_for_out_of_channel_group_users.message.none", model.StringInterface{"GroupName": group.Name}),
|
||||
}
|
||||
|
||||
16
app/post.go
16
app/post.go
@@ -53,8 +53,7 @@ func (a *App) CreatePostAsUser(c *request.Context, post *model.Post, currentSess
|
||||
rp, err := a.CreatePost(c, post, channel, true, setOnline)
|
||||
if err != nil {
|
||||
if err.Id == "api.post.create_post.root_id.app_error" ||
|
||||
err.Id == "api.post.create_post.channel_root_id.app_error" ||
|
||||
err.Id == "api.post.create_post.parent_id.app_error" {
|
||||
err.Id == "api.post.create_post.channel_root_id.app_error" {
|
||||
err.StatusCode = http.StatusBadRequest
|
||||
}
|
||||
|
||||
@@ -75,7 +74,6 @@ func (a *App) CreatePostAsUser(c *request.Context, post *model.Post, currentSess
|
||||
post.UserId,
|
||||
&model.Post{
|
||||
ChannelId: channel.Id,
|
||||
ParentId: post.ParentId,
|
||||
RootId: post.RootId,
|
||||
UserId: post.UserId,
|
||||
Message: T("api.post.create_post.town_square_read_only"),
|
||||
@@ -230,7 +228,6 @@ func (a *App) CreatePost(c *request.Context, post *model.Post, channel *model.Ch
|
||||
ephemeralPost = &model.Post{
|
||||
UserId: user.Id,
|
||||
RootId: post.RootId,
|
||||
ParentId: post.ParentId,
|
||||
ChannelId: channel.Id,
|
||||
Message: T("model.post.channel_notifications_disabled_in_channel.message", model.StringInterface{"ChannelName": channel.Name, "Mention": mention}),
|
||||
Props: model.StringInterface{model.PostPropsMentionHighlightDisabled: true},
|
||||
@@ -254,17 +251,6 @@ func (a *App) CreatePost(c *request.Context, post *model.Post, channel *model.Ch
|
||||
if rootPost.RootId != "" {
|
||||
return nil, model.NewAppError("createPost", "api.post.create_post.root_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if post.ParentId == "" {
|
||||
post.ParentId = post.RootId
|
||||
}
|
||||
|
||||
if post.RootId != post.ParentId {
|
||||
parent := parentPostList.Posts[post.ParentId]
|
||||
if parent == nil {
|
||||
return nil, model.NewAppError("createPost", "api.post.create_post.parent_id.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
||||
|
||||
@@ -346,7 +346,6 @@ func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
|
||||
Message: "asd",
|
||||
ChannelId: channel.Id,
|
||||
RootId: rootPost.Id,
|
||||
ParentId: rootPost.Id,
|
||||
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
||||
UserId: userInChannel.Id,
|
||||
CreateAt: 0,
|
||||
@@ -368,7 +367,6 @@ func TestPostAttachPostToChildPost(t *testing.T) {
|
||||
Message: "reply one",
|
||||
ChannelId: channel.Id,
|
||||
RootId: rootPost.Id,
|
||||
ParentId: rootPost.Id,
|
||||
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
||||
UserId: user.Id,
|
||||
CreateAt: 0,
|
||||
@@ -381,7 +379,6 @@ func TestPostAttachPostToChildPost(t *testing.T) {
|
||||
Message: "reply two",
|
||||
ChannelId: channel.Id,
|
||||
RootId: res1.Id,
|
||||
ParentId: res1.Id,
|
||||
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
||||
UserId: user.Id,
|
||||
CreateAt: 0,
|
||||
@@ -394,7 +391,6 @@ func TestPostAttachPostToChildPost(t *testing.T) {
|
||||
Message: "reply three",
|
||||
ChannelId: channel.Id,
|
||||
RootId: rootPost.Id,
|
||||
ParentId: rootPost.Id,
|
||||
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
||||
UserId: user.Id,
|
||||
CreateAt: 0,
|
||||
@@ -2313,7 +2309,6 @@ func TestReplyToPostWithLag(t *testing.T) {
|
||||
UserId: th.BasicUser2.Id,
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
RootId: root.Id,
|
||||
ParentId: root.Id,
|
||||
Message: fmt.Sprintf("@%s", th.BasicUser2.Username),
|
||||
}, th.BasicChannel, false, true)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
@@ -70,10 +70,10 @@ func (cfg *AutoPostCreator) UploadTestFile(c *request.Context) ([]string, error)
|
||||
}
|
||||
|
||||
func (cfg *AutoPostCreator) CreateRandomPost(c *request.Context) (*model.Post, error) {
|
||||
return cfg.CreateRandomPostNested(c, "", "")
|
||||
return cfg.CreateRandomPostNested(c, "")
|
||||
}
|
||||
|
||||
func (cfg *AutoPostCreator) CreateRandomPostNested(c *request.Context, parentId, rootId string) (*model.Post, error) {
|
||||
func (cfg *AutoPostCreator) CreateRandomPostNested(c *request.Context, rootId string) (*model.Post, error) {
|
||||
var fileIDs []string
|
||||
if cfg.HasImage {
|
||||
var err error
|
||||
@@ -93,7 +93,6 @@ func (cfg *AutoPostCreator) CreateRandomPostNested(c *request.Context, parentId,
|
||||
post := &model.Post{
|
||||
ChannelId: cfg.channelid,
|
||||
UserId: cfg.userid,
|
||||
ParentId: parentId,
|
||||
RootId: rootId,
|
||||
Message: postText,
|
||||
FileIds: fileIDs,
|
||||
|
||||
@@ -84,7 +84,6 @@ func (*EchoProvider) DoCommand(a *app.App, c *request.Context, args *model.Comma
|
||||
post := &model.Post{}
|
||||
post.ChannelId = args.ChannelId
|
||||
post.RootId = args.RootId
|
||||
post.ParentId = args.ParentId
|
||||
post.Message = message
|
||||
post.UserId = args.UserId
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ func (*LoadTestProvider) ThreadedPostCommand(a *app.App, c *request.Context, arg
|
||||
return &model.CommandResponse{Text: "Failed to create a post", ResponseType: model.CommandResponseTypeEphemeral}, err2
|
||||
}
|
||||
for i := 0; i < 1000; i++ {
|
||||
testPoster.CreateRandomPostNested(c, rpost.Id, rpost.Id)
|
||||
testPoster.CreateRandomPostNested(c, rpost.Id)
|
||||
}
|
||||
|
||||
return &model.CommandResponse{Text: "Added threaded post", ResponseType: model.CommandResponseTypeEphemeral}, nil
|
||||
|
||||
@@ -145,7 +145,6 @@ func TestHandleCommandResponsePost(t *testing.T) {
|
||||
TeamId: th.BasicTeam.Id,
|
||||
UserId: th.BasicUser.Id,
|
||||
RootId: "",
|
||||
ParentId: "",
|
||||
}
|
||||
|
||||
resp := &model.CommandResponse{
|
||||
@@ -161,7 +160,6 @@ func TestHandleCommandResponsePost(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, args.ChannelId, post.ChannelId)
|
||||
assert.Equal(t, args.RootId, post.RootId)
|
||||
assert.Equal(t, args.ParentId, post.ParentId)
|
||||
assert.Equal(t, args.UserId, post.UserId)
|
||||
assert.Equal(t, resp.Type, post.Type)
|
||||
assert.Equal(t, resp.Props, post.GetProps())
|
||||
|
||||
@@ -792,7 +792,6 @@ func (a *App) CreateCommandWebhook(commandID string, args *model.CommandArgs) (*
|
||||
UserId: args.UserId,
|
||||
ChannelId: args.ChannelId,
|
||||
RootId: args.RootId,
|
||||
ParentId: args.ParentId,
|
||||
}
|
||||
|
||||
savedHook, err := a.Srv().Store.CommandWebhook().Save(hook)
|
||||
@@ -844,7 +843,6 @@ func (a *App) HandleCommandWebhook(c *request.Context, hookID string, response *
|
||||
ChannelId: hook.ChannelId,
|
||||
TeamId: cmd.TeamId,
|
||||
RootId: hook.RootId,
|
||||
ParentId: hook.ParentId,
|
||||
}
|
||||
|
||||
if nErr := a.Srv().Store.CommandWebhook().TryUse(hook.Id, 5); nErr != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user