mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-07 14:18:09 -06:00
[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 😇
* fix create flag test to use correct function
This commit is contained in:
parent
bfe8144fda
commit
61141ac232
14 changed files with 610 additions and 433 deletions
|
|
@ -24,6 +24,7 @@ import (
|
|||
"codeberg.org/gruf/go-cache/v3/simple"
|
||||
"github.com/superseriousbusiness/activity/pub"
|
||||
"github.com/superseriousbusiness/activity/streams/vocab"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/filter/interaction"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/filter/spam"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/filter/visibility"
|
||||
|
|
@ -34,18 +35,20 @@ import (
|
|||
// DB wraps the pub.Database interface with
|
||||
// a couple of custom functions for GoToSocial.
|
||||
type DB interface {
|
||||
// Default functionality.
|
||||
// Default
|
||||
// functionality.
|
||||
pub.Database
|
||||
|
||||
/*
|
||||
Overridden functionality for calling from federatingProtocol.
|
||||
*/
|
||||
|
||||
Undo(ctx context.Context, undo vocab.ActivityStreamsUndo) error
|
||||
Accept(ctx context.Context, accept vocab.ActivityStreamsAccept) error
|
||||
Reject(ctx context.Context, reject vocab.ActivityStreamsReject) error
|
||||
Announce(ctx context.Context, announce vocab.ActivityStreamsAnnounce) error
|
||||
Move(ctx context.Context, move vocab.ActivityStreamsMove) error
|
||||
// Federating protocol overridden callback functionality.
|
||||
Like(context.Context, vocab.ActivityStreamsLike) error
|
||||
Block(context.Context, vocab.ActivityStreamsBlock) error
|
||||
Follow(context.Context, vocab.ActivityStreamsFollow) error
|
||||
Undo(context.Context, vocab.ActivityStreamsUndo) error
|
||||
Accept(context.Context, vocab.ActivityStreamsAccept) error
|
||||
Reject(context.Context, vocab.ActivityStreamsReject) error
|
||||
Announce(context.Context, vocab.ActivityStreamsAnnounce) error
|
||||
Move(context.Context, vocab.ActivityStreamsMove) error
|
||||
Flag(context.Context, vocab.ActivityStreamsFlag) error
|
||||
|
||||
/*
|
||||
Extra/convenience functionality.
|
||||
|
|
@ -87,3 +90,9 @@ func New(
|
|||
fdb.activityIDs.Init(0, 2048)
|
||||
return &fdb
|
||||
}
|
||||
|
||||
// storeActivityID stores an entry in the .activityIDs cache for this
|
||||
// type's JSON-LD ID, for later checks in Exist() to mark it as seen.
|
||||
func (f *federatingDB) storeActivityID(asType vocab.Type) {
|
||||
f.activityIDs.Set(ap.GetJSONLDId(asType).String(), struct{}{})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue