Skip getting the post again when getting file metadata for a post (#9879)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
60393f1cad
Коммит
ba627c0f92
@@ -528,7 +528,7 @@ func getFileInfosForPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
infos, err := c.App.GetFileInfosForPost(c.Params.PostId, false)
|
infos, err := c.App.GetFileInfosForPostWithMigration(c.Params.PostId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
|
|||||||
18
app/post.go
18
app/post.go
@@ -752,14 +752,13 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr
|
|||||||
return model.MakePostSearchResults(posts, nil), nil
|
return model.MakePostSearchResults(posts, nil), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetFileInfosForPost(postId string, readFromMaster bool) ([]*model.FileInfo, *model.AppError) {
|
func (a *App) GetFileInfosForPostWithMigration(postId string) ([]*model.FileInfo, *model.AppError) {
|
||||||
pchan := a.Srv.Store.Post().GetSingle(postId)
|
pchan := a.Srv.Store.Post().GetSingle(postId)
|
||||||
|
|
||||||
result := <-a.Srv.Store.FileInfo().GetForPost(postId, readFromMaster, true)
|
infos, err := a.GetFileInfosForPost(postId)
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
return nil, result.Err
|
return nil, err
|
||||||
}
|
}
|
||||||
infos := result.Data.([]*model.FileInfo)
|
|
||||||
|
|
||||||
if len(infos) == 0 {
|
if len(infos) == 0 {
|
||||||
// No FileInfos were returned so check if they need to be created for this post
|
// No FileInfos were returned so check if they need to be created for this post
|
||||||
@@ -779,6 +778,15 @@ func (a *App) GetFileInfosForPost(postId string, readFromMaster bool) ([]*model.
|
|||||||
return infos, nil
|
return infos, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) GetFileInfosForPost(postId string) ([]*model.FileInfo, *model.AppError) {
|
||||||
|
result := <-a.Srv.Store.FileInfo().GetForPost(postId, false, true)
|
||||||
|
if result.Err != nil {
|
||||||
|
return nil, result.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.Data.([]*model.FileInfo), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) PostWithProxyAddedToImageURLs(post *model.Post) *model.Post {
|
func (a *App) PostWithProxyAddedToImageURLs(post *model.Post) *model.Post {
|
||||||
if f := a.ImageProxyAdder(); f != nil {
|
if f := a.ImageProxyAdder(); f != nil {
|
||||||
return post.WithRewrittenImageURLs(f)
|
return post.WithRewrittenImageURLs(f)
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ func (a *App) getFileMetadataForPost(post *model.Post) ([]*model.FileInfo, *mode
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.GetFileInfosForPost(post.Id, false)
|
return a.GetFileInfosForPost(post.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) getEmojisAndReactionsForPost(post *model.Post) ([]*model.Emoji, []*model.Reaction, *model.AppError) {
|
func (a *App) getEmojisAndReactionsForPost(post *model.Post) ([]*model.Emoji, []*model.Reaction, *model.AppError) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user