Bugfix for programmatic delivery

このコミットが含まれているのは:
Cory Slep 2019-04-03 23:35:57 +02:00
コミット ca18901fcc
3個のファイルの変更36行の追加26行の削除

ファイルの表示

@ -1,8 +1,8 @@
package pub
import (
"github.com/go-fed/activity/streams/vocab"
"context"
"github.com/go-fed/activity/streams/vocab"
"net/http"
"net/url"
)
@ -102,9 +102,9 @@ type FederatingActor interface {
// The provided url must be the outbox of the sender. All processing of
// the activity occurs similarly to the C2S flow:
// - If t is not an Activity, it is wrapped in a Create activity.
// - A new ID is generated for the activity
// - The activity is added to the specified outbox
// - The activity is prepared and delivered to recipients
// - A new ID is generated for the activity.
// - The activity is added to the specified outbox.
// - The activity is prepared and delivered to recipients.
//
// Note that this function will only behave as expected if the
// implementation has been constructed to support federation. This

ファイルの表示

@ -115,7 +115,9 @@ type DelegateActor interface {
// PostOutbox delegates the logic for side effects and adding to the
// outbox.
//
// Only called if the Social API is enabled.
// Always called, regardless whether the Federated Protocol or Social
// API is enabled. In the case of the Social API being enabled, side
// effects of the Activity must occur.
//
// The delegate is responsible for adding the activity to the database's
// general storage for independent retrieval, and not just within the

ファイルの表示

@ -63,6 +63,10 @@ func (a *sideEffectActor) GetInbox(c context.Context, r *http.Request) (vocab.Ac
func (a *sideEffectActor) AuthorizePostInbox(c context.Context, w http.ResponseWriter, activity Activity) (authorized bool, err error) {
authorized = false
actor := activity.GetActivityStreamsActor()
if actor == nil {
err = fmt.Errorf("no actors in post to inbox")
return
}
var iris []*url.URL
for i := 0; i < actor.Len(); i++ {
iter := actor.At(i)
@ -299,30 +303,34 @@ func (a *sideEffectActor) InboxForwarding(c context.Context, inboxIRI *url.URL,
// This implementation assumes all types are meant to be delivered except for
// the ActivityStreams Block type.
func (a *sideEffectActor) PostOutbox(c context.Context, activity Activity, outboxIRI *url.URL, rawJSON map[string]interface{}) (deliverable bool, err error) {
wrapped, other := a.c2s.Callbacks(c)
// Populate side channels.
wrapped.db = a.db
wrapped.outboxIRI = outboxIRI
wrapped.rawActivity = rawJSON
wrapped.clock = a.clock
wrapped.newTransport = a.common.NewTransport
undeliverable := false
wrapped.undeliverable = &undeliverable
var res *streams.TypeResolver
res, err = streams.NewTypeResolver(wrapped.callbacks(other)...)
if err != nil {
return
}
if err = res.Resolve(c, activity); err != nil && !streams.IsUnmatchedErr(err) {
return
} else if streams.IsUnmatchedErr(err) {
deliverable = true
err = a.c2s.DefaultCallback(c, activity)
// TODO: Determine this if c2s is nil
deliverable = true
if a.c2s != nil {
wrapped, other := a.c2s.Callbacks(c)
// Populate side channels.
wrapped.db = a.db
wrapped.outboxIRI = outboxIRI
wrapped.rawActivity = rawJSON
wrapped.clock = a.clock
wrapped.newTransport = a.common.NewTransport
undeliverable := false
wrapped.undeliverable = &undeliverable
var res *streams.TypeResolver
res, err = streams.NewTypeResolver(wrapped.callbacks(other)...)
if err != nil {
return
}
} else {
deliverable = !undeliverable
if err = res.Resolve(c, activity); err != nil && !streams.IsUnmatchedErr(err) {
return
} else if streams.IsUnmatchedErr(err) {
deliverable = true
err = a.c2s.DefaultCallback(c, activity)
if err != nil {
return
}
} else {
deliverable = !undeliverable
}
}
err = a.addToOutbox(c, outboxIRI, activity)
return