[MM-42192] Include deleted posts in GetPost (#20358)

* Introduced include_deleted query param on get posts endpoint

* Update the correct func name in the comment.

Co-authored-by: santoniriccardo <santoni.riccardo@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Vishal
2022-06-06 13:29:42 +05:30
коммит произвёл GitHub
родитель 456299841a
Коммит 27fc14201f
16 изменённых файлов: 85 добавлений и 38 удалений

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

@@ -136,7 +136,7 @@ func (a *App) deduplicateCreatePost(post *model.Post) (foundPost *model.Post, er
// If the other thread finished creating the post, return the created post back to the
// client, making the API call feel idempotent.
actualPost, err := a.GetSinglePost(postID)
actualPost, err := a.GetSinglePost(postID, false)
if err != nil {
return nil, model.NewAppError("deduplicateCreatePost", "api.post.deduplicate_create_post.failed_to_get", nil, err.Error(), http.StatusInternalServerError)
}
@@ -718,7 +718,7 @@ func (a *App) publishWebsocketEventForPermalinkPost(post *model.Post, message *m
return false, nil
}
previewedPost, err := a.GetSinglePost(previewedPostID)
previewedPost, err := a.GetSinglePost(previewedPostID, false)
if err != nil {
if err.StatusCode == http.StatusNotFound {
mlog.Warn("permalinked post not found", mlog.String("referenced_post_id", previewedPostID))
@@ -768,7 +768,7 @@ func (a *App) publishWebsocketEventForPermalinkPost(post *model.Post, message *m
}
func (a *App) PatchPost(c *request.Context, postID string, patch *model.PostPatch) (*model.Post, *model.AppError) {
post, err := a.GetSinglePost(postID)
post, err := a.GetSinglePost(postID, false)
if err != nil {
return nil, err
}
@@ -840,8 +840,8 @@ func (a *App) GetPostsSince(options model.GetPostsSinceOptions) (*model.PostList
return postList, nil
}
func (a *App) GetSinglePost(postID string) (*model.Post, *model.AppError) {
post, err := a.Srv().Store.Post().GetSingle(postID, false)
func (a *App) GetSinglePost(postID string, includeDeleted bool) (*model.Post, *model.AppError) {
post, err := a.Srv().Store.Post().GetSingle(postID, includeDeleted)
if err != nil {
var nfErr *store.ErrNotFound
switch {
@@ -1678,8 +1678,8 @@ func (a *App) GetThreadMembershipsForUser(userID, teamID string) ([]*model.Threa
return a.Srv().Store.Thread().GetMembershipsForUser(userID, teamID)
}
func (a *App) GetPostIfAuthorized(postID string, session *model.Session) (*model.Post, *model.AppError) {
post, err := a.GetSinglePost(postID)
func (a *App) GetPostIfAuthorized(postID string, session *model.Session, includeDeleted bool) (*model.Post, *model.AppError) {
post, err := a.GetSinglePost(postID, includeDeleted)
if err != nil {
return nil, err
}