PLT-5379 Fix the error occuring while fetching OG metadata for links which don't exist. (#5308)
Этот коммит содержится в:
коммит произвёл
enahum
родитель
439d5b7ed7
Коммит
5cc30fa061
@@ -444,6 +444,7 @@ func getOpenGraphMetadata(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
ogJson, err := og.ToJSON()
|
||||
if err != nil {
|
||||
w.Write([]byte(`{"url": ""}`))
|
||||
return
|
||||
}
|
||||
w.Write(ogJson)
|
||||
}
|
||||
|
||||
@@ -488,10 +488,10 @@ func GetOpenGraphMetadata(url string) *opengraph.OpenGraph {
|
||||
og := opengraph.NewOpenGraph()
|
||||
|
||||
res, err := http.Get(url)
|
||||
defer CloseBody(res)
|
||||
if err != nil {
|
||||
return og
|
||||
}
|
||||
defer CloseBody(res)
|
||||
|
||||
if err := og.ProcessHTML(res.Body); err != nil {
|
||||
return og
|
||||
|
||||
Ссылка в новой задаче
Block a user