[MM-15841] Store: Migrate "Post.Save" to Sync by default (#11045)
* MM-15841: migrate post save to sync by default #10987 * MM-15841: remove variable shadowing #10987 * MM-15841: log error on post save #10987 * MM-15841: nil check post save errors #10987 * MM-15841: update error message on post save #10987 * MM-15841: add nil check on post save in user store test #10987
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
e0d084ab7a
Коммит
570e6f1a74
@@ -892,8 +892,8 @@ func (a *App) ImportReply(data *ReplyImportData, post *model.Post, teamId string
|
||||
}
|
||||
|
||||
if reply.Id == "" {
|
||||
if result := <-a.Srv.Store.Post().Save(reply); result.Err != nil {
|
||||
return result.Err
|
||||
if _, err := a.Srv.Store.Post().Save(reply); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if _, err := a.Srv.Store.Post().Overwrite(reply); err != nil {
|
||||
@@ -992,8 +992,8 @@ func (a *App) ImportPost(data *PostImportData, dryRun bool) *model.AppError {
|
||||
}
|
||||
|
||||
if post.Id == "" {
|
||||
if result := <-a.Srv.Store.Post().Save(post); result.Err != nil {
|
||||
return result.Err
|
||||
if _, err := a.Srv.Store.Post().Save(post); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if _, err := a.Srv.Store.Post().Overwrite(post); err != nil {
|
||||
@@ -1215,8 +1215,8 @@ func (a *App) ImportDirectPost(data *DirectPostImportData, dryRun bool) *model.A
|
||||
}
|
||||
|
||||
if post.Id == "" {
|
||||
if result := <-a.Srv.Store.Post().Save(post); result.Err != nil {
|
||||
return result.Err
|
||||
if _, err := a.Srv.Store.Post().Save(post); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if _, err := a.Srv.Store.Post().Overwrite(post); err != nil {
|
||||
|
||||
15
app/post.go
15
app/post.go
@@ -213,7 +213,7 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
|
||||
|
||||
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
||||
|
||||
if err := a.FillInPostProps(post, channel); err != nil {
|
||||
if err = a.FillInPostProps(post, channel); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -255,11 +255,10 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
|
||||
}
|
||||
}
|
||||
|
||||
result := <-a.Srv.Store.Post().Save(post)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
rpost, err := a.Srv.Store.Post().Save(post)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rpost := result.Data.(*model.Post)
|
||||
|
||||
// Update the mapping from pending post id to the actual post id, for any clients that
|
||||
// might be duplicating requests.
|
||||
@@ -278,7 +277,7 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
|
||||
esInterface := a.Elasticsearch
|
||||
if esInterface != nil && *a.Config().ElasticsearchSettings.EnableIndexing {
|
||||
a.Srv.Go(func() {
|
||||
if err := esInterface.IndexPost(rpost, channel.TeamId); err != nil {
|
||||
if err = esInterface.IndexPost(rpost, channel.TeamId); err != nil {
|
||||
mlog.Error("Encountered error indexing post", mlog.String("post_id", post.Id), mlog.Err(err))
|
||||
}
|
||||
})
|
||||
@@ -289,8 +288,8 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
|
||||
}
|
||||
|
||||
if len(post.FileIds) > 0 {
|
||||
if err := a.attachFilesToPost(post); err != nil {
|
||||
mlog.Error("Encountered error attaching files to post", mlog.String("post_id", post.Id), mlog.Any("file_ids", post.FileIds), mlog.Err(result.Err))
|
||||
if err = a.attachFilesToPost(post); err != nil {
|
||||
mlog.Error("Encountered error attaching files to post", mlog.String("post_id", post.Id), mlog.Any("file_ids", post.FileIds), mlog.Err(err))
|
||||
}
|
||||
|
||||
if a.Metrics != nil {
|
||||
|
||||
@@ -758,7 +758,8 @@ func (a *App) OldImportPost(post *model.Post) string {
|
||||
post.RootId = firstPostId
|
||||
post.ParentId = firstPostId
|
||||
|
||||
if result := <-a.Srv.Store.Post().Save(post); result.Err != nil {
|
||||
_, err := a.Srv.Store.Post().Save(post)
|
||||
if err != nil {
|
||||
mlog.Debug(fmt.Sprintf("Error saving post. user=%v, message=%v", post.UserId, post.Message))
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user