diff options
author | 2023-01-25 11:12:27 +0100 | |
---|---|---|
committer | 2023-01-25 11:12:27 +0100 | |
commit | 993aae5e48a5a3b47a7c7bb3cb66e2d8abda17b2 (patch) | |
tree | a64ad3edaf2a29f457bd050b24609fe4f1abdf02 /internal/ap | |
parent | [feature] Implement reports admin API so admins can view + close reports (#1378) (diff) | |
download | gotosocial-993aae5e48a5a3b47a7c7bb3cb66e2d8abda17b2.tar.xz |
[feature] Accept incoming federated Flag activity (#1382)
* start working on handling incoming Flag activity
* interim commit
* federate Flag in successfully
Diffstat (limited to 'internal/ap')
-rw-r--r-- | internal/ap/extract.go | 17 | ||||
-rw-r--r-- | internal/ap/interfaces.go | 10 |
2 files changed, 27 insertions, 0 deletions
diff --git a/internal/ap/extract.go b/internal/ap/extract.go index c09f07c41..20420e02c 100644 --- a/internal/ap/extract.go +++ b/internal/ap/extract.go @@ -635,6 +635,23 @@ func ExtractObject(i WithObject) (*url.URL, error) { return nil, errors.New("no iri found for object prop") } +// ExtractObjects extracts a slice of URL objects from a WithObject interface. +func ExtractObjects(i WithObject) ([]*url.URL, error) { + objectProp := i.GetActivityStreamsObject() + if objectProp == nil { + return nil, errors.New("object property was nil") + } + + urls := make([]*url.URL, 0, objectProp.Len()) + for iter := objectProp.Begin(); iter != objectProp.End(); iter = iter.Next() { + if iter.IsIRI() && iter.GetIRI() != nil { + urls = append(urls, iter.GetIRI()) + } + } + + return urls, nil +} + // ExtractVisibility extracts the gtsmodel.Visibility of a given addressable with a To and CC property. // // ActorFollowersURI is needed to check whether the visibility is FollowersOnly or not. The passed-in value diff --git a/internal/ap/interfaces.go b/internal/ap/interfaces.go index 91960eed3..a538e4c2b 100644 --- a/internal/ap/interfaces.go +++ b/internal/ap/interfaces.go @@ -157,6 +157,16 @@ type CollectionPageable interface { WithItems } +// Flaggable represents the minimum interface for an activitystreams 'Flag' activity. +type Flaggable interface { + WithJSONLDId + WithTypeName + + WithActor + WithContent + WithObject +} + // WithJSONLDId represents an activity with JSONLDIdProperty type WithJSONLDId interface { GetJSONLDId() vocab.JSONLDIdProperty |