MM-64226: improved post deduplication (#31004)
Require access to a post before allowing PendingPostId to deduplicate. Fixes: https://mattermost.atlassian.net/browse/MM-64226
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8e033f41d1
Коммит
fa40a8c5d4
@@ -153,7 +153,7 @@ func (a *App) deduplicateCreatePost(rctx request.CTX, post *model.Post) (foundPo
|
||||
}
|
||||
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("errorGetPostId", "api.post.error_get_post_id.pending", nil, "", http.StatusInternalServerError).Wrap(nErr)
|
||||
return nil, model.NewAppError("deduplicateCreatePost", "api.post.error_get_post_id.pending", nil, "", http.StatusInternalServerError).Wrap(nErr)
|
||||
}
|
||||
|
||||
// If another thread saved the cache record, but hasn't yet updated it with the actual post
|
||||
@@ -165,8 +165,11 @@ func (a *App) deduplicateCreatePost(rctx request.CTX, post *model.Post) (foundPo
|
||||
|
||||
// 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(rctx, postID, false)
|
||||
if err != nil {
|
||||
actualPost, err := a.GetPostIfAuthorized(rctx, postID, rctx.Session(), false)
|
||||
if err != nil && err.StatusCode == http.StatusForbidden {
|
||||
rctx.Logger().Warn("Ignoring pending_post_id for which the user is unauthorized", mlog.String("pending_post_id", post.PendingPostId), mlog.String("post_id", postID), mlog.Err(err))
|
||||
return nil, nil
|
||||
} else if err != nil {
|
||||
return nil, model.NewAppError("deduplicateCreatePost", "api.post.deduplicate_create_post.failed_to_get", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user