1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 17:44:59 +09:00

GO-2213 bookmark: check http status

This commit is contained in:
Roman Khafizianov 2023-10-17 17:59:18 +02:00
parent 87a88ebf1e
commit f5c5abc392
No known key found for this signature in database
GPG key ID: F07A7D55A2684852

View file

@ -3,6 +3,7 @@ package linkpreview
import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"path/filepath"
@ -63,6 +64,10 @@ func (l *linkPreview) Fetch(ctx context.Context, fetchUrl string) (model.LinkPre
}
return model.LinkPreview{}, err
}
if resp := rt.lastResponse; resp != nil && resp.StatusCode != http.StatusOK {
return model.LinkPreview{}, fmt.Errorf("invalid http code %d", resp.StatusCode)
}
res := l.convertOGToInfo(fetchUrl, og)
if len(res.Description) == 0 {
res.Description = l.findContent(rt.lastBody)