Use different user-agent for twitter links (#16210)

Этот коммит содержится в:
Ben Schumacher
2020-11-17 14:48:51 +01:00
коммит произвёл GitHub
родитель eced0cdb72
Коммит 4063f407a1
3 изменённых файлов: 9 добавлений и 3 удалений

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

@@ -410,6 +410,12 @@ func (a *App) getLinkMetadata(requestURL string, timestamp int64, isNewPost bool
client := a.HTTPService().MakeClient(false)
client.Timeout = time.Duration(*a.Config().ExperimentalSettings.LinkMetadataTimeoutMilliseconds) * time.Millisecond
mmTransport := a.HTTPService().MakeTransport(false)
client.Transport = mmTransport.Transport
if strings.HasPrefix(requestURL, "https://twitter.com/") || strings.HasPrefix(requestURL, "https://mobile.twitter.com/") {
request.Header.Add("User-Agent", "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)")
}
var res *http.Response
res, err = client.Do(request)