MM-15035: Read from file infos from master on post creation (#10899)

* MM-15035: Read from file infos from master on post creation

* Handling edit post cases for get files metadata
Этот коммит содержится в:
Jesús Espino
2019-05-23 14:29:41 +02:00
коммит произвёл GitHub
родитель e59674cfdd
Коммит 87ff64ea6d
6 изменённых файлов: 31 добавлений и 31 удалений

Просмотреть файл

@@ -295,7 +295,7 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
// Normally, we would let the API layer call PreparePostForClient, but we do it here since it also needs
// to be done when we send the post over the websocket in handlePostEvents
rpost = a.PreparePostForClient(rpost, true)
rpost = a.PreparePostForClient(rpost, true, false)
if err := a.handlePostEvents(rpost, user, channel, triggerWebhooks, parentPostList); err != nil {
mlog.Error("Failed to handle post events", mlog.Err(err))
@@ -415,7 +415,7 @@ func (a *App) SendEphemeralPost(userId string, post *model.Post) *model.Post {
post.GenerateActionIds()
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_EPHEMERAL_MESSAGE, "", post.ChannelId, userId, nil)
post = a.PreparePostForClient(post, true)
post = a.PreparePostForClient(post, true, false)
post = model.AddPostActionCookies(post, a.PostActionCookieSecret())
message.Add("post", post.ToJson())
a.Publish(message)
@@ -433,7 +433,7 @@ func (a *App) UpdateEphemeralPost(userId string, post *model.Post) *model.Post {
post.GenerateActionIds()
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_POST_EDITED, "", post.ChannelId, userId, nil)
post = a.PreparePostForClient(post, true)
post = a.PreparePostForClient(post, true, false)
post = model.AddPostActionCookies(post, a.PostActionCookieSecret())
message.Add("post", post.ToJson())
a.Publish(message)
@@ -563,7 +563,7 @@ func (a *App) UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model
})
}
rpost = a.PreparePostForClient(rpost, false)
rpost = a.PreparePostForClient(rpost, false, true)
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_POST_EDITED, "", rpost.ChannelId, "", nil)
message.Add("post", rpost.ToJson())
@@ -741,7 +741,7 @@ func (a *App) DeletePost(postId, deleteByID string) (*model.Post, *model.AppErro
}
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_POST_DELETED, "", post.ChannelId, "", nil)
message.Add("post", a.PreparePostForClient(post, false).ToJson())
message.Add("post", a.PreparePostForClient(post, false, false).ToJson())
a.Publish(message)
a.Srv.Go(func() {
@@ -957,7 +957,7 @@ func (a *App) SearchPostsInTeamForUser(terms string, userId string, teamId strin
func (a *App) GetFileInfosForPostWithMigration(postId string) ([]*model.FileInfo, *model.AppError) {
pchan := a.Srv.Store.Post().GetSingle(postId)
infos, err := a.GetFileInfosForPost(postId)
infos, err := a.GetFileInfosForPost(postId, false)
if err != nil {
return nil, err
}
@@ -980,8 +980,8 @@ func (a *App) GetFileInfosForPostWithMigration(postId string) ([]*model.FileInfo
return infos, nil
}
func (a *App) GetFileInfosForPost(postId string) ([]*model.FileInfo, *model.AppError) {
return a.Srv.Store.FileInfo().GetForPost(postId, false, true)
func (a *App) GetFileInfosForPost(postId string, fromMaster bool) ([]*model.FileInfo, *model.AppError) {
return a.Srv.Store.FileInfo().GetForPost(postId, fromMaster, true)
}
func (a *App) PostWithProxyAddedToImageURLs(post *model.Post) *model.Post {