[MM-16330] Migrate "Channel.GetForPost" to Sync by default (#11199)
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
209f70e80b
Коммит
5c32f92413
@@ -75,8 +75,7 @@ func (a *App) SessionHasPermissionToChannelByPost(session model.Session, postId
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-a.Srv.Store.Channel().GetForPost(postId); result.Err == nil {
|
||||
channel := result.Data.(*model.Channel)
|
||||
if channel, err := a.Srv.Store.Channel().GetForPost(postId); err == nil {
|
||||
if channel.TeamId != "" {
|
||||
return a.SessionHasPermissionToTeam(session, channel.TeamId, permission)
|
||||
}
|
||||
@@ -175,8 +174,7 @@ func (a *App) HasPermissionToChannelByPost(askingUserId string, postId string, p
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-a.Srv.Store.Channel().GetForPost(postId); result.Err == nil {
|
||||
channel := result.Data.(*model.Channel)
|
||||
if channel, err := a.Srv.Store.Channel().GetForPost(postId); err == nil {
|
||||
return a.HasPermissionToTeam(askingUserId, channel.TeamId, permission)
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,12 @@ func (a *App) DoPostActionWithCookie(postId, actionId, userId, selectedOption st
|
||||
close(pchan)
|
||||
}()
|
||||
|
||||
cchan := a.Srv.Store.Channel().GetForPost(postId)
|
||||
cchan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
channel, err := a.Srv.Store.Channel().GetForPost(postId)
|
||||
cchan <- store.StoreResult{Data: channel, Err: err}
|
||||
close(cchan)
|
||||
}()
|
||||
|
||||
result := <-pchan
|
||||
if result.Err != nil {
|
||||
|
||||
14
app/post.go
14
app/post.go
@@ -341,11 +341,11 @@ func (a *App) FillInPostProps(post *model.Post, channel *model.Channel) *model.A
|
||||
|
||||
if len(channelMentions) > 0 {
|
||||
if channel == nil {
|
||||
result := <-a.Srv.Store.Channel().GetForPost(post.Id)
|
||||
if result.Err != nil {
|
||||
return model.NewAppError("FillInPostProps", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "post.channel_id"}, result.Err.Error(), http.StatusBadRequest)
|
||||
postChannel, err := a.Srv.Store.Channel().GetForPost(post.Id)
|
||||
if err != nil {
|
||||
return model.NewAppError("FillInPostProps", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "post.channel_id"}, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
channel = result.Data.(*model.Channel)
|
||||
channel = postChannel
|
||||
}
|
||||
|
||||
mentionedChannels, err := a.GetChannelsByNames(channelMentions, channel.TeamId)
|
||||
@@ -552,12 +552,12 @@ func (a *App) UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model
|
||||
|
||||
if a.IsESIndexingEnabled() {
|
||||
a.Srv.Go(func() {
|
||||
rchannel := <-a.Srv.Store.Channel().GetForPost(rpost.Id)
|
||||
if rchannel.Err != nil {
|
||||
channel, chanErr := a.Srv.Store.Channel().GetForPost(rpost.Id)
|
||||
if chanErr != nil {
|
||||
mlog.Error(fmt.Sprintf("Couldn't get channel %v for post %v for Elasticsearch indexing.", rpost.ChannelId, rpost.Id))
|
||||
return
|
||||
}
|
||||
if err := a.Elasticsearch.IndexPost(rpost, rchannel.Data.(*model.Channel).TeamId); err != nil {
|
||||
if err := a.Elasticsearch.IndexPost(rpost, channel.TeamId); err != nil {
|
||||
mlog.Error("Encountered error indexing post", mlog.String("post_id", post.Id), mlog.Err(err))
|
||||
}
|
||||
})
|
||||
|
||||
Ссылка в новой задаче
Block a user