summaryrefslogtreecommitdiff
path: root/internal/federation/federatingdb/undo.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/federation/federatingdb/undo.go')
-rw-r--r--internal/federation/federatingdb/undo.go31
1 files changed, 16 insertions, 15 deletions
diff --git a/internal/federation/federatingdb/undo.go b/internal/federation/federatingdb/undo.go
index 84a5bdd47..a7a0f077a 100644
--- a/internal/federation/federatingdb/undo.go
+++ b/internal/federation/federatingdb/undo.go
@@ -27,6 +27,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtscontext"
+ "github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/log"
)
@@ -48,31 +49,31 @@ func (f *federatingDB) Undo(ctx context.Context, undo vocab.ActivityStreamsUndo)
return nil // Already processed.
}
- undoObject := undo.GetActivityStreamsObject()
- if undoObject == nil {
- return errors.New("UNDO: no object set on vocab.ActivityStreamsUndo")
- }
+ var errs gtserror.MultiError
- for iter := undoObject.Begin(); iter != undoObject.End(); iter = iter.Next() {
- t := iter.GetType()
- if t == nil {
+ for _, object := range ap.ExtractObjects(undo) {
+ // Try to get object as vocab.Type,
+ // else skip handling (likely) IRI.
+ objType := object.GetType()
+ if objType == nil {
continue
}
- switch t.GetTypeName() {
+ switch objType.GetTypeName() {
case ap.ActivityFollow:
- if err := f.undoFollow(ctx, receivingAccount, undo, t); err != nil {
- return err
+ if err := f.undoFollow(ctx, receivingAccount, undo, objType); err != nil {
+ errs.Appendf("error undoing follow: %w", err)
}
case ap.ActivityLike:
- if err := f.undoLike(ctx, receivingAccount, undo, t); err != nil {
- return err
+ if err := f.undoLike(ctx, receivingAccount, undo, objType); err != nil {
+ errs.Appendf("error undoing like: %w", err)
}
case ap.ActivityAnnounce:
- // todo: undo boost / reblog / announce
+ // TODO: actually handle this !
+ log.Warn(ctx, "skipped undo announce")
case ap.ActivityBlock:
- if err := f.undoBlock(ctx, receivingAccount, undo, t); err != nil {
- return err
+ if err := f.undoBlock(ctx, receivingAccount, undo, objType); err != nil {
+ errs.Appendf("error undoing block: %w", err)
}
}
}