[GH-25484] Fix draft removal on post deletion (#25715)
* [GH-25484] Fix draft removal on post deletion * [GH-25484] Add batch migration to remove orphan drafts * [GH-25484] Fix tests of migration and draft store * [GH-25484] Remove translation file changes. * [GH-25484] Remove translation file changes. --------- Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
435da9bea7
Коммит
3ac6edb406
@@ -1417,11 +1417,23 @@ func (a *App) DeletePost(c request.CTX, postID, deleteByID string) (*model.Post,
|
||||
}
|
||||
})
|
||||
|
||||
// delete drafts associated with the post when deleting the post
|
||||
a.Srv().Go(func() {
|
||||
a.deleteDraftsAssociatedWithPost(c, channel, post)
|
||||
})
|
||||
|
||||
a.invalidateCacheForChannelPosts(post.ChannelId)
|
||||
|
||||
return post, nil
|
||||
}
|
||||
|
||||
func (a *App) deleteDraftsAssociatedWithPost(c request.CTX, channel *model.Channel, post *model.Post) {
|
||||
if err := a.Srv().Store().Draft().DeleteDraftsAssociatedWithPost(channel.Id, post.Id); err != nil {
|
||||
c.Logger().Error("Failed to delete drafts associated with post when deleting post", mlog.Err(err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) deleteFlaggedPosts(c request.CTX, postID string) {
|
||||
if err := a.Srv().Store().Preference().DeleteCategoryAndName(model.PreferenceCategoryFlaggedPost, postID); err != nil {
|
||||
c.Logger().Warn("Unable to delete flagged post preference when deleting post.", mlog.Err(err))
|
||||
|
||||
Ссылка в новой задаче
Block a user