summaryrefslogtreecommitdiff
path: root/internal/federation/federatingdb/util.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-07-11 16:22:21 +0200
committerLibravatar GitHub <noreply@github.com>2021-07-11 16:22:21 +0200
commit846057f0d696fded87d105dec1245e9ba32763ce (patch)
tree9a4914c07bcf189a3eea0a2c091567c56cdf4963 /internal/federation/federatingdb/util.go
parentfavourites GET implementation (#95) (diff)
downloadgotosocial-846057f0d696fded87d105dec1245e9ba32763ce.tar.xz
Block/unblock (#96)
* remote + local block logic, incl. federation * improve blocking stuff * fiddle with display of blocked profiles * go fmt
Diffstat (limited to 'internal/federation/federatingdb/util.go')
-rw-r--r--internal/federation/federatingdb/util.go30
1 files changed, 28 insertions, 2 deletions
diff --git a/internal/federation/federatingdb/util.go b/internal/federation/federatingdb/util.go
index ed3c252d9..28f4c5a21 100644
--- a/internal/federation/federatingdb/util.go
+++ b/internal/federation/federatingdb/util.go
@@ -139,7 +139,7 @@ func (f *federatingDB) NewID(c context.Context, t vocab.Type) (idURL *url.URL, e
// ID might already be set on an announce we've created, so check it here and return it if it is
announce, ok := t.(vocab.ActivityStreamsAnnounce)
if !ok {
- return nil, errors.New("newid: fave couldn't be parsed into vocab.ActivityStreamsAnnounce")
+ return nil, errors.New("newid: announce couldn't be parsed into vocab.ActivityStreamsAnnounce")
}
idProp := announce.GetJSONLDId()
if idProp != nil {
@@ -152,7 +152,7 @@ func (f *federatingDB) NewID(c context.Context, t vocab.Type) (idURL *url.URL, e
// ID might already be set on an update we've created, so check it here and return it if it is
update, ok := t.(vocab.ActivityStreamsUpdate)
if !ok {
- return nil, errors.New("newid: fave couldn't be parsed into vocab.ActivityStreamsUpdate")
+ return nil, errors.New("newid: update couldn't be parsed into vocab.ActivityStreamsUpdate")
}
idProp := update.GetJSONLDId()
if idProp != nil {
@@ -160,6 +160,32 @@ func (f *federatingDB) NewID(c context.Context, t vocab.Type) (idURL *url.URL, e
return idProp.GetIRI(), nil
}
}
+ case gtsmodel.ActivityStreamsBlock:
+ // BLOCK
+ // ID might already be set on a block we've created, so check it here and return it if it is
+ block, ok := t.(vocab.ActivityStreamsBlock)
+ if !ok {
+ return nil, errors.New("newid: block couldn't be parsed into vocab.ActivityStreamsBlock")
+ }
+ idProp := block.GetJSONLDId()
+ if idProp != nil {
+ if idProp.IsIRI() {
+ return idProp.GetIRI(), nil
+ }
+ }
+ case gtsmodel.ActivityStreamsUndo:
+ // UNDO
+ // ID might already be set on an undo we've created, so check it here and return it if it is
+ undo, ok := t.(vocab.ActivityStreamsUndo)
+ if !ok {
+ return nil, errors.New("newid: undo couldn't be parsed into vocab.ActivityStreamsUndo")
+ }
+ idProp := undo.GetJSONLDId()
+ if idProp != nil {
+ if idProp.IsIRI() {
+ return idProp.GetIRI(), nil
+ }
+ }
}
// fallback default behavior: just return a random ULID after our protocol and host