* Use flags for create post

* Remove unintended file

* Fix unintended change and types

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Daniel Espino García
2024-10-22 16:00:26 +02:00
коммит произвёл GitHub
родитель 43a06d1b78
Коммит 2d96053012
31 изменённых файлов: 293 добавлений и 288 удалений

Просмотреть файл

@@ -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
}