[MM-29217] Remove Posts.ParentId (#17923)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
757dc96461
Коммит
d181ae9262
@@ -414,7 +414,6 @@ func listCommandAutocompleteSuggestions(c *Context, w http.ResponseWriter, r *ht
|
|||||||
ChannelId: query.Get("channel_id"),
|
ChannelId: query.Get("channel_id"),
|
||||||
TeamId: c.Params.TeamId,
|
TeamId: c.Params.TeamId,
|
||||||
RootId: query.Get("root_id"),
|
RootId: query.Get("root_id"),
|
||||||
ParentId: query.Get("parent_id"),
|
|
||||||
UserId: c.AppContext.Session().UserId,
|
UserId: c.AppContext.Session().UserId,
|
||||||
T: c.AppContext.T,
|
T: c.AppContext.T,
|
||||||
Session: *c.AppContext.Session(),
|
Session: *c.AppContext.Session(),
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ func TestCreatePost(t *testing.T) {
|
|||||||
require.Nil(t, rpost.GetProp(model.PropsAddChannelMember), "newly created post shouldn't have Props['add_channel_member'] set")
|
require.Nil(t, rpost.GetProp(model.PropsAddChannelMember), "newly created post shouldn't have Props['add_channel_member'] set")
|
||||||
|
|
||||||
post.RootId = rpost.Id
|
post.RootId = rpost.Id
|
||||||
post.ParentId = rpost.Id
|
|
||||||
_, _, err2 = client.CreatePost(post)
|
_, _, err2 = client.CreatePost(post)
|
||||||
require.NoError(t, err2)
|
require.NoError(t, err2)
|
||||||
|
|
||||||
@@ -56,12 +55,6 @@ func TestCreatePost(t *testing.T) {
|
|||||||
require.Error(t, err2)
|
require.Error(t, err2)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
post.RootId = rpost.Id
|
|
||||||
post.ParentId = "junk"
|
|
||||||
_, resp, err2 = client.CreatePost(post)
|
|
||||||
require.Error(t, err2)
|
|
||||||
CheckBadRequestStatus(t, resp)
|
|
||||||
|
|
||||||
post2 := &model.Post{ChannelId: th.BasicChannel2.Id, Message: "zz" + model.NewId() + "a", CreateAt: 123}
|
post2 := &model.Post{ChannelId: th.BasicChannel2.Id, Message: "zz" + model.NewId() + "a", CreateAt: 123}
|
||||||
rpost2, _, _ := client.CreatePost(post2)
|
rpost2, _, _ := client.CreatePost(post2)
|
||||||
require.NotEqual(t, post2.CreateAt, rpost2.CreateAt, "create at should not match")
|
require.NotEqual(t, post2.CreateAt, rpost2.CreateAt, "create at should not match")
|
||||||
@@ -130,7 +123,6 @@ func TestCreatePost(t *testing.T) {
|
|||||||
th.RemovePermissionFromRole(model.PermissionUseChannelMentions.Id, model.ChannelUserRoleId)
|
th.RemovePermissionFromRole(model.PermissionUseChannelMentions.Id, model.ChannelUserRoleId)
|
||||||
|
|
||||||
post.RootId = rpost.Id
|
post.RootId = rpost.Id
|
||||||
post.ParentId = rpost.Id
|
|
||||||
post.Message = "a post with no channel mentions"
|
post.Message = "a post with no channel mentions"
|
||||||
_, _, err = client.CreatePost(post)
|
_, _, err = client.CreatePost(post)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -148,19 +140,16 @@ func TestCreatePost(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
post.RootId = rpost.Id
|
post.RootId = rpost.Id
|
||||||
post.ParentId = rpost.Id
|
|
||||||
post.Message = "a post with @channel"
|
post.Message = "a post with @channel"
|
||||||
_, _, err = client.CreatePost(post)
|
_, _, err = client.CreatePost(post)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
post.RootId = rpost.Id
|
post.RootId = rpost.Id
|
||||||
post.ParentId = rpost.Id
|
|
||||||
post.Message = "a post with @all"
|
post.Message = "a post with @all"
|
||||||
_, _, err = client.CreatePost(post)
|
_, _, err = client.CreatePost(post)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
post.RootId = rpost.Id
|
post.RootId = rpost.Id
|
||||||
post.ParentId = rpost.Id
|
|
||||||
post.Message = "a post with @here"
|
post.Message = "a post with @here"
|
||||||
_, _, err = client.CreatePost(post)
|
_, _, err = client.CreatePost(post)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -182,7 +171,6 @@ func TestCreatePost(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post.RootId = ""
|
post.RootId = ""
|
||||||
post.ParentId = ""
|
|
||||||
post.Type = model.PostTypeSystemGeneric
|
post.Type = model.PostTypeSystemGeneric
|
||||||
_, resp, err := client.CreatePost(post)
|
_, resp, err := client.CreatePost(post)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
@@ -190,13 +178,11 @@ func TestCreatePost(t *testing.T) {
|
|||||||
|
|
||||||
post.Type = ""
|
post.Type = ""
|
||||||
post.RootId = rpost2.Id
|
post.RootId = rpost2.Id
|
||||||
post.ParentId = rpost2.Id
|
|
||||||
_, resp, err = client.CreatePost(post)
|
_, resp, err = client.CreatePost(post)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
post.RootId = ""
|
post.RootId = ""
|
||||||
post.ParentId = ""
|
|
||||||
post.ChannelId = "junk"
|
post.ChannelId = "junk"
|
||||||
_, resp, err = client.CreatePost(post)
|
_, resp, err = client.CreatePost(post)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
@@ -1703,7 +1689,7 @@ func TestGetPostsForChannelAroundLastUnread(t *testing.T) {
|
|||||||
post3 := th.CreatePost()
|
post3 := th.CreatePost()
|
||||||
post4 := th.CreatePost()
|
post4 := th.CreatePost()
|
||||||
post5 := th.CreatePost()
|
post5 := th.CreatePost()
|
||||||
replyPost := &model.Post{ChannelId: channelId, Message: model.NewId(), RootId: post4.Id, ParentId: post4.Id}
|
replyPost := &model.Post{ChannelId: channelId, Message: model.NewId(), RootId: post4.Id}
|
||||||
post6, _, err := client.CreatePost(replyPost)
|
post6, _, err := client.CreatePost(replyPost)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
post7, _, err := client.CreatePost(replyPost)
|
post7, _, err := client.CreatePost(replyPost)
|
||||||
@@ -1907,7 +1893,6 @@ func TestGetPostsForChannelAroundLastUnread(t *testing.T) {
|
|||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
Message: model.NewId(),
|
Message: model.NewId(),
|
||||||
RootId: post4.Id,
|
RootId: post4.Id,
|
||||||
ParentId: post4.Id,
|
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
post13 := th.CreatePost()
|
post13 := th.CreatePost()
|
||||||
|
|||||||
@@ -271,7 +271,6 @@ func TestSendAutoResponseSuccess(t *testing.T) {
|
|||||||
if post.Type == model.PostTypeAutoResponder {
|
if post.Type == model.PostTypeAutoResponder {
|
||||||
autoResponderPostFound = true
|
autoResponderPostFound = true
|
||||||
assert.Equal(t, savedPost.Id, post.RootId)
|
assert.Equal(t, savedPost.Id, post.RootId)
|
||||||
assert.Equal(t, savedPost.Id, post.ParentId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert.True(t, autoResponderPostFound)
|
assert.True(t, autoResponderPostFound)
|
||||||
@@ -304,7 +303,7 @@ func TestSendAutoResponseSuccessOnThread(t *testing.T) {
|
|||||||
Message: "zz" + model.NewId() + "a",
|
Message: "zz" + model.NewId() + "a",
|
||||||
UserId: th.BasicUser.Id,
|
UserId: th.BasicUser.Id,
|
||||||
RootId: parentPost.Id,
|
RootId: parentPost.Id,
|
||||||
ParentId: parentPost.Id},
|
},
|
||||||
th.BasicChannel,
|
th.BasicChannel,
|
||||||
false, true)
|
false, true)
|
||||||
|
|
||||||
@@ -321,7 +320,6 @@ func TestSendAutoResponseSuccessOnThread(t *testing.T) {
|
|||||||
if post.Type == model.PostTypeAutoResponder {
|
if post.Type == model.PostTypeAutoResponder {
|
||||||
autoResponderPostFound = true
|
autoResponderPostFound = true
|
||||||
assert.Equal(t, savedPost.RootId, post.RootId)
|
assert.Equal(t, savedPost.RootId, post.RootId)
|
||||||
assert.Equal(t, savedPost.ParentId, post.ParentId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert.True(t, autoResponderPostFound)
|
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) {
|
if (response.ResponseType == "" || response.ResponseType == model.CommandResponseTypeEphemeral) && (response.Text != "" || response.Attachments != nil) {
|
||||||
post.ParentId = ""
|
|
||||||
a.SendEphemeralPost(post.UserId, post)
|
a.SendEphemeralPost(post.UserId, post)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,7 +569,6 @@ func (a *App) HandleCommandResponsePost(c *request.Context, command *model.Comma
|
|||||||
post := &model.Post{}
|
post := &model.Post{}
|
||||||
post.ChannelId = args.ChannelId
|
post.ChannelId = args.ChannelId
|
||||||
post.RootId = args.RootId
|
post.RootId = args.RootId
|
||||||
post.ParentId = args.ParentId
|
|
||||||
post.UserId = args.UserId
|
post.UserId = args.UserId
|
||||||
post.Type = response.Type
|
post.Type = response.Type
|
||||||
post.SetProps(response.Props)
|
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("channel_id", commandArgs.ChannelId)
|
||||||
params.Add("team_id", commandArgs.TeamId)
|
params.Add("team_id", commandArgs.TeamId)
|
||||||
params.Add("root_id", commandArgs.RootId)
|
params.Add("root_id", commandArgs.RootId)
|
||||||
params.Add("parent_id", commandArgs.ParentId)
|
|
||||||
params.Add("user_id", commandArgs.UserId)
|
params.Add("user_id", commandArgs.UserId)
|
||||||
params.Add("site_url", commandArgs.SiteURL)
|
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.UserId = user.Id
|
||||||
reply.ChannelId = post.ChannelId
|
reply.ChannelId = post.ChannelId
|
||||||
reply.ParentId = post.Id
|
|
||||||
reply.RootId = post.Id
|
reply.RootId = post.Id
|
||||||
reply.Message = *replyData.Message
|
reply.Message = *replyData.Message
|
||||||
reply.CreateAt = *replyData.CreateAt
|
reply.CreateAt = *replyData.CreateAt
|
||||||
|
|||||||
@@ -569,7 +569,6 @@ func (a *App) sendNoUsersNotifiedByGroupInChannel(sender *model.User, post *mode
|
|||||||
ephemeralPost := &model.Post{
|
ephemeralPost := &model.Post{
|
||||||
UserId: sender.Id,
|
UserId: sender.Id,
|
||||||
RootId: post.RootId,
|
RootId: post.RootId,
|
||||||
ParentId: post.ParentId,
|
|
||||||
ChannelId: channel.Id,
|
ChannelId: channel.Id,
|
||||||
Message: T("api.post.check_for_out_of_channel_group_users.message.none", model.StringInterface{"GroupName": group.Name}),
|
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)
|
rp, err := a.CreatePost(c, post, channel, true, setOnline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.Id == "api.post.create_post.root_id.app_error" ||
|
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.channel_root_id.app_error" {
|
||||||
err.Id == "api.post.create_post.parent_id.app_error" {
|
|
||||||
err.StatusCode = http.StatusBadRequest
|
err.StatusCode = http.StatusBadRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +74,6 @@ func (a *App) CreatePostAsUser(c *request.Context, post *model.Post, currentSess
|
|||||||
post.UserId,
|
post.UserId,
|
||||||
&model.Post{
|
&model.Post{
|
||||||
ChannelId: channel.Id,
|
ChannelId: channel.Id,
|
||||||
ParentId: post.ParentId,
|
|
||||||
RootId: post.RootId,
|
RootId: post.RootId,
|
||||||
UserId: post.UserId,
|
UserId: post.UserId,
|
||||||
Message: T("api.post.create_post.town_square_read_only"),
|
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{
|
ephemeralPost = &model.Post{
|
||||||
UserId: user.Id,
|
UserId: user.Id,
|
||||||
RootId: post.RootId,
|
RootId: post.RootId,
|
||||||
ParentId: post.ParentId,
|
|
||||||
ChannelId: channel.Id,
|
ChannelId: channel.Id,
|
||||||
Message: T("model.post.channel_notifications_disabled_in_channel.message", model.StringInterface{"ChannelName": channel.Name, "Mention": mention}),
|
Message: T("model.post.channel_notifications_disabled_in_channel.message", model.StringInterface{"ChannelName": channel.Name, "Mention": mention}),
|
||||||
Props: model.StringInterface{model.PostPropsMentionHighlightDisabled: true},
|
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 != "" {
|
if rootPost.RootId != "" {
|
||||||
return nil, model.NewAppError("createPost", "api.post.create_post.root_id.app_error", nil, "", http.StatusBadRequest)
|
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)
|
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
||||||
|
|||||||
@@ -346,7 +346,6 @@ func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
|
|||||||
Message: "asd",
|
Message: "asd",
|
||||||
ChannelId: channel.Id,
|
ChannelId: channel.Id,
|
||||||
RootId: rootPost.Id,
|
RootId: rootPost.Id,
|
||||||
ParentId: rootPost.Id,
|
|
||||||
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
||||||
UserId: userInChannel.Id,
|
UserId: userInChannel.Id,
|
||||||
CreateAt: 0,
|
CreateAt: 0,
|
||||||
@@ -368,7 +367,6 @@ func TestPostAttachPostToChildPost(t *testing.T) {
|
|||||||
Message: "reply one",
|
Message: "reply one",
|
||||||
ChannelId: channel.Id,
|
ChannelId: channel.Id,
|
||||||
RootId: rootPost.Id,
|
RootId: rootPost.Id,
|
||||||
ParentId: rootPost.Id,
|
|
||||||
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
||||||
UserId: user.Id,
|
UserId: user.Id,
|
||||||
CreateAt: 0,
|
CreateAt: 0,
|
||||||
@@ -381,7 +379,6 @@ func TestPostAttachPostToChildPost(t *testing.T) {
|
|||||||
Message: "reply two",
|
Message: "reply two",
|
||||||
ChannelId: channel.Id,
|
ChannelId: channel.Id,
|
||||||
RootId: res1.Id,
|
RootId: res1.Id,
|
||||||
ParentId: res1.Id,
|
|
||||||
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
||||||
UserId: user.Id,
|
UserId: user.Id,
|
||||||
CreateAt: 0,
|
CreateAt: 0,
|
||||||
@@ -394,7 +391,6 @@ func TestPostAttachPostToChildPost(t *testing.T) {
|
|||||||
Message: "reply three",
|
Message: "reply three",
|
||||||
ChannelId: channel.Id,
|
ChannelId: channel.Id,
|
||||||
RootId: rootPost.Id,
|
RootId: rootPost.Id,
|
||||||
ParentId: rootPost.Id,
|
|
||||||
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
||||||
UserId: user.Id,
|
UserId: user.Id,
|
||||||
CreateAt: 0,
|
CreateAt: 0,
|
||||||
@@ -2313,7 +2309,6 @@ func TestReplyToPostWithLag(t *testing.T) {
|
|||||||
UserId: th.BasicUser2.Id,
|
UserId: th.BasicUser2.Id,
|
||||||
ChannelId: th.BasicChannel.Id,
|
ChannelId: th.BasicChannel.Id,
|
||||||
RootId: root.Id,
|
RootId: root.Id,
|
||||||
ParentId: root.Id,
|
|
||||||
Message: fmt.Sprintf("@%s", th.BasicUser2.Username),
|
Message: fmt.Sprintf("@%s", th.BasicUser2.Username),
|
||||||
}, th.BasicChannel, false, true)
|
}, th.BasicChannel, false, true)
|
||||||
require.Nil(t, appErr)
|
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) {
|
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
|
var fileIDs []string
|
||||||
if cfg.HasImage {
|
if cfg.HasImage {
|
||||||
var err error
|
var err error
|
||||||
@@ -93,7 +93,6 @@ func (cfg *AutoPostCreator) CreateRandomPostNested(c *request.Context, parentId,
|
|||||||
post := &model.Post{
|
post := &model.Post{
|
||||||
ChannelId: cfg.channelid,
|
ChannelId: cfg.channelid,
|
||||||
UserId: cfg.userid,
|
UserId: cfg.userid,
|
||||||
ParentId: parentId,
|
|
||||||
RootId: rootId,
|
RootId: rootId,
|
||||||
Message: postText,
|
Message: postText,
|
||||||
FileIds: fileIDs,
|
FileIds: fileIDs,
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ func (*EchoProvider) DoCommand(a *app.App, c *request.Context, args *model.Comma
|
|||||||
post := &model.Post{}
|
post := &model.Post{}
|
||||||
post.ChannelId = args.ChannelId
|
post.ChannelId = args.ChannelId
|
||||||
post.RootId = args.RootId
|
post.RootId = args.RootId
|
||||||
post.ParentId = args.ParentId
|
|
||||||
post.Message = message
|
post.Message = message
|
||||||
post.UserId = args.UserId
|
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
|
return &model.CommandResponse{Text: "Failed to create a post", ResponseType: model.CommandResponseTypeEphemeral}, err2
|
||||||
}
|
}
|
||||||
for i := 0; i < 1000; i++ {
|
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
|
return &model.CommandResponse{Text: "Added threaded post", ResponseType: model.CommandResponseTypeEphemeral}, nil
|
||||||
|
|||||||
@@ -145,7 +145,6 @@ func TestHandleCommandResponsePost(t *testing.T) {
|
|||||||
TeamId: th.BasicTeam.Id,
|
TeamId: th.BasicTeam.Id,
|
||||||
UserId: th.BasicUser.Id,
|
UserId: th.BasicUser.Id,
|
||||||
RootId: "",
|
RootId: "",
|
||||||
ParentId: "",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &model.CommandResponse{
|
resp := &model.CommandResponse{
|
||||||
@@ -161,7 +160,6 @@ func TestHandleCommandResponsePost(t *testing.T) {
|
|||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, args.ChannelId, post.ChannelId)
|
assert.Equal(t, args.ChannelId, post.ChannelId)
|
||||||
assert.Equal(t, args.RootId, post.RootId)
|
assert.Equal(t, args.RootId, post.RootId)
|
||||||
assert.Equal(t, args.ParentId, post.ParentId)
|
|
||||||
assert.Equal(t, args.UserId, post.UserId)
|
assert.Equal(t, args.UserId, post.UserId)
|
||||||
assert.Equal(t, resp.Type, post.Type)
|
assert.Equal(t, resp.Type, post.Type)
|
||||||
assert.Equal(t, resp.Props, post.GetProps())
|
assert.Equal(t, resp.Props, post.GetProps())
|
||||||
|
|||||||
@@ -792,7 +792,6 @@ func (a *App) CreateCommandWebhook(commandID string, args *model.CommandArgs) (*
|
|||||||
UserId: args.UserId,
|
UserId: args.UserId,
|
||||||
ChannelId: args.ChannelId,
|
ChannelId: args.ChannelId,
|
||||||
RootId: args.RootId,
|
RootId: args.RootId,
|
||||||
ParentId: args.ParentId,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
savedHook, err := a.Srv().Store.CommandWebhook().Save(hook)
|
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,
|
ChannelId: hook.ChannelId,
|
||||||
TeamId: cmd.TeamId,
|
TeamId: cmd.TeamId,
|
||||||
RootId: hook.RootId,
|
RootId: hook.RootId,
|
||||||
ParentId: hook.ParentId,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if nErr := a.Srv().Store.CommandWebhook().TryUse(hook.Id, 5); nErr != nil {
|
if nErr := a.Srv().Store.CommandWebhook().TryUse(hook.Id, 5); nErr != nil {
|
||||||
|
|||||||
16
i18n/en.json
16
i18n/en.json
@@ -2148,10 +2148,6 @@
|
|||||||
"id": "api.post.create_post.channel_root_id.app_error",
|
"id": "api.post.create_post.channel_root_id.app_error",
|
||||||
"translation": "Invalid ChannelId for RootId parameter."
|
"translation": "Invalid ChannelId for RootId parameter."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "api.post.create_post.parent_id.app_error",
|
|
||||||
"translation": "Invalid ParentId parameter."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "api.post.create_post.root_id.app_error",
|
"id": "api.post.create_post.root_id.app_error",
|
||||||
"translation": "Invalid RootId parameter."
|
"translation": "Invalid RootId parameter."
|
||||||
@@ -7822,10 +7818,6 @@
|
|||||||
"id": "model.command_hook.id.app_error",
|
"id": "model.command_hook.id.app_error",
|
||||||
"translation": "Invalid command hook id."
|
"translation": "Invalid command hook id."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "model.command_hook.parent_id.app_error",
|
|
||||||
"translation": "Invalid parent id."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "model.command_hook.root_id.app_error",
|
"id": "model.command_hook.root_id.app_error",
|
||||||
"translation": "Invalid root id."
|
"translation": "Invalid root id."
|
||||||
@@ -8618,10 +8610,6 @@
|
|||||||
"id": "model.post.is_valid.original_id.app_error",
|
"id": "model.post.is_valid.original_id.app_error",
|
||||||
"translation": "Invalid original id."
|
"translation": "Invalid original id."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "model.post.is_valid.parent_id.app_error",
|
|
||||||
"translation": "Invalid parent id."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "model.post.is_valid.props.app_error",
|
"id": "model.post.is_valid.props.app_error",
|
||||||
"translation": "Invalid props."
|
"translation": "Invalid props."
|
||||||
@@ -8630,10 +8618,6 @@
|
|||||||
"id": "model.post.is_valid.root_id.app_error",
|
"id": "model.post.is_valid.root_id.app_error",
|
||||||
"translation": "Invalid root id."
|
"translation": "Invalid root id."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "model.post.is_valid.root_parent.app_error",
|
|
||||||
"translation": "Invalid root ID must be set if parent ID set."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "model.post.is_valid.type.app_error",
|
"id": "model.post.is_valid.type.app_error",
|
||||||
"translation": "Invalid type."
|
"translation": "Invalid type."
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ type CommandWebhook struct {
|
|||||||
UserId string
|
UserId string
|
||||||
ChannelId string
|
ChannelId string
|
||||||
RootId string
|
RootId string
|
||||||
ParentId string
|
|
||||||
UseCount int
|
UseCount int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,9 +56,5 @@ func (o *CommandWebhook) IsValid() *AppError {
|
|||||||
return NewAppError("CommandWebhook.IsValid", "model.command_hook.root_id.app_error", nil, "", http.StatusBadRequest)
|
return NewAppError("CommandWebhook.IsValid", "model.command_hook.root_id.app_error", nil, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.ParentId != "" && !IsValidId(o.ParentId) {
|
|
||||||
return NewAppError("CommandWebhook.IsValid", "model.command_hook.parent_id.app_error", nil, "", http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ func TestCommandWebhookIsValid(t *testing.T) {
|
|||||||
{func() { h.ChannelId = NewId() }, ""},
|
{func() { h.ChannelId = NewId() }, ""},
|
||||||
{func() { h.RootId = "asd" }, "model.command_hook.root_id.app_error"},
|
{func() { h.RootId = "asd" }, "model.command_hook.root_id.app_error"},
|
||||||
{func() { h.RootId = NewId() }, ""},
|
{func() { h.RootId = NewId() }, ""},
|
||||||
{func() { h.ParentId = "asd" }, "model.command_hook.parent_id.app_error"},
|
|
||||||
{func() { h.ParentId = NewId() }, ""},
|
|
||||||
} {
|
} {
|
||||||
tmp := h
|
tmp := h
|
||||||
test.Transform()
|
test.Transform()
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ type CompliancePost struct {
|
|||||||
PostUpdateAt int64
|
PostUpdateAt int64
|
||||||
PostDeleteAt int64
|
PostDeleteAt int64
|
||||||
PostRootId string
|
PostRootId string
|
||||||
PostParentId string
|
|
||||||
PostOriginalId string
|
PostOriginalId string
|
||||||
PostMessage string
|
PostMessage string
|
||||||
PostType string
|
PostType string
|
||||||
@@ -60,7 +59,6 @@ func CompliancePostHeader() []string {
|
|||||||
"PostUpdateAt",
|
"PostUpdateAt",
|
||||||
"PostDeleteAt",
|
"PostDeleteAt",
|
||||||
"PostRootId",
|
"PostRootId",
|
||||||
"PostParentId",
|
|
||||||
"PostOriginalId",
|
"PostOriginalId",
|
||||||
"PostMessage",
|
"PostMessage",
|
||||||
"PostType",
|
"PostType",
|
||||||
@@ -113,7 +111,6 @@ func (cp *CompliancePost) Row() []string {
|
|||||||
postDeleteAt,
|
postDeleteAt,
|
||||||
|
|
||||||
cp.PostRootId,
|
cp.PostRootId,
|
||||||
cp.PostParentId,
|
|
||||||
cp.PostOriginalId,
|
cp.PostOriginalId,
|
||||||
cleanComplianceStrings(cp.PostMessage),
|
cleanComplianceStrings(cp.PostMessage),
|
||||||
cp.PostType,
|
cp.PostType,
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ type Post struct {
|
|||||||
UserId string `json:"user_id"`
|
UserId string `json:"user_id"`
|
||||||
ChannelId string `json:"channel_id"`
|
ChannelId string `json:"channel_id"`
|
||||||
RootId string `json:"root_id"`
|
RootId string `json:"root_id"`
|
||||||
ParentId string `json:"parent_id"`
|
|
||||||
OriginalId string `json:"original_id"`
|
OriginalId string `json:"original_id"`
|
||||||
|
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
@@ -194,7 +193,6 @@ func (o *Post) ShallowCopy(dst *Post) error {
|
|||||||
dst.UserId = o.UserId
|
dst.UserId = o.UserId
|
||||||
dst.ChannelId = o.ChannelId
|
dst.ChannelId = o.ChannelId
|
||||||
dst.RootId = o.RootId
|
dst.RootId = o.RootId
|
||||||
dst.ParentId = o.ParentId
|
|
||||||
dst.OriginalId = o.OriginalId
|
dst.OriginalId = o.OriginalId
|
||||||
dst.Message = o.Message
|
dst.Message = o.Message
|
||||||
dst.MessageSource = o.MessageSource
|
dst.MessageSource = o.MessageSource
|
||||||
@@ -302,14 +300,6 @@ func (o *Post) IsValid(maxPostSize int) *AppError {
|
|||||||
return NewAppError("Post.IsValid", "model.post.is_valid.root_id.app_error", nil, "", http.StatusBadRequest)
|
return NewAppError("Post.IsValid", "model.post.is_valid.root_id.app_error", nil, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(IsValidId(o.ParentId) || o.ParentId == "") {
|
|
||||||
return NewAppError("Post.IsValid", "model.post.is_valid.parent_id.app_error", nil, "", http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(o.ParentId) == 26 && o.RootId == "" {
|
|
||||||
return NewAppError("Post.IsValid", "model.post.is_valid.root_parent.app_error", nil, "", http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !(len(o.OriginalId) == 26 || o.OriginalId == "") {
|
if !(len(o.OriginalId) == 26 || o.OriginalId == "") {
|
||||||
return NewAppError("Post.IsValid", "model.post.is_valid.original_id.app_error", nil, "", http.StatusBadRequest)
|
return NewAppError("Post.IsValid", "model.post.is_valid.original_id.app_error", nil, "", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,16 +56,7 @@ func TestPostIsValid(t *testing.T) {
|
|||||||
require.NotNil(t, err)
|
require.NotNil(t, err)
|
||||||
|
|
||||||
o.RootId = ""
|
o.RootId = ""
|
||||||
o.ParentId = "123"
|
|
||||||
err = o.IsValid(maxPostSize)
|
|
||||||
require.NotNil(t, err)
|
|
||||||
|
|
||||||
o.ParentId = NewId()
|
|
||||||
o.RootId = ""
|
|
||||||
err = o.IsValid(maxPostSize)
|
|
||||||
require.NotNil(t, err)
|
|
||||||
|
|
||||||
o.ParentId = ""
|
|
||||||
o.Message = strings.Repeat("0", maxPostSize+1)
|
o.Message = strings.Repeat("0", maxPostSize+1)
|
||||||
err = o.IsValid(maxPostSize)
|
err = o.IsValid(maxPostSize)
|
||||||
require.NotNil(t, err)
|
require.NotNil(t, err)
|
||||||
|
|||||||
2
services/cache/lru_test.go
поставляемый
2
services/cache/lru_test.go
поставляемый
@@ -139,7 +139,6 @@ func TestLRUMarshalUnMarshal(t *testing.T) {
|
|||||||
UserId: "UserId",
|
UserId: "UserId",
|
||||||
ChannelId: "ChannelId",
|
ChannelId: "ChannelId",
|
||||||
RootId: "RootId",
|
RootId: "RootId",
|
||||||
ParentId: "ParentId",
|
|
||||||
OriginalId: "OriginalId",
|
OriginalId: "OriginalId",
|
||||||
Message: "OriginalId",
|
Message: "OriginalId",
|
||||||
MessageSource: "MessageSource",
|
MessageSource: "MessageSource",
|
||||||
@@ -487,7 +486,6 @@ func BenchmarkLRU(b *testing.B) {
|
|||||||
UserId: "UserId",
|
UserId: "UserId",
|
||||||
ChannelId: "ChannelId",
|
ChannelId: "ChannelId",
|
||||||
RootId: "RootId",
|
RootId: "RootId",
|
||||||
ParentId: "ParentId",
|
|
||||||
OriginalId: "OriginalId",
|
OriginalId: "OriginalId",
|
||||||
Message: "OriginalId",
|
Message: "OriginalId",
|
||||||
MessageSource: "MessageSource",
|
MessageSource: "MessageSource",
|
||||||
|
|||||||
@@ -330,7 +330,6 @@ func (si *SlackImporter) slackAddPosts(teamId string, channel *model.Channel, po
|
|||||||
// If post in thread
|
// If post in thread
|
||||||
if sPost.ThreadTS != "" && sPost.ThreadTS != sPost.TimeStamp {
|
if sPost.ThreadTS != "" && sPost.ThreadTS != sPost.TimeStamp {
|
||||||
newPost.RootId = threads[sPost.ThreadTS]
|
newPost.RootId = threads[sPost.ThreadTS]
|
||||||
newPost.ParentId = threads[sPost.ThreadTS]
|
|
||||||
}
|
}
|
||||||
postId := si.oldImportPost(&newPost)
|
postId := si.oldImportPost(&newPost)
|
||||||
// If post is thread starter
|
// If post is thread starter
|
||||||
@@ -631,8 +630,8 @@ func (si *SlackImporter) oldImportPost(post *model.Post) string {
|
|||||||
// Workaround for empty messages, which may be the case if they are webhook posts.
|
// Workaround for empty messages, which may be the case if they are webhook posts.
|
||||||
firstIteration := true
|
firstIteration := true
|
||||||
firstPostId := ""
|
firstPostId := ""
|
||||||
if post.ParentId != "" {
|
if post.RootId != "" {
|
||||||
firstPostId = post.ParentId
|
firstPostId = post.RootId
|
||||||
}
|
}
|
||||||
maxPostSize := si.actions.MaxPostSize()
|
maxPostSize := si.actions.MaxPostSize()
|
||||||
for messageRuneCount := utf8.RuneCountInString(post.Message); messageRuneCount > 0 || firstIteration; messageRuneCount = utf8.RuneCountInString(post.Message) {
|
for messageRuneCount := utf8.RuneCountInString(post.Message); messageRuneCount > 0 || firstIteration; messageRuneCount = utf8.RuneCountInString(post.Message) {
|
||||||
@@ -647,7 +646,6 @@ func (si *SlackImporter) oldImportPost(post *model.Post) string {
|
|||||||
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
||||||
|
|
||||||
post.RootId = firstPostId
|
post.RootId = firstPostId
|
||||||
post.ParentId = firstPostId
|
|
||||||
|
|
||||||
_, err := si.store.Post().Save(post)
|
_, err := si.store.Post().Save(post)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -384,7 +384,6 @@ func (th *SearchTestHelper) createFileInfo(creatorID, postID, name, content, ext
|
|||||||
|
|
||||||
func (th *SearchTestHelper) createReply(userID, message, hashtags string, parent *model.Post, createAt int64, pinned bool) (*model.Post, error) {
|
func (th *SearchTestHelper) createReply(userID, message, hashtags string, parent *model.Post, createAt int64, pinned bool) (*model.Post, error) {
|
||||||
replyModel := th.createPostModel(userID, parent.ChannelId, message, hashtags, parent.Type, createAt, pinned)
|
replyModel := th.createPostModel(userID, parent.ChannelId, message, hashtags, parent.Type, createAt, pinned)
|
||||||
replyModel.ParentId = parent.Id
|
|
||||||
replyModel.RootId = parent.Id
|
replyModel.RootId = parent.Id
|
||||||
return th.Store.Post().Save(replyModel)
|
return th.Store.Post().Save(replyModel)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ func newSqlCommandWebhookStore(sqlStore *SqlStore) store.CommandWebhookStore {
|
|||||||
tablec.ColMap("UserId").SetMaxSize(26)
|
tablec.ColMap("UserId").SetMaxSize(26)
|
||||||
tablec.ColMap("ChannelId").SetMaxSize(26)
|
tablec.ColMap("ChannelId").SetMaxSize(26)
|
||||||
tablec.ColMap("RootId").SetMaxSize(26)
|
tablec.ColMap("RootId").SetMaxSize(26)
|
||||||
tablec.ColMap("ParentId").SetMaxSize(26)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ func (s SqlComplianceStore) ComplianceExport(job *model.Compliance, cursor model
|
|||||||
Posts.UpdateAt AS PostUpdateAt,
|
Posts.UpdateAt AS PostUpdateAt,
|
||||||
Posts.DeleteAt AS PostDeleteAt,
|
Posts.DeleteAt AS PostDeleteAt,
|
||||||
Posts.RootId AS PostRootId,
|
Posts.RootId AS PostRootId,
|
||||||
Posts.ParentId AS PostParentId,
|
|
||||||
Posts.OriginalId AS PostOriginalId,
|
Posts.OriginalId AS PostOriginalId,
|
||||||
Posts.Message AS PostMessage,
|
Posts.Message AS PostMessage,
|
||||||
Posts.Type AS PostType,
|
Posts.Type AS PostType,
|
||||||
@@ -200,7 +199,6 @@ func (s SqlComplianceStore) ComplianceExport(job *model.Compliance, cursor model
|
|||||||
Posts.UpdateAt AS PostUpdateAt,
|
Posts.UpdateAt AS PostUpdateAt,
|
||||||
Posts.DeleteAt AS PostDeleteAt,
|
Posts.DeleteAt AS PostDeleteAt,
|
||||||
Posts.RootId AS PostRootId,
|
Posts.RootId AS PostRootId,
|
||||||
Posts.ParentId AS PostParentId,
|
|
||||||
Posts.OriginalId AS PostOriginalId,
|
Posts.OriginalId AS PostOriginalId,
|
||||||
Posts.Message AS PostMessage,
|
Posts.Message AS PostMessage,
|
||||||
Posts.Type AS PostType,
|
Posts.Type AS PostType,
|
||||||
|
|||||||
@@ -150,16 +150,6 @@ func checkPostsFileInfoIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPostsPostsParentIdIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
|
||||||
parentName: "Posts",
|
|
||||||
parentIdAttr: "ParentId",
|
|
||||||
childName: "Posts",
|
|
||||||
childIdAttr: "Id",
|
|
||||||
canParentIdBeEmpty: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkPostsPostsRootIdIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
func checkPostsPostsRootIdIntegrity(ss *SqlStore) model.IntegrityCheckResult {
|
||||||
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
return checkParentChildIntegrity(ss, relationalCheckConfig{
|
||||||
parentName: "Posts",
|
parentName: "Posts",
|
||||||
@@ -474,7 +464,6 @@ func checkCommandsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckRes
|
|||||||
|
|
||||||
func checkPostsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
func checkPostsIntegrity(ss *SqlStore, results chan<- model.IntegrityCheckResult) {
|
||||||
results <- checkPostsFileInfoIntegrity(ss)
|
results <- checkPostsFileInfoIntegrity(ss)
|
||||||
results <- checkPostsPostsParentIdIntegrity(ss)
|
|
||||||
results <- checkPostsPostsRootIdIntegrity(ss)
|
results <- checkPostsPostsRootIdIntegrity(ss)
|
||||||
results <- checkPostsReactionsIntegrity(ss)
|
results <- checkPostsReactionsIntegrity(ss)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,6 @@ func createPost(ss store.Store, channelId, userId, rootId, parentId string) *mod
|
|||||||
m.ChannelId = channelId
|
m.ChannelId = channelId
|
||||||
m.UserId = userId
|
m.UserId = userId
|
||||||
m.RootId = rootId
|
m.RootId = rootId
|
||||||
m.ParentId = parentId
|
|
||||||
m.Message = "zz" + model.NewId() + "b"
|
m.Message = "zz" + model.NewId() + "b"
|
||||||
p, _ := ss.Post().Save(&m)
|
p, _ := ss.Post().Save(&m)
|
||||||
return p
|
return p
|
||||||
@@ -604,51 +603,6 @@ func TestCheckPostsFileInfoIntegrity(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
|
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
|
||||||
store := ss.(*SqlStore)
|
|
||||||
dbmap := store.GetMaster()
|
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
|
||||||
result := checkPostsPostsParentIdIntegrity(store)
|
|
||||||
require.NoError(t, result.Err)
|
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
|
||||||
require.Empty(t, data.Records)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("should generate a report with no records", func(t *testing.T) {
|
|
||||||
root := createPost(ss, model.NewId(), model.NewId(), "", "")
|
|
||||||
parent := createPost(ss, model.NewId(), model.NewId(), root.Id, root.Id)
|
|
||||||
post := createPost(ss, model.NewId(), model.NewId(), root.Id, parent.Id)
|
|
||||||
result := checkPostsPostsParentIdIntegrity(store)
|
|
||||||
require.NoError(t, result.Err)
|
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
|
||||||
require.Empty(t, data.Records)
|
|
||||||
dbmap.Delete(parent)
|
|
||||||
dbmap.Delete(root)
|
|
||||||
dbmap.Delete(post)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("should generate a report with one record", func(t *testing.T) {
|
|
||||||
root := createPost(ss, model.NewId(), model.NewId(), "", "")
|
|
||||||
parent := createPost(ss, model.NewId(), model.NewId(), root.Id, root.Id)
|
|
||||||
parentId := parent.Id
|
|
||||||
post := createPost(ss, model.NewId(), model.NewId(), root.Id, parent.Id)
|
|
||||||
dbmap.Delete(parent)
|
|
||||||
result := checkPostsPostsParentIdIntegrity(store)
|
|
||||||
require.NoError(t, result.Err)
|
|
||||||
data := result.Data.(model.RelationalIntegrityCheckData)
|
|
||||||
require.Len(t, data.Records, 1)
|
|
||||||
require.Equal(t, model.OrphanedRecord{
|
|
||||||
ParentId: &parentId,
|
|
||||||
ChildId: &post.Id,
|
|
||||||
}, data.Records[0])
|
|
||||||
dbmap.Delete(root)
|
|
||||||
dbmap.Delete(post)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
|
func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
|
||||||
StoreTest(t, func(t *testing.T, ss store.Store) {
|
StoreTest(t, func(t *testing.T, ss store.Store) {
|
||||||
store := ss.(*SqlStore)
|
store := ss.(*SqlStore)
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ func postSliceColumnsWithTypes() []struct {
|
|||||||
{"UserId", reflect.String},
|
{"UserId", reflect.String},
|
||||||
{"ChannelId", reflect.String},
|
{"ChannelId", reflect.String},
|
||||||
{"RootId", reflect.String},
|
{"RootId", reflect.String},
|
||||||
{"ParentId", reflect.String},
|
|
||||||
{"OriginalId", reflect.String},
|
{"OriginalId", reflect.String},
|
||||||
{"Message", reflect.String},
|
{"Message", reflect.String},
|
||||||
{"Type", reflect.String},
|
{"Type", reflect.String},
|
||||||
@@ -84,7 +83,6 @@ func postToSlice(post *model.Post) []interface{} {
|
|||||||
post.UserId,
|
post.UserId,
|
||||||
post.ChannelId,
|
post.ChannelId,
|
||||||
post.RootId,
|
post.RootId,
|
||||||
post.ParentId,
|
|
||||||
post.OriginalId,
|
post.OriginalId,
|
||||||
post.Message,
|
post.Message,
|
||||||
post.Type,
|
post.Type,
|
||||||
@@ -141,7 +139,6 @@ func newSqlPostStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) s
|
|||||||
table.ColMap("UserId").SetMaxSize(26)
|
table.ColMap("UserId").SetMaxSize(26)
|
||||||
table.ColMap("ChannelId").SetMaxSize(26)
|
table.ColMap("ChannelId").SetMaxSize(26)
|
||||||
table.ColMap("RootId").SetMaxSize(26)
|
table.ColMap("RootId").SetMaxSize(26)
|
||||||
table.ColMap("ParentId").SetMaxSize(26)
|
|
||||||
table.ColMap("OriginalId").SetMaxSize(26)
|
table.ColMap("OriginalId").SetMaxSize(26)
|
||||||
table.ColMap("Message").SetMaxSize(model.PostMessageMaxBytesV2)
|
table.ColMap("Message").SetMaxSize(model.PostMessageMaxBytesV2)
|
||||||
table.ColMap("Type").SetMaxSize(26)
|
table.ColMap("Type").SetMaxSize(26)
|
||||||
@@ -2229,7 +2226,7 @@ func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId str
|
|||||||
Join("Users ON p.UserId = Users.Id").
|
Join("Users ON p.UserId = Users.Id").
|
||||||
Where(sq.And{
|
Where(sq.And{
|
||||||
sq.Gt{"p.Id": afterId},
|
sq.Gt{"p.Id": afterId},
|
||||||
sq.Eq{"p.ParentId": string("")},
|
sq.Eq{"p.RootId": string("")},
|
||||||
sq.Eq{"p.DeleteAt": int(0)},
|
sq.Eq{"p.DeleteAt": int(0)},
|
||||||
sq.Eq{"Channels.DeleteAt": int(0)},
|
sq.Eq{"Channels.DeleteAt": int(0)},
|
||||||
sq.Eq{"Users.DeleteAt": int(0)},
|
sq.Eq{"Users.DeleteAt": int(0)},
|
||||||
|
|||||||
@@ -1311,6 +1311,11 @@ func upgradeDatabaseToVersion600(sqlStore *SqlStore) {
|
|||||||
sqlStore.AlterColumnTypeIfExists("Users", "NotifyProps", "JSON", "jsonb")
|
sqlStore.AlterColumnTypeIfExists("Users", "NotifyProps", "JSON", "jsonb")
|
||||||
sqlStore.AlterColumnTypeIfExists("Users", "Timezone", "JSON", "jsonb")
|
sqlStore.AlterColumnTypeIfExists("Users", "Timezone", "JSON", "jsonb")
|
||||||
|
|
||||||
|
sqlStore.GetMaster().ExecNoTimeout("UPDATE Posts SET RootId = ParentId WHERE RootId = '' AND RootId != ParentId")
|
||||||
|
sqlStore.RemoveColumnIfExists("Posts", "ParentId")
|
||||||
|
sqlStore.GetMaster().ExecNoTimeout("UPDATE CommandWebhooks SET RootId = ParentId WHERE RootId = '' AND RootId != ParentId")
|
||||||
|
sqlStore.RemoveColumnIfExists("CommandWebhooks", "ParentId")
|
||||||
|
|
||||||
// saveSchemaVersion(sqlStore, Version600)
|
// saveSchemaVersion(sqlStore, Version600)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,13 +125,12 @@ func createChannelMemberWithLastViewAt(ss store.Store, channelId, userId string,
|
|||||||
cm, _ := ss.Channel().SaveMember(&m)
|
cm, _ := ss.Channel().SaveMember(&m)
|
||||||
return cm
|
return cm
|
||||||
}
|
}
|
||||||
func createPostWithTimestamp(ss store.Store, channelId, userId, rootId, parentId string, timestamp int64) *model.Post {
|
func createPostWithTimestamp(ss store.Store, channelId, userId, rootId string, timestamp int64) *model.Post {
|
||||||
m := model.Post{}
|
m := model.Post{}
|
||||||
m.CreateAt = timestamp
|
m.CreateAt = timestamp
|
||||||
m.ChannelId = channelId
|
m.ChannelId = channelId
|
||||||
m.UserId = userId
|
m.UserId = userId
|
||||||
m.RootId = rootId
|
m.RootId = rootId
|
||||||
m.ParentId = parentId
|
|
||||||
m.Message = "zz" + model.NewId() + "b"
|
m.Message = "zz" + model.NewId() + "b"
|
||||||
p, _ := ss.Post().Save(&m)
|
p, _ := ss.Post().Save(&m)
|
||||||
return p
|
return p
|
||||||
@@ -225,10 +224,10 @@ func TestMsgCountRootMigration(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for i, pt := range testChannel.PostTimes {
|
for i, pt := range testChannel.PostTimes {
|
||||||
rt := testChannel.ReplyTimes[i]
|
rt := testChannel.ReplyTimes[i]
|
||||||
post := createPostWithTimestamp(ss, channel.Id, model.NewId(), "", "", pt)
|
post := createPostWithTimestamp(ss, channel.Id, model.NewId(), "", pt)
|
||||||
require.NotNil(t, post)
|
require.NotNil(t, post)
|
||||||
if rt > 0 {
|
if rt > 0 {
|
||||||
reply := createPostWithTimestamp(ss, channel.Id, model.NewId(), post.Id, post.Id, rt)
|
reply := createPostWithTimestamp(ss, channel.Id, model.NewId(), post.Id, rt)
|
||||||
require.NotNil(t, reply)
|
require.NotNil(t, reply)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,12 +275,12 @@ func TestFixCRTCountsAndUnreads(t *testing.T) {
|
|||||||
// - user2: reply 2 to root post 1
|
// - user2: reply 2 to root post 1
|
||||||
// - user1: reply 3 to root post 1
|
// - user1: reply 3 to root post 1
|
||||||
// - user2: reply 4 to root post 1
|
// - user2: reply 4 to root post 1
|
||||||
rootPost1 := createPostWithTimestamp(ss, c1.Id, uId2, "", "", 1)
|
rootPost1 := createPostWithTimestamp(ss, c1.Id, uId2, "", 1)
|
||||||
lastReplyAt := int64(40)
|
lastReplyAt := int64(40)
|
||||||
_ = createPostWithTimestamp(ss, c1.Id, uId1, rootPost1.Id, rootPost1.Id, 10)
|
_ = createPostWithTimestamp(ss, c1.Id, uId1, rootPost1.Id, 10)
|
||||||
_ = createPostWithTimestamp(ss, c1.Id, uId2, rootPost1.Id, rootPost1.Id, 20)
|
_ = createPostWithTimestamp(ss, c1.Id, uId2, rootPost1.Id, 20)
|
||||||
_ = createPostWithTimestamp(ss, c1.Id, uId1, rootPost1.Id, rootPost1.Id, 30)
|
_ = createPostWithTimestamp(ss, c1.Id, uId1, rootPost1.Id, 30)
|
||||||
_ = createPostWithTimestamp(ss, c1.Id, uId2, rootPost1.Id, rootPost1.Id, lastReplyAt)
|
_ = createPostWithTimestamp(ss, c1.Id, uId2, rootPost1.Id, lastReplyAt)
|
||||||
|
|
||||||
// Check created thread is good
|
// Check created thread is good
|
||||||
goodThread1, err := ss.Thread().Get(rootPost1.Id)
|
goodThread1, err := ss.Thread().Get(rootPost1.Id)
|
||||||
|
|||||||
@@ -5952,7 +5952,6 @@ func testChannelStoreGetPinnedPosts(t *testing.T, ss store.Store) {
|
|||||||
post3, err := ss.Post().Save(&model.Post{
|
post3, err := ss.Post().Save(&model.Post{
|
||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
ParentId: post1.Id,
|
|
||||||
RootId: post1.Id,
|
RootId: post1.Id,
|
||||||
Message: "message",
|
Message: "message",
|
||||||
IsPinned: true,
|
IsPinned: true,
|
||||||
|
|||||||
@@ -658,7 +658,6 @@ func testFileInfoStoreGetFilesBatchForIndexing(t *testing.T, ss store.Store) {
|
|||||||
o3 := &model.Post{}
|
o3 := &model.Post{}
|
||||||
o3.ChannelId = c1.Id
|
o3.ChannelId = c1.Id
|
||||||
o3.UserId = model.NewId()
|
o3.UserId = model.NewId()
|
||||||
o3.ParentId = o1.Id
|
|
||||||
o3.RootId = o1.Id
|
o3.RootId = o1.Id
|
||||||
o3.Message = "zz" + model.NewId() + "QQQQQQQQQQ"
|
o3.Message = "zz" + model.NewId() + "QQQQQQQQQQ"
|
||||||
o3, err = ss.Post().Save(o3)
|
o3, err = ss.Post().Save(o3)
|
||||||
|
|||||||
@@ -525,7 +525,6 @@ func testPostStoreUpdate(t *testing.T, ss store.Store) {
|
|||||||
o2.ChannelId = o1.ChannelId
|
o2.ChannelId = o1.ChannelId
|
||||||
o2.UserId = model.NewId()
|
o2.UserId = model.NewId()
|
||||||
o2.Message = "zz" + model.NewId() + "CCCCCCCCC"
|
o2.Message = "zz" + model.NewId() + "CCCCCCCCC"
|
||||||
o2.ParentId = o1.Id
|
|
||||||
o2.RootId = o1.Id
|
o2.RootId = o1.Id
|
||||||
o2, err = ss.Post().Save(o2)
|
o2, err = ss.Post().Save(o2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -657,7 +656,6 @@ func testPostStoreDelete1Level(t *testing.T, ss store.Store) {
|
|||||||
o2.ChannelId = o1.ChannelId
|
o2.ChannelId = o1.ChannelId
|
||||||
o2.UserId = model.NewId()
|
o2.UserId = model.NewId()
|
||||||
o2.Message = "zz" + model.NewId() + "b"
|
o2.Message = "zz" + model.NewId() + "b"
|
||||||
o2.ParentId = o1.Id
|
|
||||||
o2.RootId = o1.Id
|
o2.RootId = o1.Id
|
||||||
o2, err = ss.Post().Save(o2)
|
o2, err = ss.Post().Save(o2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -684,7 +682,6 @@ func testPostStoreDelete2Level(t *testing.T, ss store.Store) {
|
|||||||
o2.ChannelId = o1.ChannelId
|
o2.ChannelId = o1.ChannelId
|
||||||
o2.UserId = model.NewId()
|
o2.UserId = model.NewId()
|
||||||
o2.Message = "zz" + model.NewId() + "b"
|
o2.Message = "zz" + model.NewId() + "b"
|
||||||
o2.ParentId = o1.Id
|
|
||||||
o2.RootId = o1.Id
|
o2.RootId = o1.Id
|
||||||
o2, err = ss.Post().Save(o2)
|
o2, err = ss.Post().Save(o2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -693,7 +690,6 @@ func testPostStoreDelete2Level(t *testing.T, ss store.Store) {
|
|||||||
o3.ChannelId = o1.ChannelId
|
o3.ChannelId = o1.ChannelId
|
||||||
o3.UserId = model.NewId()
|
o3.UserId = model.NewId()
|
||||||
o3.Message = "zz" + model.NewId() + "b"
|
o3.Message = "zz" + model.NewId() + "b"
|
||||||
o3.ParentId = o2.Id
|
|
||||||
o3.RootId = o1.Id
|
o3.RootId = o1.Id
|
||||||
o3, err = ss.Post().Save(o3)
|
o3, err = ss.Post().Save(o3)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -733,7 +729,6 @@ func testPostStorePermDelete1Level(t *testing.T, ss store.Store) {
|
|||||||
o2.ChannelId = o1.ChannelId
|
o2.ChannelId = o1.ChannelId
|
||||||
o2.UserId = model.NewId()
|
o2.UserId = model.NewId()
|
||||||
o2.Message = "zz" + model.NewId() + "b"
|
o2.Message = "zz" + model.NewId() + "b"
|
||||||
o2.ParentId = o1.Id
|
|
||||||
o2.RootId = o1.Id
|
o2.RootId = o1.Id
|
||||||
o2, err = ss.Post().Save(o2)
|
o2, err = ss.Post().Save(o2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -773,7 +768,6 @@ func testPostStorePermDelete1Level2(t *testing.T, ss store.Store) {
|
|||||||
o2.ChannelId = o1.ChannelId
|
o2.ChannelId = o1.ChannelId
|
||||||
o2.UserId = model.NewId()
|
o2.UserId = model.NewId()
|
||||||
o2.Message = "zz" + model.NewId() + "b"
|
o2.Message = "zz" + model.NewId() + "b"
|
||||||
o2.ParentId = o1.Id
|
|
||||||
o2.RootId = o1.Id
|
o2.RootId = o1.Id
|
||||||
o2, err = ss.Post().Save(o2)
|
o2, err = ss.Post().Save(o2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -810,7 +804,6 @@ func testPostStoreGetWithChildren(t *testing.T, ss store.Store) {
|
|||||||
o2.ChannelId = o1.ChannelId
|
o2.ChannelId = o1.ChannelId
|
||||||
o2.UserId = model.NewId()
|
o2.UserId = model.NewId()
|
||||||
o2.Message = "zz" + model.NewId() + "b"
|
o2.Message = "zz" + model.NewId() + "b"
|
||||||
o2.ParentId = o1.Id
|
|
||||||
o2.RootId = o1.Id
|
o2.RootId = o1.Id
|
||||||
o2, err = ss.Post().Save(o2)
|
o2, err = ss.Post().Save(o2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -819,7 +812,6 @@ func testPostStoreGetWithChildren(t *testing.T, ss store.Store) {
|
|||||||
o3.ChannelId = o1.ChannelId
|
o3.ChannelId = o1.ChannelId
|
||||||
o3.UserId = model.NewId()
|
o3.UserId = model.NewId()
|
||||||
o3.Message = "zz" + model.NewId() + "b"
|
o3.Message = "zz" + model.NewId() + "b"
|
||||||
o3.ParentId = o2.Id
|
|
||||||
o3.RootId = o1.Id
|
o3.RootId = o1.Id
|
||||||
o3, err = ss.Post().Save(o3)
|
o3, err = ss.Post().Save(o3)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -859,7 +851,6 @@ func testPostStoreGetPostsWithDetails(t *testing.T, ss store.Store) {
|
|||||||
o2.ChannelId = o1.ChannelId
|
o2.ChannelId = o1.ChannelId
|
||||||
o2.UserId = model.NewId()
|
o2.UserId = model.NewId()
|
||||||
o2.Message = "zz" + model.NewId() + "b"
|
o2.Message = "zz" + model.NewId() + "b"
|
||||||
o2.ParentId = o1.Id
|
|
||||||
o2.RootId = o1.Id
|
o2.RootId = o1.Id
|
||||||
_, err = ss.Post().Save(o2)
|
_, err = ss.Post().Save(o2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -869,7 +860,6 @@ func testPostStoreGetPostsWithDetails(t *testing.T, ss store.Store) {
|
|||||||
o2a.ChannelId = o1.ChannelId
|
o2a.ChannelId = o1.ChannelId
|
||||||
o2a.UserId = model.NewId()
|
o2a.UserId = model.NewId()
|
||||||
o2a.Message = "zz" + model.NewId() + "b"
|
o2a.Message = "zz" + model.NewId() + "b"
|
||||||
o2a.ParentId = o1.Id
|
|
||||||
o2a.RootId = o1.Id
|
o2a.RootId = o1.Id
|
||||||
o2a, err = ss.Post().Save(o2a)
|
o2a, err = ss.Post().Save(o2a)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -879,7 +869,6 @@ func testPostStoreGetPostsWithDetails(t *testing.T, ss store.Store) {
|
|||||||
o3.ChannelId = o1.ChannelId
|
o3.ChannelId = o1.ChannelId
|
||||||
o3.UserId = model.NewId()
|
o3.UserId = model.NewId()
|
||||||
o3.Message = "zz" + model.NewId() + "b"
|
o3.Message = "zz" + model.NewId() + "b"
|
||||||
o3.ParentId = o1.Id
|
|
||||||
o3.RootId = o1.Id
|
o3.RootId = o1.Id
|
||||||
o3, err = ss.Post().Save(o3)
|
o3, err = ss.Post().Save(o3)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -897,7 +886,6 @@ func testPostStoreGetPostsWithDetails(t *testing.T, ss store.Store) {
|
|||||||
o5.ChannelId = o1.ChannelId
|
o5.ChannelId = o1.ChannelId
|
||||||
o5.UserId = model.NewId()
|
o5.UserId = model.NewId()
|
||||||
o5.Message = "zz" + model.NewId() + "b"
|
o5.Message = "zz" + model.NewId() + "b"
|
||||||
o5.ParentId = o4.Id
|
|
||||||
o5.RootId = o4.Id
|
o5.RootId = o4.Id
|
||||||
o5, err = ss.Post().Save(o5)
|
o5, err = ss.Post().Save(o5)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -1073,7 +1061,6 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
post3, err := ss.Post().Save(&model.Post{
|
post3, err := ss.Post().Save(&model.Post{
|
||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
ParentId: post1.Id,
|
|
||||||
RootId: post1.Id,
|
RootId: post1.Id,
|
||||||
Message: "message",
|
Message: "message",
|
||||||
})
|
})
|
||||||
@@ -1085,7 +1072,6 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
RootId: post2.Id,
|
RootId: post2.Id,
|
||||||
ParentId: post2.Id,
|
|
||||||
Message: "message",
|
Message: "message",
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -1103,7 +1089,6 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
post6, err := ss.Post().Save(&model.Post{
|
post6, err := ss.Post().Save(&model.Post{
|
||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
ParentId: post2.Id,
|
|
||||||
RootId: post2.Id,
|
RootId: post2.Id,
|
||||||
Message: "message",
|
Message: "message",
|
||||||
})
|
})
|
||||||
@@ -1174,7 +1159,6 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
post3, err := ss.Post().Save(&model.Post{
|
post3, err := ss.Post().Save(&model.Post{
|
||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
ParentId: post1.Id,
|
|
||||||
RootId: post1.Id,
|
RootId: post1.Id,
|
||||||
Message: "post3",
|
Message: "post3",
|
||||||
})
|
})
|
||||||
@@ -1186,7 +1170,6 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
RootId: post2.Id,
|
RootId: post2.Id,
|
||||||
ParentId: post2.Id,
|
|
||||||
Message: "post4",
|
Message: "post4",
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -1204,7 +1187,6 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
post6, err := ss.Post().Save(&model.Post{
|
post6, err := ss.Post().Save(&model.Post{
|
||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
ParentId: post2.Id,
|
|
||||||
RootId: post2.Id,
|
RootId: post2.Id,
|
||||||
Message: "post6",
|
Message: "post6",
|
||||||
})
|
})
|
||||||
@@ -1283,7 +1265,6 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
post3, err := ss.Post().Save(&model.Post{
|
post3, err := ss.Post().Save(&model.Post{
|
||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
ParentId: post1.Id,
|
|
||||||
RootId: post1.Id,
|
RootId: post1.Id,
|
||||||
Message: "post3",
|
Message: "post3",
|
||||||
})
|
})
|
||||||
@@ -1295,7 +1276,6 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
RootId: post2.Id,
|
RootId: post2.Id,
|
||||||
ParentId: post2.Id,
|
|
||||||
Message: "post4",
|
Message: "post4",
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -1313,7 +1293,6 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
post6, err := ss.Post().Save(&model.Post{
|
post6, err := ss.Post().Save(&model.Post{
|
||||||
ChannelId: channelId,
|
ChannelId: channelId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
ParentId: post2.Id,
|
|
||||||
RootId: post2.Id,
|
RootId: post2.Id,
|
||||||
Message: "post6",
|
Message: "post6",
|
||||||
})
|
})
|
||||||
@@ -1606,7 +1585,6 @@ func testPostStoreGetPostBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
o0a.ChannelId = channelId
|
o0a.ChannelId = channelId
|
||||||
o0a.UserId = model.NewId()
|
o0a.UserId = model.NewId()
|
||||||
o0a.Message = "zz" + model.NewId() + "b"
|
o0a.Message = "zz" + model.NewId() + "b"
|
||||||
o0a.ParentId = o1.Id
|
|
||||||
o0a.RootId = o1.Id
|
o0a.RootId = o1.Id
|
||||||
_, err = ss.Post().Save(o0a)
|
_, err = ss.Post().Save(o0a)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -1616,7 +1594,6 @@ func testPostStoreGetPostBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
o0b.ChannelId = channelId
|
o0b.ChannelId = channelId
|
||||||
o0b.UserId = model.NewId()
|
o0b.UserId = model.NewId()
|
||||||
o0b.Message = "deleted message"
|
o0b.Message = "deleted message"
|
||||||
o0b.ParentId = o1.Id
|
|
||||||
o0b.RootId = o1.Id
|
o0b.RootId = o1.Id
|
||||||
o0b.DeleteAt = 1
|
o0b.DeleteAt = 1
|
||||||
_, err = ss.Post().Save(o0b)
|
_, err = ss.Post().Save(o0b)
|
||||||
@@ -1643,7 +1620,6 @@ func testPostStoreGetPostBeforeAfter(t *testing.T, ss store.Store) {
|
|||||||
o2a.ChannelId = channelId
|
o2a.ChannelId = channelId
|
||||||
o2a.UserId = model.NewId()
|
o2a.UserId = model.NewId()
|
||||||
o2a.Message = "zz" + model.NewId() + "b"
|
o2a.Message = "zz" + model.NewId() + "b"
|
||||||
o2a.ParentId = o2.Id
|
|
||||||
o2a.RootId = o2.Id
|
o2a.RootId = o2.Id
|
||||||
_, err = ss.Post().Save(o2a)
|
_, err = ss.Post().Save(o2a)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -2252,7 +2228,6 @@ func testPostStoreGetPostsCreatedAt(t *testing.T, ss store.Store) {
|
|||||||
o2.ChannelId = o1.ChannelId
|
o2.ChannelId = o1.ChannelId
|
||||||
o2.UserId = model.NewId()
|
o2.UserId = model.NewId()
|
||||||
o2.Message = "zz" + model.NewId() + "b"
|
o2.Message = "zz" + model.NewId() + "b"
|
||||||
o2.ParentId = o1.Id
|
|
||||||
o2.RootId = o1.Id
|
o2.RootId = o1.Id
|
||||||
o2.CreateAt = createTime + 1
|
o2.CreateAt = createTime + 1
|
||||||
_, err = ss.Post().Save(o2)
|
_, err = ss.Post().Save(o2)
|
||||||
@@ -2282,7 +2257,6 @@ func testPostStoreOverwriteMultiple(t *testing.T, ss store.Store) {
|
|||||||
o2.ChannelId = o1.ChannelId
|
o2.ChannelId = o1.ChannelId
|
||||||
o2.UserId = model.NewId()
|
o2.UserId = model.NewId()
|
||||||
o2.Message = "zz" + model.NewId() + "CCCCCCCCC"
|
o2.Message = "zz" + model.NewId() + "CCCCCCCCC"
|
||||||
o2.ParentId = o1.Id
|
|
||||||
o2.RootId = o1.Id
|
o2.RootId = o1.Id
|
||||||
o2, err = ss.Post().Save(o2)
|
o2, err = ss.Post().Save(o2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -2409,7 +2383,6 @@ func testPostStoreOverwrite(t *testing.T, ss store.Store) {
|
|||||||
o2.ChannelId = o1.ChannelId
|
o2.ChannelId = o1.ChannelId
|
||||||
o2.UserId = model.NewId()
|
o2.UserId = model.NewId()
|
||||||
o2.Message = "zz" + model.NewId() + "CCCCCCCCC"
|
o2.Message = "zz" + model.NewId() + "CCCCCCCCC"
|
||||||
o2.ParentId = o1.Id
|
|
||||||
o2.RootId = o1.Id
|
o2.RootId = o1.Id
|
||||||
o2, err = ss.Post().Save(o2)
|
o2, err = ss.Post().Save(o2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -2583,7 +2556,6 @@ func testPostStoreGetPostsBatchForIndexing(t *testing.T, ss store.Store) {
|
|||||||
o3 := &model.Post{}
|
o3 := &model.Post{}
|
||||||
o3.ChannelId = c1.Id
|
o3.ChannelId = c1.Id
|
||||||
o3.UserId = model.NewId()
|
o3.UserId = model.NewId()
|
||||||
o3.ParentId = o1.Id
|
|
||||||
o3.RootId = o1.Id
|
o3.RootId = o1.Id
|
||||||
o3.Message = "zz" + model.NewId() + "QQQQQQQQQQ"
|
o3.Message = "zz" + model.NewId() + "QQQQQQQQQQ"
|
||||||
o3, err = ss.Post().Save(o3)
|
o3, err = ss.Post().Save(o3)
|
||||||
@@ -2935,7 +2907,6 @@ func testPostStoreGetRepliesForExport(t *testing.T, ss store.Store) {
|
|||||||
p2.UserId = u1.Id
|
p2.UserId = u1.Id
|
||||||
p2.Message = "zz" + model.NewId() + "AAAAAAAAAAA"
|
p2.Message = "zz" + model.NewId() + "AAAAAAAAAAA"
|
||||||
p2.CreateAt = 1001
|
p2.CreateAt = 1001
|
||||||
p2.ParentId = p1.Id
|
|
||||||
p2.RootId = p1.Id
|
p2.RootId = p1.Id
|
||||||
p2, nErr = ss.Post().Save(p2)
|
p2, nErr = ss.Post().Save(p2)
|
||||||
require.NoError(t, nErr)
|
require.NoError(t, nErr)
|
||||||
|
|||||||
@@ -455,7 +455,6 @@ func threadStoreCreateReply(t *testing.T, ss store.Store, channelID, postID stri
|
|||||||
UserId: model.NewId(),
|
UserId: model.NewId(),
|
||||||
CreateAt: createAt,
|
CreateAt: createAt,
|
||||||
RootId: postID,
|
RootId: postID,
|
||||||
ParentId: postID,
|
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return reply
|
return reply
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user