MM-58038: Use context to call master for DeletePost (#27098)
Calling app.DeletePost immediately after creating a post is susceptible to replica lag because we were calling the replica to check for the post. We fix this by passing a context to always query master. https://mattermost.atlassian.net/browse/MM-58038 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
09c0eb7e7a
Коммит
6f3327ce0f
@@ -563,7 +563,7 @@ func getEditHistoryForPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
originalPost, err := c.App.GetSinglePost(c.Params.PostId, false)
|
||||
originalPost, err := c.App.GetSinglePost(c.AppContext, c.Params.PostId, false)
|
||||
if err != nil {
|
||||
c.SetPermissionError(model.PermissionEditPost)
|
||||
return
|
||||
@@ -600,7 +600,7 @@ func deletePost(c *Context, w http.ResponseWriter, _ *http.Request) {
|
||||
defer c.LogAuditRecWithLevel(auditRec, app.LevelContent)
|
||||
audit.AddEventParameter(auditRec, "post_id", c.Params.PostId)
|
||||
|
||||
post, err := c.App.GetSinglePost(c.Params.PostId, false)
|
||||
post, err := c.App.GetSinglePost(c.AppContext, c.Params.PostId, false)
|
||||
if err != nil {
|
||||
c.SetPermissionError(model.PermissionDeletePost)
|
||||
return
|
||||
@@ -844,7 +844,7 @@ func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
originalPost, err := c.App.GetSinglePost(c.Params.PostId, false)
|
||||
originalPost, err := c.App.GetSinglePost(c.AppContext, c.Params.PostId, false)
|
||||
if err != nil {
|
||||
c.SetPermissionError(model.PermissionEditPost)
|
||||
return
|
||||
@@ -916,7 +916,7 @@ func patchPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
// Updating the file_ids of a post is not a supported operation and will be ignored
|
||||
post.FileIds = nil
|
||||
|
||||
originalPost, err := c.App.GetSinglePost(c.Params.PostId, false)
|
||||
originalPost, err := c.App.GetSinglePost(c.AppContext, c.Params.PostId, false)
|
||||
if err != nil {
|
||||
c.SetPermissionError(model.PermissionEditPost)
|
||||
return
|
||||
@@ -1023,7 +1023,7 @@ func saveIsPinnedPost(c *Context, w http.ResponseWriter, isPinned bool) {
|
||||
audit.AddEventParameter(auditRec, "post_id", c.Params.PostId)
|
||||
defer c.LogAuditRecWithLevel(auditRec, app.LevelContent)
|
||||
|
||||
post, err := c.App.GetSinglePost(c.Params.PostId, false)
|
||||
post, err := c.App.GetSinglePost(c.AppContext, c.Params.PostId, false)
|
||||
if err != nil {
|
||||
c.SetPermissionError(model.PermissionReadChannelContent)
|
||||
return
|
||||
@@ -1117,7 +1117,7 @@ func unacknowledgePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
_, err := c.App.GetSinglePost(c.Params.PostId, false)
|
||||
_, err := c.App.GetSinglePost(c.AppContext, c.Params.PostId, false)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
|
||||
Ссылка в новой задаче
Block a user