mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-18 14:49:01 -06:00
Add preview card storing to the database
This commit is contained in:
parent
85c32526f2
commit
6169351d22
12 changed files with 228 additions and 55 deletions
|
|
@ -55,7 +55,7 @@ func FetchPreview(text string) (*gtsmodel.Card, gtserror.WithCode) {
|
|||
return nil, gtserror.NewErrorInternalError(fmt.Errorf("unsupported scheme: %s", parsed.Scheme))
|
||||
}
|
||||
|
||||
resp, err := http.Get(link)
|
||||
resp, err := safeGet(parsed)
|
||||
if err != nil {
|
||||
return nil, gtserror.NewErrorInternalError(err, "request failed")
|
||||
}
|
||||
|
|
@ -109,3 +109,8 @@ func FetchPreview(text string) (*gtsmodel.Card, gtserror.WithCode) {
|
|||
|
||||
return card, nil
|
||||
}
|
||||
|
||||
func safeGet(u *url.URL) (*http.Response, error) {
|
||||
// #nosec G107 -- URL was already validated
|
||||
return http.Get(u.String())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue