diff --git a/pub/fed.go b/pub/fed.go index 60f24ab..1d3640d 100644 --- a/pub/fed.go +++ b/pub/fed.go @@ -929,7 +929,6 @@ func (f *federator) handleDelete(c context.Context) func(s *streams.Delete) erro } } -// TODO: Only Set IRIs func (f *federator) handleFollow(c context.Context, inboxURL *url.URL) func(s *streams.Follow) error { return func(s *streams.Follow) error { // Permit either human-triggered or automatically triggering @@ -948,13 +947,23 @@ func (f *federator) handleFollow(c context.Context, inboxURL *url.URL) func(s *s raw := s.Raw() activity.AppendObject(raw) for i := 0; i < raw.ActorLen(); i++ { + var to *url.URL if raw.IsActorObject(i) { - activity.AppendToObject(raw.GetActorObject(i)) + obj := raw.GetActorObject(i) + if !obj.HasId() { + return fmt.Errorf("to object missing id") + } + to = obj.GetId() } else if raw.IsActorLink(i) { - activity.AppendToLink(raw.GetActorLink(i)) + href := raw.GetActorLink(i) + if !href.HasHref() { + return fmt.Errorf("to link missing href") + } + to = href.GetHref() } else if raw.IsActorIRI(i) { - activity.AppendToIRI(raw.GetActorIRI(i)) + to = raw.GetActorIRI(i) } + activity.AppendToIRI(to) } ownsAny := false if todo == AutomaticAccept { diff --git a/pub/fed_test.go b/pub/fed_test.go index f71ead5..c27a501 100644 --- a/pub/fed_test.go +++ b/pub/fed_test.go @@ -2556,7 +2556,7 @@ func TestPostInbox_Follow_AutoReject(t *testing.T) { } expected := &vocab.Reject{} expected.AppendObject(testFollow) - expected.AppendToObject(sallyActor) + expected.AppendToIRI(sallyIRI) handled, err := p.PostInbox(context.Background(), resp, req) if err != nil { t.Fatal(err) @@ -2683,7 +2683,7 @@ func TestPostInbox_Follow_AutoAccept(t *testing.T) { } expected := &vocab.Accept{} expected.AppendObject(testFollow) - expected.AppendToObject(sallyActor) + expected.AppendToIRI(sallyIRI) expectedFollowers := &vocab.Collection{} expectedFollowers.AppendItemsIRI(sallyIRI) expectedActor := &vocab.Person{}