MM-21898 - Part 1: Generate and use an interface instead of *A… (#13840)
* Generate and use an interface instead of *App
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
66fc096768
Коммит
17523fa5d9
@@ -384,12 +384,12 @@ func (a *App) getLinkMetadata(requestURL string, timestamp int64, isNewPost bool
|
||||
|
||||
if (request.URL.Scheme+"://"+request.URL.Host) == a.GetSiteURL() && request.URL.Path == "/api/v4/image" {
|
||||
// /api/v4/image requires authentication, so bypass the API by hitting the proxy directly
|
||||
body, contentType, err = a.ImageProxy.GetImageDirect(a.ImageProxy.GetUnproxiedImageURL(request.URL.String()))
|
||||
body, contentType, err = a.ImageProxy().GetImageDirect(a.ImageProxy().GetUnproxiedImageURL(request.URL.String()))
|
||||
} else {
|
||||
request.Header.Add("Accept", "image/*")
|
||||
request.Header.Add("Accept", "text/html;q=0.8")
|
||||
|
||||
client := a.HTTPService.MakeClient(false)
|
||||
client := a.HTTPService().MakeClient(false)
|
||||
client.Timeout = time.Duration(*a.Config().ExperimentalSettings.LinkMetadataTimeoutMilliseconds) * time.Millisecond
|
||||
|
||||
var res *http.Response
|
||||
@@ -451,7 +451,7 @@ func getLinkMetadataFromCache(requestURL string, timestamp int64) (*opengraph.Op
|
||||
}
|
||||
|
||||
func (a *App) getLinkMetadataFromDatabase(requestURL string, timestamp int64) (*opengraph.OpenGraph, *model.PostImage, bool) {
|
||||
linkMetadata, err := a.Srv.Store.LinkMetadata().Get(requestURL, timestamp)
|
||||
linkMetadata, err := a.Srv().Store.LinkMetadata().Get(requestURL, timestamp)
|
||||
if err != nil {
|
||||
return nil, nil, false
|
||||
}
|
||||
@@ -484,7 +484,7 @@ func (a *App) saveLinkMetadataToDatabase(requestURL string, timestamp int64, og
|
||||
metadata.Type = model.LINK_METADATA_TYPE_NONE
|
||||
}
|
||||
|
||||
_, err := a.Srv.Store.LinkMetadata().Save(metadata)
|
||||
_, err := a.Srv().Store.LinkMetadata().Save(metadata)
|
||||
if err != nil {
|
||||
mlog.Warn("Failed to write link metadata", mlog.String("request_url", requestURL), mlog.Err(err))
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user