Rename Callbacks to disambiguate between S2S & C2S

This commit is contained in:
Cory Slep 2020-07-06 19:41:49 +02:00
parent 0430970bd3
commit c2285ceec2
6 changed files with 32 additions and 32 deletions

View File

@ -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
@ -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.

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: pub/federating_protocol.go
// Source: federating_protocol.go
// Package pub is a generated GoMock package.
package pub
@ -82,20 +82,20 @@ func (mr *MockFederatingProtocolMockRecorder) Blocked(c, actorIRIs interface{})
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Blocked", reflect.TypeOf((*MockFederatingProtocol)(nil).Blocked), c, actorIRIs)
}
// Callbacks mocks base method
func (m *MockFederatingProtocol) Callbacks(c context.Context) (FederatingWrappedCallbacks, []interface{}, error) {
// FederatingCallbacks mocks base method
func (m *MockFederatingProtocol) FederatingCallbacks(c context.Context) (FederatingWrappedCallbacks, []interface{}, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Callbacks", c)
ret := m.ctrl.Call(m, "FederatingCallbacks", c)
ret0, _ := ret[0].(FederatingWrappedCallbacks)
ret1, _ := ret[1].([]interface{})
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// Callbacks indicates an expected call of Callbacks
func (mr *MockFederatingProtocolMockRecorder) Callbacks(c interface{}) *gomock.Call {
// FederatingCallbacks indicates an expected call of FederatingCallbacks
func (mr *MockFederatingProtocolMockRecorder) FederatingCallbacks(c interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Callbacks", reflect.TypeOf((*MockFederatingProtocol)(nil).Callbacks), c)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FederatingCallbacks", reflect.TypeOf((*MockFederatingProtocol)(nil).FederatingCallbacks), c)
}
// DefaultCallback mocks base method

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: pub/social_protocol.go
// Source: social_protocol.go
// Package pub is a generated GoMock package.
package pub
@ -66,20 +66,20 @@ func (mr *MockSocialProtocolMockRecorder) AuthenticatePostOutbox(c, w, r interfa
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthenticatePostOutbox", reflect.TypeOf((*MockSocialProtocol)(nil).AuthenticatePostOutbox), c, w, r)
}
// Callbacks mocks base method
func (m *MockSocialProtocol) Callbacks(c context.Context) (SocialWrappedCallbacks, []interface{}, error) {
// SocialCallbacks mocks base method
func (m *MockSocialProtocol) SocialCallbacks(c context.Context) (SocialWrappedCallbacks, []interface{}, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Callbacks", c)
ret := m.ctrl.Call(m, "SocialCallbacks", c)
ret0, _ := ret[0].(SocialWrappedCallbacks)
ret1, _ := ret[1].([]interface{})
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// Callbacks indicates an expected call of Callbacks
func (mr *MockSocialProtocolMockRecorder) Callbacks(c interface{}) *gomock.Call {
// SocialCallbacks indicates an expected call of SocialCallbacks
func (mr *MockSocialProtocolMockRecorder) SocialCallbacks(c interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Callbacks", reflect.TypeOf((*MockSocialProtocol)(nil).Callbacks), c)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SocialCallbacks", reflect.TypeOf((*MockSocialProtocol)(nil).SocialCallbacks), c)
}
// DefaultCallback mocks base method

View File

@ -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
}
@ -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
}

View File

@ -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)
@ -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)
@ -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
@ -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
@ -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
@ -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))
@ -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))
@ -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
@ -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
@ -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

View File

@ -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
@ -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.