Use flags for create post (#28857)

* Use flags for create post

* Remove unintended file

* Fix unintended change and types

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Daniel Espino García 2024-10-22 16:00:26 +02:00 committed by GitHub
parent 43a06d1b78
commit 2d96053012
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 293 additions and 288 deletions

View file

@ -1287,7 +1287,7 @@ func TestUpdatePost(t *testing.T) {
ChannelId: channel.Id,
Message: "zz" + model.NewId() + "a",
FileIds: fileIds,
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
assert.Equal(t, rpost.Message, rpost.Message, "full name didn't match")
@ -1344,7 +1344,7 @@ func TestUpdatePost(t *testing.T) {
Message: "zz" + model.NewId() + "a",
Type: model.PostTypeJoinLeave,
UserId: th.BasicUser.Id,
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
up2 := &model.Post{
@ -1361,7 +1361,7 @@ func TestUpdatePost(t *testing.T) {
ChannelId: channel.Id,
Message: "zz" + model.NewId() + "a",
UserId: th.BasicUser.Id,
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
t.Run("new message, add files", func(t *testing.T) {
@ -1410,7 +1410,7 @@ func TestUpdatePost(t *testing.T) {
Message: "zz" + model.NewId() + "a",
UserId: th.BasicUser.Id,
CreateAt: model.GetMillis() - 2000,
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
up4 := &model.Post{
@ -3612,13 +3612,13 @@ func TestSetChannelUnread(t *testing.T) {
t.Run("Unread on a direct channel in a thread", func(t *testing.T) {
dc := th.CreateDmChannel(th.CreateUser())
rootPost, appErr := th.App.CreatePost(th.Context, &model.Post{UserId: u1.Id, CreateAt: now, ChannelId: dc.Id, Message: "root"}, dc, false, false)
rootPost, appErr := th.App.CreatePost(th.Context, &model.Post{UserId: u1.Id, CreateAt: now, ChannelId: dc.Id, Message: "root"}, dc, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: u1.Id, CreateAt: now + 10, ChannelId: dc.Id, Message: "reply 1"}, dc, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: u1.Id, CreateAt: now + 10, ChannelId: dc.Id, Message: "reply 1"}, dc, model.CreatePostFlags{})
require.Nil(t, appErr)
reply2, appErr := th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: u1.Id, CreateAt: now + 20, ChannelId: dc.Id, Message: "reply 2"}, dc, false, false)
reply2, appErr := th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: u1.Id, CreateAt: now + 20, ChannelId: dc.Id, Message: "reply 2"}, dc, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: u1.Id, CreateAt: now + 30, ChannelId: dc.Id, Message: "reply 3"}, dc, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: u1.Id, CreateAt: now + 30, ChannelId: dc.Id, Message: "reply 3"}, dc, model.CreatePostFlags{})
require.Nil(t, appErr)
// Ensure that post have been read
@ -3714,19 +3714,19 @@ func TestSetPostUnreadWithoutCollapsedThreads(t *testing.T) {
// user1: a root post
// user2: Another root mention @u1
user1Mention := " @" + th.BasicUser.Username
rootPost1, appErr := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "first root mention" + user1Mention}, th.BasicChannel, false, false)
rootPost1, appErr := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "first root mention" + user1Mention}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "hello"}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "hello"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
replyPost1, appErr := th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "mention" + user1Mention}, th.BasicChannel, false, false)
replyPost1, appErr := th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "mention" + user1Mention}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another reply"}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another reply"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another mention" + user1Mention}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another mention" + user1Mention}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "a root post"}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "a root post"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another root mention" + user1Mention}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another root mention" + user1Mention}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
t.Run("Mark reply post as unread", func(t *testing.T) {
@ -3830,7 +3830,7 @@ func TestGetEditHistoryForPost(t *testing.T) {
UserId: th.BasicUser.Id,
}
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
time.Sleep(1 * time.Millisecond)

View file

@ -534,7 +534,7 @@ type AppIface interface {
CreateOAuthUser(c request.CTX, service string, userData io.Reader, teamID string, tokenUser *model.User) (*model.User, *model.AppError)
CreateOutgoingWebhook(hook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
CreatePasswordRecoveryToken(rctx request.CTX, userID, email string) (*model.Token, *model.AppError)
CreatePost(c request.CTX, post *model.Post, channel *model.Channel, triggerWebhooks, setOnline bool) (savedPost *model.Post, err *model.AppError)
CreatePost(c request.CTX, post *model.Post, channel *model.Channel, flags model.CreatePostFlags) (savedPost *model.Post, err *model.AppError)
CreatePostAsUser(c request.CTX, post *model.Post, currentSessionId string, setOnline bool) (*model.Post, *model.AppError)
CreatePostMissingChannel(c request.CTX, post *model.Post, triggerWebhooks bool, setOnline bool) (*model.Post, *model.AppError)
CreateRemoteClusterInvite(remoteId, siteURL, token, password string) (string, *model.AppError)

View file

@ -77,7 +77,7 @@ func (a *App) SendAutoResponse(rctx request.CTX, channel *model.Channel, receive
UserId: receiver.Id,
}
if _, err := a.CreatePost(rctx, autoResponderPost, channel, false, false); err != nil {
if _, err := a.CreatePost(rctx, autoResponderPost, channel, model.CreatePostFlags{}); err != nil {
return false, err
}

View file

@ -103,7 +103,7 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
Message: NewTestId(),
UserId: th.BasicUser.Id},
th.BasicChannel,
false, true)
model.CreatePostFlags{SetOnline: true})
sent, err := th.App.SendAutoResponseIfNecessary(th.Context, channel, th.BasicUser, savedPost)
@ -133,7 +133,7 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
Message: NewTestId(),
UserId: th.BasicUser.Id},
th.BasicChannel,
false, true)
model.CreatePostFlags{SetOnline: true})
sent, err := th.App.SendAutoResponseIfNecessary(th.Context, channel, th.BasicUser, savedPost)
@ -150,7 +150,7 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
Message: NewTestId(),
UserId: th.BasicUser.Id},
th.BasicChannel,
false, true)
model.CreatePostFlags{SetOnline: true})
sent, err := th.App.SendAutoResponseIfNecessary(th.Context, th.BasicChannel, th.BasicUser, savedPost)
@ -190,7 +190,7 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
Message: NewTestId(),
UserId: botUser.Id},
th.BasicChannel,
false, true)
model.CreatePostFlags{SetOnline: true})
sent, err := th.App.SendAutoResponseIfNecessary(th.Context, channel, botUser, savedPost)
@ -228,7 +228,7 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
Type: model.PostTypeAutoResponder,
},
th.BasicChannel,
false, true)
model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
savedPost.CreateAt = model.GetMillisForTime(time.Now())
@ -259,7 +259,7 @@ func TestSendAutoResponseSuccess(t *testing.T) {
Message: "zz" + model.NewId() + "a",
UserId: th.BasicUser.Id},
th.BasicChannel,
false, true)
model.CreatePostFlags{SetOnline: true})
sent, err := th.App.SendAutoResponse(th.Context, th.BasicChannel, userUpdated1, savedPost)
@ -299,7 +299,7 @@ func TestSendAutoResponseSuccessOnThread(t *testing.T) {
Message: "zz" + model.NewId() + "a",
UserId: th.BasicUser.Id},
th.BasicChannel,
false, true)
model.CreatePostFlags{SetOnline: true})
savedPost, _ := th.App.CreatePost(th.Context, &model.Post{
ChannelId: th.BasicChannel.Id,
@ -308,7 +308,7 @@ func TestSendAutoResponseSuccessOnThread(t *testing.T) {
RootId: parentPost.Id,
},
th.BasicChannel,
false, true)
model.CreatePostFlags{SetOnline: true})
sent, err := th.App.SendAutoResponse(th.Context, th.BasicChannel, userUpdated1, savedPost)
@ -348,7 +348,7 @@ func TestSendAutoResponseFailure(t *testing.T) {
Message: "zz" + model.NewId() + "a",
UserId: th.BasicUser.Id},
th.BasicChannel,
false, true)
model.CreatePostFlags{SetOnline: true})
sent, err := th.App.SendAutoResponse(th.Context, th.BasicChannel, userUpdated1, savedPost)

View file

@ -561,7 +561,7 @@ func (a *App) notifySysadminsBotOwnerDeactivated(rctx request.CTX, userID string
Type: model.PostTypeSystemGeneric,
}
_, appErr = a.CreatePost(rctx, post, channel, false, true)
_, appErr = a.CreatePost(rctx, post, channel, model.CreatePostFlags{SetOnline: true})
if appErr != nil {
return appErr
}

View file

@ -758,7 +758,7 @@ func (a *App) postChannelPrivacyMessage(c request.CTX, user *model.User, channel
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("postChannelPrivacyMessage", "api.channel.post_channel_privacy_message.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -813,7 +813,7 @@ func (a *App) RestoreChannel(c request.CTX, channel *model.Channel, userID strin
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
c.Logger().Warn("Failed to post unarchive message", mlog.Err(err))
}
} else {
@ -834,7 +834,7 @@ func (a *App) RestoreChannel(c request.CTX, channel *model.Channel, userID strin
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
c.Logger().Error("Failed to post unarchive message", mlog.Err(err))
}
})
@ -1464,7 +1464,7 @@ func (a *App) DeleteChannel(c request.CTX, channel *model.Channel, userID string
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
c.Logger().Warn("Failed to post archive message", mlog.Err(err))
}
} else {
@ -1482,7 +1482,7 @@ func (a *App) DeleteChannel(c request.CTX, channel *model.Channel, userID string
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
c.Logger().Warn("Failed to post archive message", mlog.Err(err))
}
}
@ -1761,7 +1761,7 @@ func (a *App) PostUpdateChannelHeaderMessage(c request.CTX, userID string, chann
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("", "api.channel.post_update_channel_header_message_and_forget.post.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -1794,7 +1794,7 @@ func (a *App) PostUpdateChannelPurposeMessage(c request.CTX, userID string, chan
"new_purpose": newChannelPurpose,
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("", "app.channel.post_update_channel_purpose_message.post.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -1821,7 +1821,7 @@ func (a *App) PostUpdateChannelDisplayNameMessage(c request.CTX, userID string,
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("PostUpdateChannelDisplayNameMessage", "api.channel.post_update_channel_displayname_message_and_forget.create_post.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -2314,7 +2314,7 @@ func (a *App) postJoinChannelMessage(c request.CTX, user *model.User, channel *m
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("postJoinChannelMessage", "api.channel.post_user_add_remove_message_and_forget.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -2332,7 +2332,7 @@ func (a *App) postJoinTeamMessage(c request.CTX, user *model.User, channel *mode
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("postJoinTeamMessage", "api.channel.post_user_add_remove_message_and_forget.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -2431,7 +2431,7 @@ func (a *App) postLeaveChannelMessage(c request.CTX, user *model.User, channel *
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("postLeaveChannelMessage", "api.channel.post_user_add_remove_message_and_forget.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -2460,7 +2460,7 @@ func (a *App) PostAddToChannelMessage(c request.CTX, user *model.User, addedUser
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("postAddToChannelMessage", "api.channel.post_user_add_remove_message_and_forget.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -2482,7 +2482,7 @@ func (a *App) postAddToTeamMessage(c request.CTX, user *model.User, addedUser *m
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("postAddToTeamMessage", "api.channel.post_user_add_remove_message_and_forget.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -2514,7 +2514,7 @@ func (a *App) postRemoveFromChannelMessage(c request.CTX, removerUserId string,
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("postRemoveFromChannelMessage", "api.channel.post_user_add_remove_message_and_forget.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -3259,7 +3259,7 @@ func (a *App) postChannelMoveMessage(c request.CTX, user *model.User, channel *m
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("postChannelMoveMessage", "api.team.move_channel.post.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -3743,7 +3743,7 @@ func (a *App) postMessageForConvertGroupMessageToChannel(c request.CTX, channelI
return appErr
}
if _, appErr := a.CreatePost(c, post, channel, false, true); appErr != nil {
if _, appErr := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); appErr != nil {
c.Logger().Error("Failed to create post for notifying about GM converted to private channel", mlog.Err(appErr))
return model.NewAppError(

View file

@ -653,7 +653,7 @@ func TestLeaveDefaultChannel(t *testing.T) {
Message: "root post",
UserId: th.BasicUser.Id,
}
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
reply := &model.Post{
@ -662,7 +662,7 @@ func TestLeaveDefaultChannel(t *testing.T) {
UserId: th.BasicUser.Id,
RootId: rpost.Id,
}
_, err = th.App.CreatePost(th.Context, reply, th.BasicChannel, false, true)
_, err = th.App.CreatePost(th.Context, reply, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
threads, err := th.App.GetThreadsForUser(th.BasicUser.Id, townSquare.TeamId, model.GetUserThreadsOpts{})
@ -691,7 +691,7 @@ func TestLeaveChannel(t *testing.T) {
UserId: th.BasicUser.Id,
}
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
reply := &model.Post{
@ -700,7 +700,7 @@ func TestLeaveChannel(t *testing.T) {
UserId: th.BasicUser.Id,
RootId: rpost.Id,
}
_, err = th.App.CreatePost(th.Context, reply, th.BasicChannel, false, true)
_, err = th.App.CreatePost(th.Context, reply, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
return rpost
@ -1550,7 +1550,7 @@ func TestMarkChannelAsUnreadFromPost(t *testing.T) {
UserId: u2.Id,
ChannelId: c2.Id,
Message: "@" + u1.Username,
}, c2, false, true)
}, c2, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
th.CreatePost(c2)
@ -1559,7 +1559,7 @@ func TestMarkChannelAsUnreadFromPost(t *testing.T) {
ChannelId: c2.Id,
RootId: p4.Id,
Message: "@" + u1.Username,
}, c2, false, true)
}, c2, model.CreatePostFlags{SetOnline: true})
response, err := th.App.MarkChannelAsUnreadFromPost(th.Context, p4.Id, u1.Id, true)
assert.Nil(t, err)
@ -1581,7 +1581,7 @@ func TestMarkChannelAsUnreadFromPost(t *testing.T) {
th.CreatePost(dc)
th.CreatePost(dc)
_, err := th.App.CreatePost(th.Context, &model.Post{ChannelId: dc.Id, UserId: th.BasicUser.Id, Message: "testReply", RootId: dm1.Id}, dc, false, false)
_, err := th.App.CreatePost(th.Context, &model.Post{ChannelId: dc.Id, UserId: th.BasicUser.Id, Message: "testReply", RootId: dm1.Id}, dc, model.CreatePostFlags{})
assert.Nil(t, err)
response, err := th.App.MarkChannelAsUnreadFromPost(th.Context, dm1.Id, u2.Id, true)
@ -2297,7 +2297,7 @@ func TestViewChannelCollapsedThreadsTurnedOff(t *testing.T) {
Message: "root post @" + u1.Username,
UserId: u2.Id,
}
rpost1, appErr := th.App.CreatePost(th.Context, post1, c1, false, true)
rpost1, appErr := th.App.CreatePost(th.Context, post1, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
// mention the user in a reply post
@ -2307,7 +2307,7 @@ func TestViewChannelCollapsedThreadsTurnedOff(t *testing.T) {
UserId: u2.Id,
RootId: rpost1.Id,
}
_, appErr = th.App.CreatePost(th.Context, post2, c1, false, true)
_, appErr = th.App.CreatePost(th.Context, post2, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
// Check we have unread mention in the thread
@ -2373,19 +2373,19 @@ func TestMarkChannelAsUnreadFromPostCollapsedThreadsTurnedOff(t *testing.T) {
// user1: a root post
// user2: Another root mention @u1
user1Mention := " @" + th.BasicUser.Username
rootPost1, appErr := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "first root mention" + user1Mention}, th.BasicChannel, false, false)
rootPost1, appErr := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "first root mention" + user1Mention}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "hello"}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "hello"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
replyPost1, appErr := th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "mention" + user1Mention}, th.BasicChannel, false, false)
replyPost1, appErr := th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "mention" + user1Mention}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another reply"}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another reply"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another mention" + user1Mention}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost1.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another mention" + user1Mention}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "a root post"}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "a root post"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another root mention" + user1Mention}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "another root mention" + user1Mention}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
t.Run("Mark reply post as unread", func(t *testing.T) {
@ -2439,13 +2439,13 @@ func TestMarkUnreadCRTOffUpdatesThreads(t *testing.T) {
t.Run("Mentions counted correctly if post is edited", func(t *testing.T) {
user3 := th.CreateUser()
defer th.App.PermanentDeleteUser(th.Context, user3)
rootPost, appErr := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "root post"}, th.BasicChannel, false, false)
rootPost, appErr := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "root post"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
r1, appErr := th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "reply 1"}, th.BasicChannel, false, false)
r1, appErr := th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "reply 1"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "reply 2 @" + user3.Username}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: th.BasicUser.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "reply 2 @" + user3.Username}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "reply 3"}, th.BasicChannel, false, false)
_, appErr = th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "reply 3"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
editedPost := r1.Clone()
editedPost.Message += " edited"

View file

@ -129,7 +129,7 @@ func (a *App) elasticsearchChannelIndexCheck() {
UserId: systemBot.UserId,
ChannelId: channel.Id,
}
_, appErr = a.CreatePost(request.EmptyContext(a.Log()), post, channel, true, false)
_, appErr = a.CreatePost(request.EmptyContext(a.Log()), post, channel, model.CreatePostFlags{TriggerWebhooks: true})
if appErr != nil {
a.Log().Error("elasticsearchChannelIndexCheck: error occurred creating post", mlog.Err(appErr))
continue

View file

@ -446,14 +446,14 @@ func TestExportDMandGMPost(t *testing.T) {
Message: "aa" + model.NewId() + "a",
UserId: th1.BasicUser.Id,
}
th1.App.CreatePost(th1.Context, p1, dmChannel, false, true)
th1.App.CreatePost(th1.Context, p1, dmChannel, model.CreatePostFlags{SetOnline: true})
p2 := &model.Post{
ChannelId: dmChannel.Id,
Message: "bb" + model.NewId() + "a",
UserId: th1.BasicUser.Id,
}
th1.App.CreatePost(th1.Context, p2, dmChannel, false, true)
th1.App.CreatePost(th1.Context, p2, dmChannel, model.CreatePostFlags{SetOnline: true})
// GM posts
p3 := &model.Post{
@ -461,14 +461,14 @@ func TestExportDMandGMPost(t *testing.T) {
Message: "cc" + model.NewId() + "a",
UserId: th1.BasicUser.Id,
}
th1.App.CreatePost(th1.Context, p3, gmChannel, false, true)
th1.App.CreatePost(th1.Context, p3, gmChannel, model.CreatePostFlags{SetOnline: true})
p4 := &model.Post{
ChannelId: gmChannel.Id,
Message: "dd" + model.NewId() + "a",
UserId: th1.BasicUser.Id,
}
th1.App.CreatePost(th1.Context, p4, gmChannel, false, true)
th1.App.CreatePost(th1.Context, p4, gmChannel, model.CreatePostFlags{SetOnline: true})
posts, err := th1.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
require.NoError(t, err)
@ -531,7 +531,7 @@ func TestExportPostWithProps(t *testing.T) {
},
UserId: th1.BasicUser.Id,
}
th1.App.CreatePost(th1.Context, p1, dmChannel, false, true)
th1.App.CreatePost(th1.Context, p1, dmChannel, model.CreatePostFlags{SetOnline: true})
p2 := &model.Post{
ChannelId: gmChannel.Id,
@ -541,7 +541,7 @@ func TestExportPostWithProps(t *testing.T) {
},
UserId: th1.BasicUser.Id,
}
th1.App.CreatePost(th1.Context, p2, gmChannel, false, true)
th1.App.CreatePost(th1.Context, p2, gmChannel, model.CreatePostFlags{SetOnline: true})
posts, err := th1.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
require.NoError(t, err)
@ -819,7 +819,7 @@ func TestBuildPostReplies(t *testing.T) {
fileIDs = append(fileIDs, info.Id)
}
post, err := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: th.BasicChannel.Id, RootId: rootID, FileIds: fileIDs}, th.BasicChannel, false, true)
post, err := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: th.BasicChannel.Id, RootId: rootID, FileIds: fileIDs}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
return post

View file

@ -279,13 +279,13 @@ func TestMigrateFilenamesToFileInfos(t *testing.T) {
fpath := fmt.Sprintf("/teams/%v/channels/%v/users/%v/%v/test.png", th.BasicTeam.Id, th.BasicChannel.Id, th.BasicUser.Id, fileID)
_, err := th.App.WriteFile(file, fpath)
require.Nil(t, err)
rpost, err := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: th.BasicChannel.Id, Filenames: []string{fmt.Sprintf("/%v/%v/%v/test.png", th.BasicChannel.Id, th.BasicUser.Id, fileID)}}, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: th.BasicChannel.Id, Filenames: []string{fmt.Sprintf("/%v/%v/%v/test.png", th.BasicChannel.Id, th.BasicUser.Id, fileID)}}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
infos = th.App.MigrateFilenamesToFileInfos(th.Context, rpost)
assert.Equal(t, 1, len(infos))
rpost, err = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: th.BasicChannel.Id, Filenames: []string{fmt.Sprintf("/%v/%v/%v/../../test.png", th.BasicChannel.Id, th.BasicUser.Id, fileID)}}, th.BasicChannel, false, true)
rpost, err = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: th.BasicChannel.Id, Filenames: []string{fmt.Sprintf("/%v/%v/%v/../../test.png", th.BasicChannel.Id, th.BasicUser.Id, fileID)}}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
infos = th.App.MigrateFilenamesToFileInfos(th.Context, rpost)
@ -755,7 +755,7 @@ func TestPermanentDeleteFilesByPost(t *testing.T) {
FileIds: []string{info1.Id},
}
post, err = th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
post, err = th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
assert.Nil(t, err)
err = th.App.PermanentDeleteFilesByPost(th.Context, post.Id)
@ -779,7 +779,7 @@ func TestPermanentDeleteFilesByPost(t *testing.T) {
CreateAt: 0,
}
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
assert.Nil(t, err)
err = th.App.PermanentDeleteFilesByPost(th.Context, post.Id)

View file

@ -456,7 +456,7 @@ func (th *TestHelper) CreatePost(channel *model.Channel) *model.Post {
}
var err *model.AppError
if post, err = th.App.CreatePost(th.Context, post, channel, false, true); err != nil {
if post, err = th.App.CreatePost(th.Context, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
panic(err)
}
return post
@ -471,7 +471,7 @@ func (th *TestHelper) CreateMessagePost(channel *model.Channel, message string)
}
var err *model.AppError
if post, err = th.App.CreatePost(th.Context, post, channel, false, true); err != nil {
if post, err = th.App.CreatePost(th.Context, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
panic(err)
}
return post
@ -491,7 +491,7 @@ func (th *TestHelper) CreatePostReply(root *model.Post) *model.Post {
if err != nil {
panic(err)
}
if post, err = th.App.CreatePost(th.Context, post, ch, false, true); err != nil {
if post, err = th.App.CreatePost(th.Context, post, ch, model.CreatePostFlags{SetOnline: true}); err != nil {
panic(err)
}
return post

View file

@ -74,7 +74,7 @@ func TestSendNotifications(t *testing.T) {
Message: fmt.Sprintf("hello @%s group", *group.Name),
CreateAt: model.GetMillis() - 10000,
}
groupMentionPost, createPostErr := th.App.CreatePost(th.Context, groupMentionPost, th.BasicChannel, false, true)
groupMentionPost, createPostErr := th.App.CreatePost(th.Context, groupMentionPost, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, createPostErr)
mentions, err := th.App.SendNotifications(th.Context, groupMentionPost, th.BasicTeam, th.BasicChannel, th.BasicUser, nil, true)
@ -359,7 +359,7 @@ func TestSendNotifications_MentionsFollowers(t *testing.T) {
}
// Use CreatePost instead of SendNotifications here since we need that to set up some threads state
_, appErr := th.App.CreatePost(th.Context, post, th.BasicChannel, false, false)
_, appErr := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
received1 := <-messages1
@ -2824,7 +2824,7 @@ func TestReplyPostNotificationsWithCRT(t *testing.T) {
Message: "root post by user1",
UserId: u1.Id,
}
rpost, appErr := th.App.CreatePost(th.Context, rootPost, c1, false, true)
rpost, appErr := th.App.CreatePost(th.Context, rootPost, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
replyPost1 := &model.Post{
@ -2833,7 +2833,7 @@ func TestReplyPostNotificationsWithCRT(t *testing.T) {
UserId: u2.Id,
RootId: rpost.Id,
}
_, appErr = th.App.CreatePost(th.Context, replyPost1, c1, false, true)
_, appErr = th.App.CreatePost(th.Context, replyPost1, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
replyPost2 := &model.Post{
@ -2842,7 +2842,7 @@ func TestReplyPostNotificationsWithCRT(t *testing.T) {
UserId: u1.Id,
RootId: rpost.Id,
}
_, appErr = th.App.CreatePost(th.Context, replyPost2, c1, false, true)
_, appErr = th.App.CreatePost(th.Context, replyPost2, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
threadMembership, appErr := th.App.GetThreadMembershipForUser(u2.Id, rpost.Id)
@ -2922,7 +2922,7 @@ func TestChannelAutoFollowThreads(t *testing.T) {
Message: "root post by user3",
UserId: u3.Id,
}
rpost, appErr := th.App.CreatePost(th.Context, rootPost, c1, false, true)
rpost, appErr := th.App.CreatePost(th.Context, rootPost, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
replyPost1 := &model.Post{
@ -2931,7 +2931,7 @@ func TestChannelAutoFollowThreads(t *testing.T) {
UserId: u1.Id,
RootId: rpost.Id,
}
_, appErr = th.App.CreatePost(th.Context, replyPost1, c1, false, true)
_, appErr = th.App.CreatePost(th.Context, replyPost1, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
// user-2 starts auto-following thread
@ -2953,7 +2953,7 @@ func TestChannelAutoFollowThreads(t *testing.T) {
UserId: u1.Id,
RootId: rpost.Id,
}
_, appErr = th.App.CreatePost(th.Context, replyPost2, c1, false, true)
_, appErr = th.App.CreatePost(th.Context, replyPost2, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
// Do NOT start auto-following thread, once "un-followed"
@ -2984,7 +2984,7 @@ func TestRemoveNotifications(t *testing.T) {
Message: "root post by user1",
UserId: u1.Id,
}
rootPost, appErr := th.App.CreatePost(th.Context, rootPost, c1, false, true)
rootPost, appErr := th.App.CreatePost(th.Context, rootPost, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
replyPost1 := &model.Post{
@ -2993,7 +2993,7 @@ func TestRemoveNotifications(t *testing.T) {
UserId: u2.Id,
RootId: rootPost.Id,
}
_, appErr = th.App.CreatePost(th.Context, replyPost1, c1, false, true)
_, appErr = th.App.CreatePost(th.Context, replyPost1, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
replyPost2 := &model.Post{
@ -3002,7 +3002,7 @@ func TestRemoveNotifications(t *testing.T) {
UserId: u1.Id,
RootId: rootPost.Id,
}
replyPost2, appErr = th.App.CreatePost(th.Context, replyPost2, c1, false, true)
replyPost2, appErr = th.App.CreatePost(th.Context, replyPost2, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
_, appErr = th.App.DeletePost(th.Context, replyPost2.Id, u1.Id)
@ -3041,7 +3041,7 @@ func TestRemoveNotifications(t *testing.T) {
Message: "root post by user1",
UserId: u1.Id,
}
rootPost, appErr = th.App.CreatePost(th.Context, rootPost, c1, false, true)
rootPost, appErr = th.App.CreatePost(th.Context, rootPost, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
replyPost1 := &model.Post{
@ -3050,7 +3050,7 @@ func TestRemoveNotifications(t *testing.T) {
UserId: u2.Id,
RootId: rootPost.Id,
}
_, appErr = th.App.CreatePost(th.Context, replyPost1, c1, false, true)
_, appErr = th.App.CreatePost(th.Context, replyPost1, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
replyPost2 := &model.Post{
@ -3059,7 +3059,7 @@ func TestRemoveNotifications(t *testing.T) {
UserId: u1.Id,
RootId: rootPost.Id,
}
replyPost2, appErr = th.App.CreatePost(th.Context, replyPost2, c1, false, true)
replyPost2, appErr = th.App.CreatePost(th.Context, replyPost2, c1, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
_, appErr = th.App.DeletePost(th.Context, replyPost2.Id, u1.Id)

View file

@ -154,7 +154,7 @@ func (a *App) pluginInstallAdminNotifyPost(c request.CTX, userBasedData map[stri
props["requested_plugins_by_user_ids"] = userBasedData
post.SetProps(props)
_, appErr = a.CreatePost(c, post, channel, false, true)
_, appErr = a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true})
if appErr != nil {
c.Logger().Warn("Error creating post", mlog.Err(appErr))
}
@ -193,7 +193,7 @@ func (a *App) upgradePlanAdminNotifyPost(c request.CTX, workspaceName string, us
props["trial"] = trial
post.SetProps(props)
_, appErr = a.CreatePost(c, post, channel, false, true)
_, appErr = a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true})
if appErr != nil {
c.Logger().Warn("Error creating post", mlog.Err(appErr))

View file

@ -2500,7 +2500,7 @@ func (a *OpenTracingAppLayer) CreatePasswordRecoveryToken(rctx request.CTX, user
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) CreatePost(c request.CTX, post *model.Post, channel *model.Channel, triggerWebhooks bool, setOnline bool) (savedPost *model.Post, err *model.AppError) {
func (a *OpenTracingAppLayer) CreatePost(c request.CTX, post *model.Post, channel *model.Channel, flags model.CreatePostFlags) (savedPost *model.Post, err *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CreatePost")
@ -2512,7 +2512,7 @@ func (a *OpenTracingAppLayer) CreatePost(c request.CTX, post *model.Post, channe
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.CreatePost(c, post, channel, triggerWebhooks, setOnline)
resultVar0, resultVar1 := a.app.CreatePost(c, post, channel, flags)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))

View file

@ -100,7 +100,7 @@ func TestHookMessageWillBePosted(t *testing.T) {
Message: "message_",
CreateAt: model.GetMillis() - 10000,
}
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
if assert.NotNil(t, err) {
assert.Equal(t, "Post rejected by plugin. rejected", err.Message)
}
@ -141,7 +141,7 @@ func TestHookMessageWillBePosted(t *testing.T) {
Message: "message_",
CreateAt: model.GetMillis() - 10000,
}
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
if assert.NotNil(t, err) {
assert.Equal(t, "Post rejected by plugin. rejected", err.Message)
}
@ -181,7 +181,7 @@ func TestHookMessageWillBePosted(t *testing.T) {
Message: "message",
CreateAt: model.GetMillis() - 10000,
}
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.Equal(t, "message", post.Message)
@ -225,7 +225,7 @@ func TestHookMessageWillBePosted(t *testing.T) {
Message: "message",
CreateAt: model.GetMillis() - 10000,
}
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.Equal(t, "message_fromplugin", post.Message)
@ -291,7 +291,7 @@ func TestHookMessageWillBePosted(t *testing.T) {
Message: "message",
CreateAt: model.GetMillis() - 10000,
}
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.Equal(t, "prefix_message_suffix", post.Message)
})
@ -335,7 +335,7 @@ func TestHookMessageHasBeenPosted(t *testing.T) {
Message: "message",
CreateAt: model.GetMillis() - 10000,
}
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
}
@ -374,7 +374,7 @@ func TestHookMessageWillBeUpdated(t *testing.T) {
Message: "message_",
CreateAt: model.GetMillis() - 10000,
}
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.Equal(t, "message_", post.Message)
post.Message = post.Message + "edited_"
@ -422,7 +422,7 @@ func TestHookMessageHasBeenUpdated(t *testing.T) {
Message: "message_",
CreateAt: model.GetMillis() - 10000,
}
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
post, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.Equal(t, "message_", post.Message)
post.Message = post.Message + "edited"
@ -468,7 +468,7 @@ func TestHookMessageHasBeenDeleted(t *testing.T) {
Message: "message",
CreateAt: model.GetMillis() - 10000,
}
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.DeletePost(th.Context, post.Id, th.BasicUser.Id)
require.Nil(t, err)
@ -1035,7 +1035,7 @@ func TestHookContext(t *testing.T) {
Message: "not this",
CreateAt: model.GetMillis() - 10000,
}
_, err := th.App.CreatePost(ctx, post, th.BasicChannel, false, true)
_, err := th.App.CreatePost(ctx, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
}
@ -1603,7 +1603,7 @@ func TestHookMessagesWillBeConsumed(t *testing.T) {
Message: "message",
CreateAt: model.GetMillis() - 10000,
}
_, err := th.App.CreatePost(th.Context, newPost, th.BasicChannel, false, true)
_, err := th.App.CreatePost(th.Context, newPost, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
post, err := th.App.GetSinglePost(th.Context, newPost.Id, true)
@ -1626,7 +1626,7 @@ func TestHookMessagesWillBeConsumed(t *testing.T) {
Message: "message",
CreateAt: model.GetMillis() - 10000,
}
_, err := th.App.CreatePost(th.Context, newPost, th.BasicChannel, false, true)
_, err := th.App.CreatePost(th.Context, newPost, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
post, err := th.App.GetSinglePost(th.Context, newPost.Id, true)

View file

@ -754,7 +754,7 @@ func TestPluginPanicLogs(t *testing.T) {
Message: "message_",
CreateAt: model.GetMillis() - 10000,
}
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
assert.Nil(t, err)
th.TestLogger.Flush()

View file

@ -51,7 +51,7 @@ func (a *App) CreatePostAsUser(c request.CTX, post *model.Post, currentSessionId
return nil, err
}
rp, err := a.CreatePost(c, post, channel, true, setOnline)
rp, err := a.CreatePost(c, post, channel, model.CreatePostFlags{TriggerWebhooks: true, SetOnline: 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" {
@ -95,7 +95,7 @@ func (a *App) CreatePostMissingChannel(c request.CTX, post *model.Post, triggerW
}
}
return a.CreatePost(c, post, channel, triggerWebhooks, setOnline)
return a.CreatePost(c, post, channel, model.CreatePostFlags{TriggerWebhooks: triggerWebhooks, SetOnline: setOnline})
}
// deduplicateCreatePost attempts to make posting idempotent within a caching window.
@ -140,7 +140,7 @@ func (a *App) deduplicateCreatePost(rctx request.CTX, post *model.Post) (foundPo
return actualPost, nil
}
func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel, triggerWebhooks, setOnline bool) (savedPost *model.Post, err *model.AppError) {
func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel, flags model.CreatePostFlags) (savedPost *model.Post, err *model.AppError) {
if channel.IsShared() && (channel.Type == model.ChannelTypeDirect || channel.Type == model.ChannelTypeGroup) {
return nil, model.NewAppError("CreatePost", "app.post.create_post.shared_dm_or_gm.app_error", nil, "", http.StatusBadRequest)
}
@ -384,7 +384,7 @@ func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel
}
}
if err := a.handlePostEvents(c, rpost, user, channel, triggerWebhooks, parentPostList, setOnline); err != nil {
if err := a.handlePostEvents(c, rpost, user, channel, flags.TriggerWebhooks, parentPostList, flags.SetOnline); err != nil {
c.Logger().Warn("Failed to handle post events", mlog.Err(err))
}
@ -2223,7 +2223,7 @@ func (a *App) CheckPostReminders(rctx request.CTX) {
},
}
if _, err := a.CreatePost(request.EmptyContext(a.Log()), dm, ch, false, true); err != nil {
if _, err := a.CreatePost(request.EmptyContext(a.Log()), dm, ch, model.CreatePostFlags{SetOnline: true}); err != nil {
rctx.Logger().Error("Failed to post reminder message", mlog.Err(err))
}
}
@ -2463,14 +2463,14 @@ func (a *App) CopyWranglerPostlist(c request.CTX, wpl *model.WranglerPostList, t
newPost.ChannelId = targetChannel.Id
if i == 0 {
newPost, appErr = a.CreatePost(c, newPost, targetChannel, false, false)
newPost, appErr = a.CreatePost(c, newPost, targetChannel, model.CreatePostFlags{})
if appErr != nil {
return nil, appErr
}
newRootPost = newPost.Clone()
} else {
newPost.RootId = newRootPost.Id
newPost, appErr = a.CreatePost(c, newPost, targetChannel, false, false)
newPost, appErr = a.CreatePost(c, newPost, targetChannel, model.CreatePostFlags{})
if appErr != nil {
return nil, appErr
}
@ -2552,7 +2552,7 @@ func (a *App) MoveThread(c request.CTX, postID string, sourceChannelID, channelI
ChannelId: channelID,
Message: T("app.post.move_thread.from_another_channel"),
Props: ephemeralPostProps,
}, targetChannel, false, false)
}, targetChannel, model.CreatePostFlags{})
if appErr != nil {
return appErr
}
@ -2599,7 +2599,7 @@ func (a *App) MoveThread(c request.CTX, postID string, sourceChannelID, channelI
ChannelId: originalChannel.Id,
Message: msg,
Props: ephemeralPostProps,
}, originalChannel, false, false)
}, originalChannel, model.CreatePostFlags{})
if appErr != nil {
return appErr
}

View file

@ -190,7 +190,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
FileIds: []string{fileInfo.Id},
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
fileInfo.PostId = post.Id
@ -225,7 +225,7 @@ func TestPreparePostForClient(t *testing.T) {
},
},
},
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
th.AddReactionToPost(post, th.BasicUser, "smile")
@ -269,7 +269,7 @@ func TestPreparePostForClient(t *testing.T) {
},
},
},
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
th.AddReactionToPost(post, th.BasicUser, emoji1.Name)
@ -303,7 +303,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: "Test",
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
@ -360,7 +360,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: fmt.Sprintf("This is ![our logo](%s/test-image2.png) and ![our icon](%s/test-image1.png)", server.URL, server.URL),
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
clientPost := th.App.PreparePostForClient(th.Context, post, false, false, false)
@ -389,7 +389,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: "some post",
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// this value expected to be a string
@ -423,7 +423,7 @@ func TestPreparePostForClient(t *testing.T) {
ChannelId: th.BasicChannel.Id,
Message: `This is our logo: ` + server.URL + `/test-image2.png
And this is our icon: ` + server.URL + `/test-image1.png`,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
post.Metadata.Embeds = nil
clientPost := th.App.PreparePostForClientWithEmbedsAndImages(th.Context, post, false, false, false)
@ -458,7 +458,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: `This is our web page: ` + server.URL,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
clientPost := th.App.PreparePostForClient(th.Context, post, false, false, false)
@ -529,7 +529,7 @@ func TestPreparePostForClient(t *testing.T) {
}
prepost.AddProp(UnsafeLinksPostProp, "true")
post, err := th.App.CreatePost(th.Context, prepost, th.BasicChannel, false, true)
post, err := th.App.CreatePost(th.Context, prepost, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
clientPost := th.App.PreparePostForClient(th.Context, post, false, false, false)
@ -545,7 +545,7 @@ func TestPreparePostForClient(t *testing.T) {
Message: `Bla bla bla: ` + fmt.Sprintf(tc.link, server.URL),
}
post, err := th.App.CreatePost(th.Context, prepost, th.BasicChannel, false, true)
post, err := th.App.CreatePost(th.Context, prepost, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
clientPost := th.App.PreparePostForClient(th.Context, post, false, false, false)
@ -571,7 +571,7 @@ func TestPreparePostForClient(t *testing.T) {
},
},
},
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
post.Metadata.Embeds = nil
clientPost := th.App.PreparePostForClientWithEmbedsAndImages(th.Context, post, false, false, false)
@ -607,7 +607,7 @@ func TestPreparePostForClient(t *testing.T) {
FileIds: []string{fileInfo.Id},
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
post.Metadata.Embeds = nil
@ -641,7 +641,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: "hello world",
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
referencedPost.Metadata.Embeds = nil
@ -651,7 +651,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: link,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
previewPost.Metadata.Embeds = nil
clientPost := th.App.PreparePostForClientWithEmbedsAndImages(th.Context, previewPost, false, false, false)
@ -699,7 +699,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: testCase.Channel.Id,
Message: "hello world",
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
referencedPost.Metadata.Embeds = nil
@ -709,7 +709,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: link,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
previewPost.Metadata.Embeds = nil
@ -737,7 +737,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: `This is our logo: ` + server.URL + `/test-image2.png`,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
referencedPost.Metadata.Embeds = nil
@ -747,7 +747,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: link,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
previewPost.Metadata.Embeds = nil
@ -774,7 +774,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: `This is our logo: ` + server.URL + `/test-image2.png`,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
nestedPermalinkPost.Metadata.Embeds = nil
@ -784,7 +784,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: nestedLink,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
referencedPost.Metadata.Embeds = nil
@ -794,7 +794,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: link,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
previewPost.Metadata.Embeds = nil
@ -821,7 +821,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: "hello world",
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
link := fmt.Sprintf("%s/%s/pl/%s", *th.App.Config().ServiceSettings.SiteURL, th.BasicTeam.Name, referencedPost.Id)
@ -830,7 +830,7 @@ func TestPreparePostForClient(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: link,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
clientPost := th.App.PreparePostForClient(th.Context, previewPost, false, false, false)
@ -944,7 +944,7 @@ func testProxyOpenGraphImage(t *testing.T, th *TestHelper, shouldProxy bool) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: `This is our web page: ` + server.URL,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
post.Metadata.Embeds = nil
@ -2972,7 +2972,7 @@ func TestSanitizePostMetaDataForAudit(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: "hello world",
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
referencedPost.Metadata.Embeds = nil
@ -2982,7 +2982,7 @@ func TestSanitizePostMetaDataForAudit(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: link,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
previewPost.Metadata.Embeds = nil
clientPost := th.App.PreparePostForClientWithEmbedsAndImages(th.Context, previewPost, false, false, false)

View file

@ -213,7 +213,7 @@ func TestSendPersistentNotifications(t *testing.T) {
},
},
}
_, appErr := th.App.CreatePost(th.Context, p1, th.BasicChannel, false, false)
_, appErr := th.App.CreatePost(th.Context, p1, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
err := th.App.SendPersistentNotifications()

View file

@ -805,7 +805,7 @@ func TestDeletePostWithFileAttachments(t *testing.T) {
FileIds: []string{info1.Id},
}
post, err = th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
post, err = th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
assert.Nil(t, err)
// Delete the post.
@ -857,7 +857,7 @@ func TestCreatePost(t *testing.T) {
UserId: th.BasicUser.Id,
}
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.Equal(t, "![image]("+proxiedImageURL+")", rpost.Message)
})
@ -873,7 +873,7 @@ func TestCreatePost(t *testing.T) {
Message: "This post does not have mentions",
UserId: th.BasicUser.Id,
}
rpost, err := th.App.CreatePost(th.Context, postWithNoMention, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, postWithNoMention, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.Equal(t, rpost.GetProps(), model.StringInterface{})
@ -882,7 +882,7 @@ func TestCreatePost(t *testing.T) {
Message: "This post has @here mention @all",
UserId: th.BasicUser.Id,
}
rpost, err = th.App.CreatePost(th.Context, postWithMention, th.BasicChannel, false, true)
rpost, err = th.App.CreatePost(th.Context, postWithMention, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.Equal(t, rpost.GetProps(), model.StringInterface{})
})
@ -896,7 +896,7 @@ func TestCreatePost(t *testing.T) {
Message: "This post does not have mentions",
UserId: th.BasicUser.Id,
}
rpost, err := th.App.CreatePost(th.Context, postWithNoMention, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, postWithNoMention, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.Equal(t, rpost.GetProps(), model.StringInterface{})
@ -905,7 +905,7 @@ func TestCreatePost(t *testing.T) {
Message: "This post has @here mention @all",
UserId: th.BasicUser.Id,
}
rpost, err = th.App.CreatePost(th.Context, postWithMention, th.BasicChannel, false, true)
rpost, err = th.App.CreatePost(th.Context, postWithMention, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.Equal(t, rpost.GetProp(model.PostPropsMentionHighlightDisabled), true)
@ -931,7 +931,7 @@ func TestCreatePost(t *testing.T) {
th.Context.Session().UserId = th.BasicUser.Id
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, false, false)
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, err)
permalink := fmt.Sprintf("%s/%s/pl/%s", *th.App.Config().ServiceSettings.SiteURL, th.BasicTeam.Name, referencedPost.Id)
@ -943,7 +943,7 @@ func TestCreatePost(t *testing.T) {
UserId: th.BasicUser.Id,
}
previewPost, err = th.App.CreatePost(th.Context, previewPost, channelForPreview, false, false)
previewPost, err = th.App.CreatePost(th.Context, previewPost, channelForPreview, model.CreatePostFlags{})
require.Nil(t, err)
assert.Equal(t, previewPost.GetProps(), model.StringInterface{"previewed_post": referencedPost.Id})
@ -960,7 +960,7 @@ func TestCreatePost(t *testing.T) {
Message: "hello world",
UserId: th.BasicUser.Id,
}
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, false, false)
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, err)
th.App.UpdateConfig(func(cfg *model.Config) {
@ -976,7 +976,7 @@ func TestCreatePost(t *testing.T) {
UserId: th.BasicUser.Id,
}
previewPost, err = th.App.CreatePost(th.Context, previewPost, channelForPreview, false, false)
previewPost, err = th.App.CreatePost(th.Context, previewPost, channelForPreview, model.CreatePostFlags{})
require.Nil(t, err)
sqlStore := th.GetSqlStore()
@ -1032,7 +1032,7 @@ func TestCreatePost(t *testing.T) {
Message: "hello world",
UserId: testCase.Author,
}
referencedPost, err = th.App.CreatePost(th.Context, referencedPost, testCase.Channel, false, false)
referencedPost, err = th.App.CreatePost(th.Context, referencedPost, testCase.Channel, model.CreatePostFlags{})
require.Nil(t, err)
permalink := fmt.Sprintf("%s/%s/pl/%s", *th.App.Config().ServiceSettings.SiteURL, th.BasicTeam.Name, referencedPost.Id)
@ -1042,7 +1042,7 @@ func TestCreatePost(t *testing.T) {
UserId: th.BasicUser.Id,
}
previewPost, err = th.App.CreatePost(th.Context, previewPost, th.BasicChannel, false, false)
previewPost, err = th.App.CreatePost(th.Context, previewPost, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, err)
require.Len(t, previewPost.Metadata.Embeds, testCase.Length)
@ -1084,7 +1084,7 @@ func TestCreatePost(t *testing.T) {
Message: "hello world",
UserId: user1.Id,
}
createdPost, err := th.App.CreatePost(th.Context, newPost, dm, false, false)
createdPost, err := th.App.CreatePost(th.Context, newPost, dm, model.CreatePostFlags{})
require.NotNil(t, err)
require.Nil(t, createdPost)
})
@ -1124,7 +1124,7 @@ func TestCreatePost(t *testing.T) {
Message: "hello world",
UserId: user1.Id,
}
createdPost, err := th.App.CreatePost(th.Context, newPost, gm, false, false)
createdPost, err := th.App.CreatePost(th.Context, newPost, gm, model.CreatePostFlags{})
require.NotNil(t, err)
require.Nil(t, createdPost)
})
@ -1146,7 +1146,7 @@ func TestCreatePost(t *testing.T) {
Message: "hello world",
UserId: th.BasicUser.Id,
}
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, false, false)
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, err)
th.App.UpdateConfig(func(cfg *model.Config) {
@ -1162,7 +1162,7 @@ func TestCreatePost(t *testing.T) {
UserId: th.BasicUser.Id,
}
previewPost, err = th.App.CreatePost(th.Context, previewPost, channelForPreview, false, false)
previewPost, err = th.App.CreatePost(th.Context, previewPost, channelForPreview, model.CreatePostFlags{})
require.Nil(t, err)
n := 1000
@ -1204,7 +1204,7 @@ func TestPatchPost(t *testing.T) {
UserId: th.BasicUser.Id,
}
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.NotEqual(t, "![image]("+proxiedImageURL+")", rpost.Message)
@ -1229,7 +1229,7 @@ func TestPatchPost(t *testing.T) {
UserId: th.BasicUser.Id,
}
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
t.Run("Does not set prop when user has USE_CHANNEL_MENTIONS", func(t *testing.T) {
@ -1474,7 +1474,7 @@ func TestUpdateEphemeralPost(t *testing.T) {
th.Context.Session().UserId = th.BasicUser.Id
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, false, false)
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, err)
permalink := fmt.Sprintf("%s/%s/pl/%s", *th.App.Config().ServiceSettings.SiteURL, th.BasicTeam.Name, referencedPost.Id)
@ -1510,7 +1510,7 @@ func TestUpdateEphemeralPost(t *testing.T) {
th.Context.Session().UserId = th.BasicUser.Id
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, false, false)
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, err)
permalink := fmt.Sprintf("%s/%s/pl/%s", *th.App.Config().ServiceSettings.SiteURL, th.BasicTeam.Name, referencedPost.Id)
@ -1550,7 +1550,7 @@ func TestUpdatePost(t *testing.T) {
UserId: th.BasicUser.Id,
}
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
assert.NotEqual(t, "![image]("+proxiedImageURL+")", rpost.Message)
@ -1579,7 +1579,7 @@ func TestUpdatePost(t *testing.T) {
th.Context.Session().UserId = th.BasicUser.Id
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, false, false)
referencedPost, err := th.App.CreatePost(th.Context, referencedPost, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, err)
permalink := fmt.Sprintf("%s/%s/pl/%s", *th.App.Config().ServiceSettings.SiteURL, th.BasicTeam.Name, referencedPost.Id)
@ -1591,7 +1591,7 @@ func TestUpdatePost(t *testing.T) {
UserId: th.BasicUser.Id,
}
testPost, err = th.App.CreatePost(th.Context, testPost, channelForTestPost, false, false)
testPost, err = th.App.CreatePost(th.Context, testPost, channelForTestPost, model.CreatePostFlags{})
require.Nil(t, err)
assert.Equal(t, model.StringInterface{}, testPost.GetProps())
@ -1645,14 +1645,14 @@ func TestUpdatePost(t *testing.T) {
Message: "hello world",
UserId: testCase.Author,
}
_, err = th.App.CreatePost(th.Context, referencedPost, testCase.Channel, false, false)
_, err = th.App.CreatePost(th.Context, referencedPost, testCase.Channel, model.CreatePostFlags{})
require.Nil(t, err)
previewPost := &model.Post{
ChannelId: th.BasicChannel.Id,
UserId: th.BasicUser.Id,
}
previewPost, err = th.App.CreatePost(th.Context, previewPost, th.BasicChannel, false, false)
previewPost, err = th.App.CreatePost(th.Context, previewPost, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, err)
permalink := fmt.Sprintf("%s/%s/pl/%s", *th.App.Config().ServiceSettings.SiteURL, th.BasicTeam.Name, referencedPost.Id)
@ -1679,7 +1679,7 @@ func TestSearchPostsForUser(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: searchTerm,
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
@ -1905,19 +1905,19 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test2",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test3",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
count, _, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
@ -1942,19 +1942,19 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test2",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "apple",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// post1 and post3 should mention the user
@ -1981,19 +1981,19 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "@channel",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "@all",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// post2 and post3 should mention the user
@ -2020,19 +2020,19 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "@channel",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "@all",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
count, _, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
@ -2062,19 +2062,19 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "@channel",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "@all",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
count, _, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
@ -2099,34 +2099,34 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user2.Id,
ChannelId: channel.Id,
Message: "test",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
RootId: post1.Id,
Message: "test2",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
post3, err := th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test3",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user2.Id,
ChannelId: channel.Id,
RootId: post3.Id,
Message: "test4",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
RootId: post3.Id,
Message: "test5",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// post2 should mention the user
@ -2153,34 +2153,34 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user2.Id,
ChannelId: channel.Id,
Message: "test",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
RootId: post1.Id,
Message: "test2",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
post3, err := th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test3",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user2.Id,
ChannelId: channel.Id,
RootId: post3.Id,
Message: "test4",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
RootId: post3.Id,
Message: "test5",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// post2 and post5 should mention the user
@ -2209,7 +2209,7 @@ func TestCountMentionsFromPost(t *testing.T) {
Props: map[string]any{
model.PostPropsAddedUserId: model.NewId(),
},
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
@ -2219,7 +2219,7 @@ func TestCountMentionsFromPost(t *testing.T) {
Props: map[string]any{
model.PostPropsAddedUserId: user2.Id,
},
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
@ -2229,7 +2229,7 @@ func TestCountMentionsFromPost(t *testing.T) {
Props: map[string]any{
model.PostPropsAddedUserId: user2.Id,
},
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// should be mentioned by post2 and post3
@ -2254,14 +2254,14 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test2",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
count, _, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
@ -2290,21 +2290,21 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test2",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user3.Id,
ChannelId: channel.Id,
Message: "test3",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
count, _, _, err := th.App.countMentionsFromPost(th.Context, user2, post1)
@ -2332,19 +2332,19 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
post2, err := th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test2",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// post1 and post3 should mention the user, but we only count post3
@ -2369,13 +2369,13 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user2.Id,
ChannelId: channel.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// post2 should mention the user
@ -2402,27 +2402,27 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test1",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user2.Id,
ChannelId: channel.Id,
RootId: post1.Id,
Message: "test2",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
post3, err := th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test3",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
RootId: post1.Id,
Message: "test4",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// post4 should mention the user
@ -2451,14 +2451,14 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test1",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user2.Id,
ChannelId: channel.Id,
RootId: post1.Id,
Message: "test2",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
time.Sleep(time.Millisecond * 2)
@ -2467,14 +2467,14 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test3",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
RootId: post1.Id,
Message: "test4",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// Make posts created before post3 inaccessible
@ -2507,13 +2507,13 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test1",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user2.Id,
ChannelId: channel.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user2.Id,
@ -2522,7 +2522,7 @@ func TestCountMentionsFromPost(t *testing.T) {
Props: map[string]any{
"from_webhook": "true",
},
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// post3 should mention the user
@ -2549,7 +2549,7 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
for i := 0; i < numPosts-1; i++ {
@ -2557,7 +2557,7 @@ func TestCountMentionsFromPost(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
}
@ -2594,14 +2594,14 @@ func TestCountMentionsFromPost(t *testing.T) {
Priority: model.NewPointer(model.PostPriorityUrgent),
},
},
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
@ -2613,7 +2613,7 @@ func TestCountMentionsFromPost(t *testing.T) {
Priority: model.NewPointer(model.PostPriorityUrgent),
},
},
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// all posts mention the user but only post1, post3 are urgent
@ -2639,7 +2639,7 @@ func TestFillInPostProps(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test123123 @group1 @group2 blah blah blah",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
err = th.App.FillInPostProps(th.Context, post1, channel)
@ -2671,7 +2671,7 @@ func TestFillInPostProps(t *testing.T) {
UserId: guest.Id,
ChannelId: channel.Id,
Message: "test123123 @group1 @group2 blah blah blah",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
err = th.App.FillInPostProps(th.Context, post1, channel)
@ -2704,7 +2704,7 @@ func TestFillInPostProps(t *testing.T) {
UserId: guest.Id,
ChannelId: channel.Id,
Message: "test123123 @group1 @group2 blah blah blah",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
err = th.App.FillInPostProps(th.Context, post1, channel)
@ -2733,7 +2733,7 @@ func TestThreadMembership(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "root post",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
@ -2741,7 +2741,7 @@ func TestThreadMembership(t *testing.T) {
ChannelId: channel.Id,
RootId: postRoot.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// first user should now be part of the thread since they replied to a post
@ -2757,7 +2757,7 @@ func TestThreadMembership(t *testing.T) {
UserId: user2.Id,
ChannelId: channel.Id,
Message: "second post",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
@ -2765,7 +2765,7 @@ func TestThreadMembership(t *testing.T) {
ChannelId: channel.Id,
RootId: post2.Id,
Message: fmt.Sprintf("@%s", user1.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// first user should now be part of two threads
@ -2798,9 +2798,9 @@ func TestFollowThreadSkipsParticipants(t *testing.T) {
appErr = th.App.JoinChannel(th.Context, channel, sysadmin.Id)
require.Nil(t, appErr)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + sysadmin.Username}, channel, false, false)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + sysadmin.Username}, channel, model.CreatePostFlags{})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "Hola"}, channel, false, false)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "Hola"}, channel, model.CreatePostFlags{})
require.Nil(t, err)
threadMembership, err := th.App.GetThreadMembershipForUser(user.Id, p1.Id)
@ -2809,7 +2809,7 @@ func TestFollowThreadSkipsParticipants(t *testing.T) {
require.Nil(t, err)
require.Len(t, thread.Participants, 1) // length should be 1, the original poster, since sysadmin was just mentioned but didn't post
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: sysadmin.Id, ChannelId: channel.Id, Message: "sysadmin reply"}, channel, false, false)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: sysadmin.Id, ChannelId: channel.Id, Message: "sysadmin reply"}, channel, model.CreatePostFlags{})
require.Nil(t, err)
threadMembership, err = th.App.GetThreadMembershipForUser(user.Id, p1.Id)
@ -2859,12 +2859,12 @@ func TestAutofollowBasedOnRootPost(t *testing.T) {
require.Nil(t, appErr)
appErr = th.App.JoinChannel(th.Context, channel, user2.Id)
require.Nil(t, appErr)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + user2.Username}, channel, false, false)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + user2.Username}, channel, model.CreatePostFlags{})
require.Nil(t, err)
m, e := th.App.GetThreadMembershipsForUser(user2.Id, th.BasicTeam.Id)
require.NoError(t, e)
require.Len(t, m, 0)
_, err2 := th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "Hola"}, channel, false, false)
_, err2 := th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "Hola"}, channel, model.CreatePostFlags{})
require.Nil(t, err2)
m, e = th.App.GetThreadMembershipsForUser(user2.Id, th.BasicTeam.Id)
require.NoError(t, e)
@ -2887,9 +2887,9 @@ func TestViewChannelShouldNotUpdateThreads(t *testing.T) {
require.Nil(t, appErr)
appErr = th.App.JoinChannel(th.Context, channel, user2.Id)
require.Nil(t, appErr)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + user2.Username}, channel, false, false)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + user2.Username}, channel, model.CreatePostFlags{})
require.Nil(t, err)
_, err2 := th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "Hola"}, channel, false, false)
_, err2 := th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "Hola"}, channel, model.CreatePostFlags{})
require.Nil(t, err2)
m, e := th.App.GetThreadMembershipsForUser(user2.Id, th.BasicTeam.Id)
require.NoError(t, e)
@ -2924,7 +2924,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "root post",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
@ -2932,7 +2932,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
ChannelId: channel.Id,
RootId: postRoot.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
thread, nErr := th.App.Srv().Store().Thread().Get(postRoot.Id)
require.NoError(t, nErr)
@ -2963,7 +2963,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "root post",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// we introduce a race to trigger an unexpected error from the db side.
@ -2980,7 +2980,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
ChannelId: channel.Id,
RootId: postRoot.Id,
Message: fmt.Sprintf("@%s", user2.Username),
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
})
wg.Wait()
@ -3008,7 +3008,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
UserId: user1.Id,
ChannelId: channel.Id,
Message: "root post",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{
@ -3016,7 +3016,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
ChannelId: channel.Id,
RootId: postRoot.Id,
Message: "reply",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
thread, nErr := th.App.Srv().Store().Thread().Get(postRoot.Id)
require.NoError(t, nErr)
@ -3085,7 +3085,7 @@ func TestReplyToPostWithLag(t *testing.T) {
UserId: th.BasicUser.Id,
ChannelId: th.BasicChannel.Id,
Message: "root post",
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
reply, appErr := th.App.CreatePost(th.Context, &model.Post{
@ -3093,7 +3093,7 @@ func TestReplyToPostWithLag(t *testing.T) {
ChannelId: th.BasicChannel.Id,
RootId: root.Id,
Message: fmt.Sprintf("@%s", th.BasicUser2.Username),
}, th.BasicChannel, false, true)
}, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, appErr)
require.NotNil(t, reply)
})
@ -3117,7 +3117,7 @@ func TestSharedChannelSyncForPostActions(t *testing.T) {
UserId: user.Id,
ChannelId: channel.Id,
Message: "Hello folks",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err, "Creating a post should not error")
require.Len(t, sharedChannelService.channelNotifications, 1)
@ -3141,7 +3141,7 @@ func TestSharedChannelSyncForPostActions(t *testing.T) {
UserId: user.Id,
ChannelId: channel.Id,
Message: "Hello folks",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err, "Creating a post should not error")
_, err = th.App.UpdatePost(th.Context, post, true)
@ -3169,7 +3169,7 @@ func TestSharedChannelSyncForPostActions(t *testing.T) {
UserId: user.Id,
ChannelId: channel.Id,
Message: "Hello folks",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err, "Creating a post should not error")
_, err = th.App.DeletePost(th.Context, post.Id, user.Id)
@ -3199,11 +3199,11 @@ func TestAutofollowOnPostingAfterUnfollow(t *testing.T) {
require.Nil(t, appErr)
appErr = th.App.JoinChannel(th.Context, channel, user2.Id)
require.Nil(t, appErr)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + user2.Username}, channel, false, false)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + user2.Username}, channel, model.CreatePostFlags{})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user2.Id, ChannelId: channel.Id, Message: "Hola"}, channel, false, false)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user2.Id, ChannelId: channel.Id, Message: "Hola"}, channel, model.CreatePostFlags{})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "reply"}, channel, false, false)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "reply"}, channel, model.CreatePostFlags{})
require.Nil(t, err)
// unfollow thread
@ -3214,7 +3214,7 @@ func TestAutofollowOnPostingAfterUnfollow(t *testing.T) {
require.NoError(t, nErr)
require.False(t, m.Following)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "another reply"}, channel, false, false)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "another reply"}, channel, model.CreatePostFlags{})
require.Nil(t, err)
// User should be following thread after posting in it, even after previously
@ -3230,7 +3230,7 @@ func TestGetPostIfAuthorized(t *testing.T) {
t.Run("Private channel", func(t *testing.T) {
privateChannel := th.CreatePrivateChannel(th.Context, th.BasicTeam)
post, err := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: privateChannel.Id, Message: "Hello"}, privateChannel, false, false)
post, err := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: privateChannel.Id, Message: "Hello"}, privateChannel, model.CreatePostFlags{})
require.Nil(t, err)
require.NotNil(t, post)
@ -3253,7 +3253,7 @@ func TestGetPostIfAuthorized(t *testing.T) {
t.Run("Public channel", func(t *testing.T) {
publicChannel := th.CreateChannel(th.Context, th.BasicTeam)
post, err := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: publicChannel.Id, Message: "Hello"}, publicChannel, false, false)
post, err := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: publicChannel.Id, Message: "Hello"}, publicChannel, model.CreatePostFlags{})
require.Nil(t, err)
require.NotNil(t, post)
@ -3304,9 +3304,9 @@ func TestShouldNotRefollowOnOthersReply(t *testing.T) {
require.Nil(t, appErr)
appErr = th.App.JoinChannel(th.Context, channel, user2.Id)
require.Nil(t, appErr)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + user2.Username}, channel, false, false)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + user2.Username}, channel, model.CreatePostFlags{})
require.Nil(t, err)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user2.Id, ChannelId: channel.Id, Message: "Hola"}, channel, false, false)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user2.Id, ChannelId: channel.Id, Message: "Hola"}, channel, model.CreatePostFlags{})
require.Nil(t, err)
// User2 unfollows thread
@ -3318,7 +3318,7 @@ func TestShouldNotRefollowOnOthersReply(t *testing.T) {
require.False(t, m.Following)
// user posts in the thread
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "another reply"}, channel, false, false)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "another reply"}, channel, model.CreatePostFlags{})
require.Nil(t, err)
// User2 should still not be following the thread because they manually
@ -3328,7 +3328,7 @@ func TestShouldNotRefollowOnOthersReply(t *testing.T) {
require.False(t, m.Following)
// user posts in the thread mentioning user2
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "reply with mention @" + user2.Username}, channel, false, false)
_, err = th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "reply with mention @" + user2.Username}, channel, model.CreatePostFlags{})
require.Nil(t, err)
// User2 should now be following the thread because they were explicitly mentioned
@ -3438,7 +3438,7 @@ func TestGetEditHistoryForPost(t *testing.T) {
UserId: th.BasicUser.Id,
}
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
rpost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// update the post message
@ -3487,7 +3487,7 @@ func TestCopyWranglerPostlist(t *testing.T) {
UserId: th.BasicUser.Id,
FileIds: []string{fileInfo.Id},
}
rootPost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
rootPost, err := th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err)
// Add a reaction to the post
@ -3673,7 +3673,7 @@ func TestPermanentDeletePost(t *testing.T) {
FileIds: []string{info1.Id},
}
post, err = th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
post, err = th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
assert.Nil(t, err)
// Delete the post.
@ -3712,7 +3712,7 @@ func TestPermanentDeletePost(t *testing.T) {
FileIds: []string{info1.Id},
}
post, err = th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
post, err = th.App.CreatePost(th.Context, post, th.BasicChannel, model.CreatePostFlags{SetOnline: true})
assert.Nil(t, err)
infos, sErr := th.App.Srv().Store().FileInfo().GetForPost(post.Id, true, true, false)

View file

@ -113,7 +113,7 @@ func TestSharedChannelSyncForReactionActions(t *testing.T) {
UserId: user.Id,
ChannelId: channel.Id,
Message: "Hello folks",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err, "Creating a post should not error")
reaction := &model.Reaction{
@ -148,7 +148,7 @@ func TestSharedChannelSyncForReactionActions(t *testing.T) {
UserId: user.Id,
ChannelId: channel.Id,
Message: "Hello folks",
}, channel, false, true)
}, channel, model.CreatePostFlags{SetOnline: true})
require.Nil(t, err, "Creating a post should not error")
reaction := &model.Reaction{

View file

@ -136,7 +136,7 @@ func (a *App) SendReportToUser(rctx request.CTX, job *model.Job, format string)
FileIds: []string{fileInfo.Id},
}
_, err = a.CreatePost(rctx, post, channel, false, true)
_, err = a.CreatePost(rctx, post, channel, model.CreatePostFlags{SetOnline: true})
return err
}
@ -250,7 +250,7 @@ func (a *App) StartUsersBatchExport(rctx request.CTX, ro *model.UserReportOption
UserId: systemBot.UserId,
}
if _, err := a.CreatePost(rctx, post, channel, false, true); err != nil {
if _, err := a.CreatePost(rctx, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
rctx.Logger().Error("Failed to post batch export message", mlog.Err(err))
}
})

View file

@ -359,7 +359,7 @@ func (th *TestHelper) createPost(channel *model.Channel) *model.Post {
}
var err *model.AppError
if post, err = th.App.CreatePost(th.Context, post, channel, false, true); err != nil {
if post, err = th.App.CreatePost(th.Context, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
panic(err)
}
return post

View file

@ -1286,7 +1286,7 @@ func (a *App) postLeaveTeamMessage(c request.CTX, user *model.User, channel *mod
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("postRemoveFromChannelMessage", "api.channel.post_user_add_remove_message_and_forget.error", nil, "", http.StatusInternalServerError).Wrap(err)
}
@ -1304,7 +1304,7 @@ func (a *App) postRemoveFromTeamMessage(c request.CTX, user *model.User, channel
},
}
if _, err := a.CreatePost(c, post, channel, false, true); err != nil {
if _, err := a.CreatePost(c, post, channel, model.CreatePostFlags{SetOnline: true}); err != nil {
return model.NewAppError("postRemoveFromTeamMessage", "api.channel.post_user_add_remove_message_and_forget.error", nil, "", http.StatusInternalServerError).Wrap(err)
}

View file

@ -1937,9 +1937,9 @@ func TestUpdateThreadReadForUser(t *testing.T) {
*cfg.ServiceSettings.CollapsedThreads = model.CollapsedThreadsDefaultOn
})
rootPost, appErr := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "hi"}, th.BasicChannel, false, false)
rootPost, appErr := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "hi"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
replyPost, appErr := th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "hi"}, th.BasicChannel, false, false)
replyPost, appErr := th.App.CreatePost(th.Context, &model.Post{RootId: rootPost.Id, UserId: th.BasicUser2.Id, CreateAt: model.GetMillis(), ChannelId: th.BasicChannel.Id, Message: "hi"}, th.BasicChannel, model.CreatePostFlags{})
require.Nil(t, appErr)
threads, appErr := th.App.GetThreadsForUser(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{})
require.Nil(t, appErr)

View file

@ -365,7 +365,7 @@ func (a *App) CreateWebhookPost(c request.CTX, userID string, channel *model.Cha
}
for _, split := range splits {
if _, err = a.CreatePost(c, split, channel, false, false); err != nil {
if _, err = a.CreatePost(c, split, channel, model.CreatePostFlags{}); err != nil {
return nil, model.NewAppError("CreateWebhookPost", "api.post.create_webhook_post.creating.app_error", nil, "err="+err.Message, http.StatusInternalServerError)
}
}

View file

@ -22,10 +22,10 @@ func (s *MmctlE2ETestSuite) TestPostListCmd() {
channel, err := s.th.App.CreateChannel(s.th.Context, &model.Channel{Name: channelName, DisplayName: channelDisplayName, Type: model.ChannelTypePrivate, TeamId: s.th.BasicTeam.Id}, false)
s.Require().Nil(err)
post1, err := s.th.App.CreatePost(s.th.Context, &model.Post{Message: model.NewRandomString(15), UserId: s.th.BasicUser.Id, ChannelId: channel.Id}, channel, false, false)
post1, err := s.th.App.CreatePost(s.th.Context, &model.Post{Message: model.NewRandomString(15), UserId: s.th.BasicUser.Id, ChannelId: channel.Id}, channel, model.CreatePostFlags{})
s.Require().Nil(err)
post2, err := s.th.App.CreatePost(s.th.Context, &model.Post{Message: model.NewRandomString(15), UserId: s.th.BasicUser.Id, ChannelId: channel.Id}, channel, false, false)
post2, err := s.th.App.CreatePost(s.th.Context, &model.Post{Message: model.NewRandomString(15), UserId: s.th.BasicUser.Id, ChannelId: channel.Id}, channel, model.CreatePostFlags{})
s.Require().Nil(err)
return channelName, post1, post2

View file

@ -102,9 +102,9 @@ func (_m *MockAppIface) CreateChannelWithUser(c request.CTX, channel *model.Chan
return r0, r1
}
// CreatePost provides a mock function with given fields: c, post, channel, triggerWebhooks, setOnline
func (_m *MockAppIface) CreatePost(c request.CTX, post *model.Post, channel *model.Channel, triggerWebhooks bool, setOnline bool) (*model.Post, *model.AppError) {
ret := _m.Called(c, post, channel, triggerWebhooks, setOnline)
// CreatePost provides a mock function with given fields: c, post, channel, flags
func (_m *MockAppIface) CreatePost(c request.CTX, post *model.Post, channel *model.Channel, flags model.CreatePostFlags) (*model.Post, *model.AppError) {
ret := _m.Called(c, post, channel, flags)
if len(ret) == 0 {
panic("no return value specified for CreatePost")
@ -112,19 +112,19 @@ func (_m *MockAppIface) CreatePost(c request.CTX, post *model.Post, channel *mod
var r0 *model.Post
var r1 *model.AppError
if rf, ok := ret.Get(0).(func(request.CTX, *model.Post, *model.Channel, bool, bool) (*model.Post, *model.AppError)); ok {
return rf(c, post, channel, triggerWebhooks, setOnline)
if rf, ok := ret.Get(0).(func(request.CTX, *model.Post, *model.Channel, model.CreatePostFlags) (*model.Post, *model.AppError)); ok {
return rf(c, post, channel, flags)
}
if rf, ok := ret.Get(0).(func(request.CTX, *model.Post, *model.Channel, bool, bool) *model.Post); ok {
r0 = rf(c, post, channel, triggerWebhooks, setOnline)
if rf, ok := ret.Get(0).(func(request.CTX, *model.Post, *model.Channel, model.CreatePostFlags) *model.Post); ok {
r0 = rf(c, post, channel, flags)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.Post)
}
}
if rf, ok := ret.Get(1).(func(request.CTX, *model.Post, *model.Channel, bool, bool) *model.AppError); ok {
r1 = rf(c, post, channel, triggerWebhooks, setOnline)
if rf, ok := ret.Get(1).(func(request.CTX, *model.Post, *model.Channel, model.CreatePostFlags) *model.AppError); ok {
r1 = rf(c, post, channel, flags)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)

View file

@ -57,7 +57,7 @@ type AppIface interface {
AddUserToChannel(c request.CTX, user *model.User, channel *model.Channel, skipTeamMemberIntegrityCheck bool) (*model.ChannelMember, *model.AppError)
AddUserToTeamByTeamId(c request.CTX, teamId string, user *model.User) *model.AppError
PermanentDeleteChannel(c request.CTX, channel *model.Channel) *model.AppError
CreatePost(c request.CTX, post *model.Post, channel *model.Channel, triggerWebhooks bool, setOnline bool) (savedPost *model.Post, err *model.AppError)
CreatePost(c request.CTX, post *model.Post, channel *model.Channel, flags model.CreatePostFlags) (savedPost *model.Post, err *model.AppError)
UpdatePost(c request.CTX, post *model.Post, safeUpdate bool) (*model.Post, *model.AppError)
DeletePost(c request.CTX, postID, deleteByID string) (*model.Post, *model.AppError)
SaveReactionForPost(c request.CTX, reaction *model.Reaction) (*model.Reaction, *model.AppError)

View file

@ -385,7 +385,7 @@ func (scs *Service) upsertSyncPost(post *model.Post, targetChannel *model.Channe
return nil, fmt.Errorf("post sync failed: %w", ErrRemoteIDMismatch)
}
rpost, appErr = scs.app.CreatePost(rctx, post, targetChannel, true, true)
rpost, appErr = scs.app.CreatePost(rctx, post, targetChannel, model.CreatePostFlags{TriggerWebhooks: true, SetOnline: true})
if appErr == nil {
scs.server.Log().Log(mlog.LvlSharedChannelServiceDebug, "Created sync post",
mlog.String("post_id", post.Id),

View file

@ -338,6 +338,11 @@ func (o *Post) EncodeJSON(w io.Writer) error {
return json.NewEncoder(w).Encode(o)
}
type CreatePostFlags struct {
TriggerWebhooks bool
SetOnline bool
}
type GetPostsSinceOptions struct {
UserId string
ChannelId string