mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore/bugfix] Refactor ap/extract.go
functions, return URIs more reliably (#1897)
This commit is contained in:
@ -19,9 +19,11 @@ package typeutils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/regexes"
|
||||
)
|
||||
@ -82,3 +84,19 @@ func misskeyReportInlineURLs(content string) []*url.URL {
|
||||
}
|
||||
return urls
|
||||
}
|
||||
|
||||
// getURI is a shortcut/util function for extracting
|
||||
// the JSONLDId URI of an Activity or Object.
|
||||
func getURI(withID ap.WithJSONLDId) (*url.URL, string, error) {
|
||||
idProp := withID.GetJSONLDId()
|
||||
if idProp == nil {
|
||||
return nil, "", errors.New("id prop was nil")
|
||||
}
|
||||
|
||||
if !idProp.IsIRI() {
|
||||
return nil, "", errors.New("id prop was not an IRI")
|
||||
}
|
||||
|
||||
id := idProp.Get()
|
||||
return id, id.String(), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user