Exclude sending file metadata to plugin hooks (#18454)

* Exclude sending file metadata to plugin hooks

A FileInfo object contained a MiniPreview which is
a slice of bytes. This can be particularly costly
while marshalling to plugin hooks.

We avoid this by refactoring the Embeds and Images
population to a separate method and calling that
to prevent posts from getting updated.

https://community-daily.mattermost.com/boards/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=9c0b5413-5401-4ef2-83d5-b9f756585bbc

```release-note
NONE
```

* refactor to separate method

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2021-09-27 08:35:39 +05:30
коммит произвёл GitHub
родитель ef639973b7
Коммит 225461fd7e
6 изменённых файлов: 45 добавлений и 14 удалений

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

@@ -128,7 +128,7 @@ func createEphemeralPost(c *Context, w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusCreated)
rp = model.AddPostActionCookies(rp, c.App.PostActionCookieSecret())
rp = c.App.PreparePostForClient(rp, true, false)
rp = c.App.PreparePostForClientWithEmbedsAndImages(rp, true, false)
rp, err := c.App.SanitizePostMetadataForUser(rp, c.AppContext.Session().UserId)
if err != nil {
c.Err = err
@@ -376,7 +376,7 @@ func getPost(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
post = c.App.PreparePostForClient(post, false, false)
post = c.App.PreparePostForClientWithEmbedsAndImages(post, false, false)
post, err = c.App.SanitizePostMetadataForUser(post, c.AppContext.Session().UserId)
if err != nil {
c.Err = err