From 61141ac2324fd73221f8301ba3805c051bc99fe2 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Tue, 28 Jan 2025 20:22:23 +0000 Subject: [chore] remove type switch in Create() and instead move to FederatedCallbacks() (#3697) * remove type switch in Create() and instead move to FederatedCallbacks() * add missing (my bad!) federating wrapped callbacks behaviour * add missing license header :innocent: * fix create flag test to use correct function --- internal/federation/federatingprotocol.go | 35 ++----------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'internal/federation/federatingprotocol.go') diff --git a/internal/federation/federatingprotocol.go b/internal/federation/federatingprotocol.go index a953701f8..2bf934161 100644 --- a/internal/federation/federatingprotocol.go +++ b/internal/federation/federatingprotocol.go @@ -456,39 +456,8 @@ func (f *Federator) FederatingCallbacks(ctx context.Context) ( other []any, err error, ) { - wrapped = pub.FederatingWrappedCallbacks{ - // OnFollow determines what action to take for this - // particular callback if a Follow Activity is handled. - // - // For our implementation, we always want to do nothing - // because we have internal logic for handling follows. - OnFollow: pub.OnFollowDoNothing, - } - - // Override some default behaviors to trigger our own side effects. - other = []any{ - func(ctx context.Context, undo vocab.ActivityStreamsUndo) error { - return f.FederatingDB().Undo(ctx, undo) - }, - func(ctx context.Context, accept vocab.ActivityStreamsAccept) error { - return f.FederatingDB().Accept(ctx, accept) - }, - func(ctx context.Context, reject vocab.ActivityStreamsReject) error { - return f.FederatingDB().Reject(ctx, reject) - }, - func(ctx context.Context, announce vocab.ActivityStreamsAnnounce) error { - return f.FederatingDB().Announce(ctx, announce) - }, - } - - // Define some of our own behaviors which are not - // overrides of the default pub.FederatingWrappedCallbacks. - other = append(other, []any{ - func(ctx context.Context, move vocab.ActivityStreamsMove) error { - return f.FederatingDB().Move(ctx, move) - }, - }...) - + wrapped = f.wrapped + other = f.callback return } -- cgit v1.2.3