Skip to content

Commit

Permalink
Rename Callbacks to disambiguate between S2S & C2S
Browse files Browse the repository at this point in the history
  • Loading branch information
cjslep committed Jul 6, 2020
1 parent 0430970 commit c2285ce
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions pub/federating_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ type FederatingProtocol interface {
// blocked must be false and error nil. The request will continue
// to be processed.
Blocked(c context.Context, actorIRIs []*url.URL) (blocked bool, err error)
// Callbacks returns the application logic that handles ActivityStreams
// received from federating peers.
// FederatingCallbacks returns the application logic that handles
// ActivityStreams received from federating peers.
//
// Note that certain types of callbacks will be 'wrapped' with default
// behaviors supported natively by the library. Other callbacks
Expand All @@ -84,7 +84,7 @@ type FederatingProtocol interface {
//
// Applications are not expected to handle every single ActivityStreams
// type and extension. The unhandled ones are passed to DefaultCallback.
Callbacks(c context.Context) (wrapped FederatingWrappedCallbacks, other []interface{}, err error)
FederatingCallbacks(c context.Context) (wrapped FederatingWrappedCallbacks, other []interface{}, err error)
// DefaultCallback is called for types that go-fed can deserialize but
// are not handled by the application's callbacks returned in the
// Callbacks method.
Expand Down
14 changes: 7 additions & 7 deletions pub/mock_federating_protocol_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions pub/mock_social_protocol_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pub/side_effect_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (a *sideEffectActor) PostInbox(c context.Context, inboxIRI *url.URL, activi
return err
}
if isNew {
wrapped, other, err := a.s2s.Callbacks(c)
wrapped, other, err := a.s2s.FederatingCallbacks(c)
if err != nil {
return err
}
Expand Down Expand Up @@ -327,7 +327,7 @@ func (a *sideEffectActor) PostOutbox(c context.Context, activity Activity, outbo
if a.c2s != nil {
var wrapped SocialWrappedCallbacks
var other []interface{}
wrapped, other, err = a.c2s.Callbacks(c)
wrapped, other, err = a.c2s.SocialCallbacks(c)
if err != nil {
return
}
Expand Down
20 changes: 10 additions & 10 deletions pub/side_effect_actor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestPostInbox(t *testing.T) {
db.EXPECT().SetInbox(ctx, testOrderedCollectionWithFederatedId).Return(nil),
db.EXPECT().Unlock(ctx, inboxIRI),
)
fp.EXPECT().Callbacks(ctx).Return(FederatingWrappedCallbacks{}, nil, nil)
fp.EXPECT().FederatingCallbacks(ctx).Return(FederatingWrappedCallbacks{}, nil, nil)
fp.EXPECT().DefaultCallback(ctx, testListen).Return(nil)
// Run
err := a.PostInbox(ctx, inboxIRI, testListen)
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestPostInbox(t *testing.T) {
db.EXPECT().SetInbox(ctx, testOrderedCollectionWithBothFederatedIds).Return(nil),
db.EXPECT().Unlock(ctx, inboxIRI),
)
fp.EXPECT().Callbacks(ctx).Return(FederatingWrappedCallbacks{}, nil, nil)
fp.EXPECT().FederatingCallbacks(ctx).Return(FederatingWrappedCallbacks{}, nil, nil)
fp.EXPECT().DefaultCallback(ctx, testListen).Return(nil)
// Run
err := a.PostInbox(ctx, inboxIRI, testListen)
Expand All @@ -278,7 +278,7 @@ func TestPostInbox(t *testing.T) {
db.EXPECT().Unlock(ctx, inboxIRI),
)
pass := false
fp.EXPECT().Callbacks(ctx).Return(FederatingWrappedCallbacks{}, []interface{}{
fp.EXPECT().FederatingCallbacks(ctx).Return(FederatingWrappedCallbacks{}, []interface{}{
func(c context.Context, a vocab.ActivityStreamsListen) error {
pass = true
return nil
Expand All @@ -304,7 +304,7 @@ func TestPostInbox(t *testing.T) {
db.EXPECT().Unlock(ctx, inboxIRI),
)
pass := false
fp.EXPECT().Callbacks(ctx).Return(FederatingWrappedCallbacks{}, []interface{}{
fp.EXPECT().FederatingCallbacks(ctx).Return(FederatingWrappedCallbacks{}, []interface{}{
func(c context.Context, a vocab.ActivityStreamsCreate) error {
pass = true
return nil
Expand All @@ -330,7 +330,7 @@ func TestPostInbox(t *testing.T) {
db.EXPECT().Unlock(ctx, inboxIRI),
)
pass := false
fp.EXPECT().Callbacks(ctx).Return(FederatingWrappedCallbacks{
fp.EXPECT().FederatingCallbacks(ctx).Return(FederatingWrappedCallbacks{
Create: func(c context.Context, a vocab.ActivityStreamsCreate) error {
pass = true
return nil
Expand Down Expand Up @@ -857,7 +857,7 @@ func TestPostOutbox(t *testing.T) {
db.EXPECT().SetOutbox(ctx, testOrderedCollectionWithNewId).Return(nil),
db.EXPECT().Unlock(ctx, outboxIRI),
)
sp.EXPECT().Callbacks(ctx).Return(SocialWrappedCallbacks{}, nil, nil)
sp.EXPECT().SocialCallbacks(ctx).Return(SocialWrappedCallbacks{}, nil, nil)
sp.EXPECT().DefaultCallback(ctx, testMyListen).Return(nil)
// Run
deliverable, err := a.PostOutbox(ctx, testMyListen, outboxIRI, mustSerialize(testMyListen))
Expand All @@ -880,7 +880,7 @@ func TestPostOutbox(t *testing.T) {
db.EXPECT().SetOutbox(ctx, testOrderedCollectionWithBothNewIds).Return(nil),
db.EXPECT().Unlock(ctx, outboxIRI),
)
sp.EXPECT().Callbacks(ctx).Return(SocialWrappedCallbacks{}, nil, nil)
sp.EXPECT().SocialCallbacks(ctx).Return(SocialWrappedCallbacks{}, nil, nil)
sp.EXPECT().DefaultCallback(ctx, testMyListen).Return(nil)
// Run
deliverable, err := a.PostOutbox(ctx, testMyListen, outboxIRI, mustSerialize(testMyListen))
Expand All @@ -904,7 +904,7 @@ func TestPostOutbox(t *testing.T) {
db.EXPECT().Unlock(ctx, outboxIRI),
)
pass := false
sp.EXPECT().Callbacks(ctx).Return(SocialWrappedCallbacks{}, []interface{}{
sp.EXPECT().SocialCallbacks(ctx).Return(SocialWrappedCallbacks{}, []interface{}{
func(c context.Context, a vocab.ActivityStreamsListen) error {
pass = true
return nil
Expand Down Expand Up @@ -933,7 +933,7 @@ func TestPostOutbox(t *testing.T) {
db.EXPECT().Unlock(ctx, outboxIRI),
)
pass := false
sp.EXPECT().Callbacks(ctx).Return(SocialWrappedCallbacks{}, []interface{}{
sp.EXPECT().SocialCallbacks(ctx).Return(SocialWrappedCallbacks{}, []interface{}{
func(c context.Context, a vocab.ActivityStreamsCreate) error {
pass = true
return nil
Expand Down Expand Up @@ -962,7 +962,7 @@ func TestPostOutbox(t *testing.T) {
db.EXPECT().Unlock(ctx, outboxIRI),
)
pass := false
sp.EXPECT().Callbacks(ctx).Return(SocialWrappedCallbacks{
sp.EXPECT().SocialCallbacks(ctx).Return(SocialWrappedCallbacks{
Create: func(c context.Context, a vocab.ActivityStreamsCreate) error {
pass = true
return nil
Expand Down
6 changes: 3 additions & 3 deletions pub/social_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ type SocialProtocol interface {
// authenticated must be true and error nil. The request will continue
// to be processed.
AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (out context.Context, authenticated bool, err error)
// Callbacks returns the application logic that handles ActivityStreams
// received from C2S clients.
// SocialCallbacks returns the application logic that handles
// ActivityStreams received from C2S clients.
//
// Note that certain types of callbacks will be 'wrapped' with default
// behaviors supported natively by the library. Other callbacks
Expand All @@ -70,7 +70,7 @@ type SocialProtocol interface {
//
// Applications are not expected to handle every single ActivityStreams
// type and extension. The unhandled ones are passed to DefaultCallback.
Callbacks(c context.Context) (wrapped SocialWrappedCallbacks, other []interface{}, err error)
SocialCallbacks(c context.Context) (wrapped SocialWrappedCallbacks, other []interface{}, err error)
// DefaultCallback is called for types that go-fed can deserialize but
// are not handled by the application's callbacks returned in the
// Callbacks method.
Expand Down

0 comments on commit c2285ce

Please sign in to comment.