Changes
4 changed files (+64/-7)
-
-
@@ -458,3 +458,15 @@ func IntransitiveActivityNew(id ObjectID, _type ActivityVocabularyType) *Intransreturn &IntransitiveActivity{apObject: o} } func (a *Activity) RecipientsDeduplication() { var actor ObjectsArr actor.Append(a.Actor) recipientsDeduplication(&actor, &a.To, &a.CC, &a.BCC) } func (i *IntransitiveActivity) RecipientsDeduplication() { var actor ObjectsArr actor.Append(i.Actor) recipientsDeduplication(&actor, &i.To, &i.CC, &i.BCC) }
-
-
-
@@ -276,8 +276,8 @@ func (c *ObjectsArr) Append(o ObjectOrLink) error {return nil } // RecipientsDeduplication normalizes the received recipient lists func RecipientsDeduplication(recArgs ...*ObjectsArr) error { // recipientsDeduplication normalizes the received recipient lists func recipientsDeduplication(recArgs ...*ObjectsArr) error { recIds := make([]ObjectID, 0) for _, recList := range recArgs {
-
-
-
@@ -176,7 +176,7 @@ func TestRecipientsDeduplication(t *testing.T) {t.Errorf("Objects array should have exactly 8(eight) elements, not %d", len(first)) } RecipientsDeduplication(&first) recipientsDeduplication(&first) if len(first) != 4 { t.Errorf("Objects array should have exactly 4(four) elements, not %d", len(first)) }
-
@@ -185,7 +185,7 @@ func TestRecipientsDeduplication(t *testing.T) {second.Append(bar) second.Append(foo) RecipientsDeduplication(&first, &second) recipientsDeduplication(&first, &second) if len(first) != 4 { t.Errorf("First Objects array should have exactly 8(eight) elements, not %d", len(first)) }
-
@@ -193,7 +193,7 @@ func TestRecipientsDeduplication(t *testing.T) {t.Errorf("Second Objects array should have exactly 0(zero) elements, not %d", len(second)) } err := RecipientsDeduplication(&first, &second, nil) err := recipientsDeduplication(&first, &second, nil) if err != nil { t.Errorf("Deduplication with empty array failed") }
-
-
-
@@ -150,7 +150,7 @@ S2S Server: Deduplication of recipient listc.CC.Append(cc) c.BCC.Append(cc) activitypub.RecipientsDeduplication(&c.To, &c.Bto, &c.CC, &c.BCC) c.RecipientsDeduplication() checkDedup := func(list activitypub.ObjectsArr, recIds *[]activitypub.ObjectID) error { for _, rec := range list {
-
@@ -194,7 +194,52 @@ S2S Server: Do-not-deliver considerationsServer does not deliver to recipients which are the same as the actor of the Activity being notified about ` t.Skip(desc) t.Log(desc) p := activitypub.PersonNew("main actor") to := activitypub.PersonNew("bob") o := activitypub.ObjectNew("something", activitypub.ArticleType) cc := activitypub.PersonNew("alice") c := activitypub.CreateNew("create", o) c.Actor = activitypub.Actor(*p) c.To.Append(p) c.To.Append(to) c.CC.Append(cc) c.CC.Append(p) c.BCC.Append(cc) c.BCC.Append(p) c.RecipientsDeduplication() checkActor := func(list activitypub.ObjectsArr, actor activitypub.Actor) error { for _, rec := range list { if rec.Object().ID == actor.Object().ID { return fmt.Errorf("%T[%s] Actor of activity should not be in the recipients list", rec, actor.Object().ID) } } return nil } var err error err = checkActor(c.To, c.Actor) if err != nil { t.Error(err) } err = checkActor(c.Bto, c.Actor) if err != nil { t.Error(err) } err = checkActor(c.CC, c.Actor) if err != nil { t.Error(err) } err = checkActor(c.BCC, c.Actor) if err != nil { t.Error(err) } } // S2S Server: Do-not-deliver considerations
-