diff options
author | 2023-10-04 13:09:42 +0100 | |
---|---|---|
committer | 2023-10-04 13:09:42 +0100 | |
commit | c6e00afc7c23df994b70eee89d2d392718e6a321 (patch) | |
tree | cee98c1a78e36ba6a0e8183afa0b2796765fe7f6 /internal/federation/federatingdb/undo.go | |
parent | [chore] internal/ap: add pollable AS types, code reformatting, general niceti... (diff) | |
download | gotosocial-c6e00afc7c23df994b70eee89d2d392718e6a321.tar.xz |
[feature] tentatively start adding polls support (#2249)
Diffstat (limited to 'internal/federation/federatingdb/undo.go')
-rw-r--r-- | internal/federation/federatingdb/undo.go | 31 |
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) } } } |