Followers, following, likes, liked collections use IRIs.
As part of the IRI normalization effort.
このコミットが含まれているのは:
コミット
da279300a0
@ -2685,7 +2685,7 @@ func TestPostInbox_Follow_AutoAccept(t *testing.T) {
|
||||
expected.AppendObject(testFollow)
|
||||
expected.AppendToObject(sallyActor)
|
||||
expectedFollowers := &vocab.Collection{}
|
||||
expectedFollowers.AppendItemsObject(sallyActor)
|
||||
expectedFollowers.AppendItemsIRI(sallyIRI)
|
||||
expectedActor := &vocab.Person{}
|
||||
expectedActor.SetInboxAnyURI(samIRIInbox)
|
||||
expectedActor.SetId(samIRI)
|
||||
@ -2884,7 +2884,7 @@ func TestPostInbox_Follow_AutoAcceptFollowersIsOrderedCollection(t *testing.T) {
|
||||
}
|
||||
handled, err := p.PostInbox(context.Background(), resp, req)
|
||||
expectedFollowers := &vocab.OrderedCollection{}
|
||||
expectedFollowers.AppendOrderedItemsObject(sallyActor)
|
||||
expectedFollowers.AppendOrderedItemsIRI(sallyIRI)
|
||||
expectedActor := &vocab.Person{}
|
||||
expectedActor.SetInboxAnyURI(samIRIInbox)
|
||||
expectedActor.SetId(samIRI)
|
||||
@ -2972,7 +2972,7 @@ func TestPostInbox_Follow_AutoAcceptFollowersIsIRI(t *testing.T) {
|
||||
}
|
||||
handled, err := p.PostInbox(context.Background(), resp, req)
|
||||
expectedFollowers := &vocab.Collection{}
|
||||
expectedFollowers.AppendItemsObject(sallyActor)
|
||||
expectedFollowers.AppendItemsIRI(sallyIRI)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !handled {
|
||||
@ -3108,7 +3108,7 @@ func TestPostInbox_Accept_AcceptFollowAddsToFollowersIfOwned(t *testing.T) {
|
||||
return nil
|
||||
}
|
||||
expectedFollowing := &vocab.Collection{}
|
||||
expectedFollowing.AppendItemsObject(samActor)
|
||||
expectedFollowing.AppendItemsIRI(samIRI)
|
||||
expectedActor := &vocab.Person{}
|
||||
expectedActor.SetInboxAnyURI(sallyIRIInbox)
|
||||
expectedActor.SetId(sallyIRI)
|
||||
@ -3211,7 +3211,7 @@ func TestPostInbox_Accept_AcceptFollowAddsToFollowersOrderedCollection(t *testin
|
||||
return nil
|
||||
}
|
||||
expectedFollowing := &vocab.OrderedCollection{}
|
||||
expectedFollowing.AppendOrderedItemsObject(samActor)
|
||||
expectedFollowing.AppendOrderedItemsIRI(samIRI)
|
||||
expectedActor := &vocab.Person{}
|
||||
expectedActor.SetInboxAnyURI(sallyIRIInbox)
|
||||
expectedActor.SetId(sallyIRI)
|
||||
@ -3263,7 +3263,7 @@ func TestPostInbox_Accept_AcceptFollowAddsToFollowersIRI(t *testing.T) {
|
||||
return nil
|
||||
}
|
||||
expectedFollowing := &vocab.OrderedCollection{}
|
||||
expectedFollowing.AppendOrderedItemsObject(samActor)
|
||||
expectedFollowing.AppendOrderedItemsIRI(samIRI)
|
||||
handled, err := p.PostInbox(context.Background(), resp, req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -3778,7 +3778,7 @@ func TestPostInbox_Like_AddsToLikeCollection(t *testing.T) {
|
||||
}
|
||||
handled, err := p.PostInbox(context.Background(), resp, req)
|
||||
expected := &vocab.Collection{}
|
||||
expected.AppendItemsObject(sallyActor)
|
||||
expected.AppendItemsIRI(sallyIRI)
|
||||
expectedNote := &vocab.Note{}
|
||||
expectedNote.SetId(noteIRI)
|
||||
expectedNote.AppendNameString(noteName)
|
||||
@ -3882,7 +3882,7 @@ func TestPostInbox_Like_AddsToLikeOrderedCollection(t *testing.T) {
|
||||
}
|
||||
handled, err := p.PostInbox(context.Background(), resp, req)
|
||||
expected := &vocab.OrderedCollection{}
|
||||
expected.AppendOrderedItemsObject(sallyActor)
|
||||
expected.AppendOrderedItemsIRI(sallyIRI)
|
||||
expectedNote := &vocab.Note{}
|
||||
expectedNote.SetId(noteIRI)
|
||||
expectedNote.AppendNameString(noteName)
|
||||
@ -3933,7 +3933,7 @@ func TestPostInbox_Like_AddsToLikeIRI(t *testing.T) {
|
||||
}
|
||||
handled, err := p.PostInbox(context.Background(), resp, req)
|
||||
expected := &vocab.OrderedCollection{}
|
||||
expected.AppendOrderedItemsObject(sallyActor)
|
||||
expected.AppendOrderedItemsIRI(sallyIRI)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !handled {
|
||||
@ -5773,7 +5773,7 @@ func TestPostOutbox_Like_AddsToLikedCollection(t *testing.T) {
|
||||
}
|
||||
handled, err := p.PostOutbox(context.Background(), resp, req)
|
||||
expectedLikes := &vocab.Collection{}
|
||||
expectedLikes.AppendItemsObject(testNote)
|
||||
expectedLikes.AppendItemsIRI(noteIRI)
|
||||
expectedActor := &vocab.Person{}
|
||||
expectedActor.AppendNameString("Sally")
|
||||
expectedActor.SetId(sallyIRI)
|
||||
@ -5873,7 +5873,7 @@ func TestPostOutbox_Like_AddsToLikedOrderedCollection(t *testing.T) {
|
||||
}
|
||||
handled, err := p.PostOutbox(context.Background(), resp, req)
|
||||
expectedLikes := &vocab.OrderedCollection{}
|
||||
expectedLikes.AppendOrderedItemsObject(testNote)
|
||||
expectedLikes.AppendOrderedItemsIRI(noteIRI)
|
||||
expectedActor := &vocab.Person{}
|
||||
expectedActor.AppendNameString("Sally")
|
||||
expectedActor.SetId(sallyIRI)
|
||||
|
118
pub/internal.go
118
pub/internal.go
@ -1470,7 +1470,6 @@ func toTombstone(obj vocab.ObjectType, id *url.URL, now time.Time) vocab.Tombsto
|
||||
|
||||
type getActorCollectionFn func(actor vocab.ObjectType, lc *vocab.CollectionType, loc *vocab.OrderedCollectionType) (isIRI bool, e error)
|
||||
|
||||
// TODO: Only Set IRIs
|
||||
func (f *federator) addAllObjectsToActorCollection(ctx context.Context, getter getActorCollectionFn, c vocab.ActivityType, prepend bool) error {
|
||||
for i := 0; i < c.ActorLen(); i++ {
|
||||
var iri *url.URL
|
||||
@ -1522,45 +1521,30 @@ func (f *federator) addAllObjectsToActorCollection(ctx context.Context, getter g
|
||||
}
|
||||
// Add object to collection if not a duplicate
|
||||
for i := 0; i < c.ObjectLen(); i++ {
|
||||
var iri *url.URL
|
||||
if c.IsObjectIRI(i) {
|
||||
iri := c.GetObjectIRI(i)
|
||||
if iriSet[iri.String()] {
|
||||
continue
|
||||
}
|
||||
if lc != nil {
|
||||
if prepend {
|
||||
lc.PrependItemsIRI(iri)
|
||||
} else {
|
||||
lc.AppendItemsIRI(iri)
|
||||
}
|
||||
} else if loc != nil {
|
||||
if prepend {
|
||||
loc.PrependOrderedItemsIRI(iri)
|
||||
} else {
|
||||
loc.AppendOrderedItemsIRI(iri)
|
||||
}
|
||||
}
|
||||
iri = c.GetObjectIRI(i)
|
||||
} else if c.IsObject(i) {
|
||||
obj := c.GetObject(i)
|
||||
if !obj.HasId() {
|
||||
return fmt.Errorf("object at index %d has no id", i)
|
||||
}
|
||||
iri := obj.GetId()
|
||||
if iriSet[iri.String()] {
|
||||
continue
|
||||
iri = obj.GetId()
|
||||
}
|
||||
if iriSet[iri.String()] {
|
||||
continue
|
||||
}
|
||||
if lc != nil {
|
||||
if prepend {
|
||||
lc.PrependItemsIRI(iri)
|
||||
} else {
|
||||
lc.AppendItemsIRI(iri)
|
||||
}
|
||||
if lc != nil {
|
||||
if prepend {
|
||||
lc.PrependItemsObject(obj)
|
||||
} else {
|
||||
lc.AppendItemsObject(obj)
|
||||
}
|
||||
} else if loc != nil {
|
||||
if prepend {
|
||||
loc.PrependOrderedItemsObject(obj)
|
||||
} else {
|
||||
loc.AppendOrderedItemsObject(obj)
|
||||
}
|
||||
} else if loc != nil {
|
||||
if prepend {
|
||||
loc.PrependOrderedItemsIRI(iri)
|
||||
} else {
|
||||
loc.AppendOrderedItemsIRI(iri)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1582,7 +1566,6 @@ func (f *federator) addAllObjectsToActorCollection(ctx context.Context, getter g
|
||||
|
||||
type getObjectCollectionFn func(object vocab.ObjectType, lc *vocab.CollectionType, loc *vocab.OrderedCollectionType) (isIRI bool, e error)
|
||||
|
||||
// TODO: Only Set IRIs
|
||||
func (f *federator) addAllActorsToObjectCollection(ctx context.Context, getter getObjectCollectionFn, c vocab.ActivityType, prepend bool) (bool, error) {
|
||||
ownsAny := false
|
||||
for i := 0; i < c.ObjectLen(); i++ {
|
||||
@ -1630,67 +1613,36 @@ func (f *federator) addAllActorsToObjectCollection(ctx context.Context, getter g
|
||||
}
|
||||
// Add actor to collection if not a duplicate
|
||||
for i := 0; i < c.ActorLen(); i++ {
|
||||
var iri *url.URL
|
||||
if c.IsActorIRI(i) {
|
||||
iri := c.GetActorIRI(i)
|
||||
if iriSet[iri.String()] {
|
||||
continue
|
||||
}
|
||||
if lc != nil {
|
||||
if prepend {
|
||||
lc.AppendItemsIRI(iri)
|
||||
} else {
|
||||
lc.PrependItemsIRI(iri)
|
||||
}
|
||||
} else if loc != nil {
|
||||
if prepend {
|
||||
loc.PrependOrderedItemsIRI(iri)
|
||||
} else {
|
||||
loc.AppendOrderedItemsIRI(iri)
|
||||
}
|
||||
}
|
||||
iri = c.GetActorIRI(i)
|
||||
} else if c.IsActorObject(i) {
|
||||
obj := c.GetActorObject(i)
|
||||
if !obj.HasId() {
|
||||
return ownsAny, fmt.Errorf("actor object at index %d has no id", i)
|
||||
}
|
||||
iri := obj.GetId()
|
||||
if iriSet[iri.String()] {
|
||||
continue
|
||||
}
|
||||
if lc != nil {
|
||||
if prepend {
|
||||
lc.PrependItemsObject(obj)
|
||||
} else {
|
||||
lc.AppendItemsObject(obj)
|
||||
}
|
||||
} else if loc != nil {
|
||||
if prepend {
|
||||
loc.PrependOrderedItemsObject(obj)
|
||||
} else {
|
||||
loc.AppendOrderedItemsObject(obj)
|
||||
}
|
||||
}
|
||||
iri = obj.GetId()
|
||||
} else if c.IsActorLink(i) {
|
||||
l := c.GetActorLink(i)
|
||||
if !l.HasHref() {
|
||||
return ownsAny, fmt.Errorf("actor link at index %d has no id", i)
|
||||
}
|
||||
iri := l.GetHref()
|
||||
if iriSet[iri.String()] {
|
||||
continue
|
||||
iri = l.GetHref()
|
||||
}
|
||||
if iriSet[iri.String()] {
|
||||
continue
|
||||
}
|
||||
if lc != nil {
|
||||
if prepend {
|
||||
lc.AppendItemsIRI(iri)
|
||||
} else {
|
||||
lc.PrependItemsIRI(iri)
|
||||
}
|
||||
if lc != nil {
|
||||
if prepend {
|
||||
lc.PrependItemsLink(l)
|
||||
} else {
|
||||
lc.AppendItemsLink(l)
|
||||
}
|
||||
} else if loc != nil {
|
||||
if prepend {
|
||||
loc.PrependOrderedItemsLink(l)
|
||||
} else {
|
||||
loc.AppendOrderedItemsLink(l)
|
||||
}
|
||||
} else if loc != nil {
|
||||
if prepend {
|
||||
loc.PrependOrderedItemsIRI(iri)
|
||||
} else {
|
||||
loc.AppendOrderedItemsIRI(iri)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
読み込み中…
新しいイシューから参照
ユーザーをブロックする