[AP] Prevent postman to include the actor's followers for every sent activity
This commit is contained in:
parent
738f9cb89c
commit
13d7c3debe
|
@ -56,17 +56,7 @@ class Activitypub_postman
|
||||||
public function __construct(Profile $from, array $to)
|
public function __construct(Profile $from, array $to)
|
||||||
{
|
{
|
||||||
$this->actor = $from;
|
$this->actor = $from;
|
||||||
$discovery = new Activitypub_explorer();
|
|
||||||
$this->to = $to;
|
$this->to = $to;
|
||||||
$followers = apActorFollowersAction::generate_followers($this->actor, 0, null);
|
|
||||||
foreach ($followers as $sub) {
|
|
||||||
try {
|
|
||||||
$this->to[]= Activitypub_profile::from_profile($discovery->lookup($sub)[0]);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
// Not an ActivityPub Remote Follower, let it go
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($discovery);
|
|
||||||
|
|
||||||
$this->actor_uri = ActivityPubPlugin::actor_uri($this->actor);
|
$this->actor_uri = ActivityPubPlugin::actor_uri($this->actor);
|
||||||
|
|
||||||
|
@ -317,7 +307,7 @@ class Activitypub_postman
|
||||||
);
|
);
|
||||||
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
|
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
|
||||||
|
|
||||||
foreach ($this->to_inbox() as $inbox) {
|
foreach ($this->to_inbox(false) as $inbox) {
|
||||||
$res = $this->send($data, $inbox);
|
$res = $this->send($data, $inbox);
|
||||||
|
|
||||||
// accummulate errors for later use, if needed
|
// accummulate errors for later use, if needed
|
||||||
|
@ -397,10 +387,24 @@ class Activitypub_postman
|
||||||
* Clean list of inboxes to deliver messages
|
* Clean list of inboxes to deliver messages
|
||||||
*
|
*
|
||||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||||
|
* @param bool $actorFollowers whether to include the actor's follower collection
|
||||||
* @return array To Inbox URLs
|
* @return array To Inbox URLs
|
||||||
*/
|
*/
|
||||||
private function to_inbox(): array
|
private function to_inbox(bool $actorFollowers = true): array
|
||||||
{
|
{
|
||||||
|
if ($actorFollowers) {
|
||||||
|
$discovery = new Activitypub_explorer();
|
||||||
|
$followers = apActorFollowersAction::generate_followers($this->actor, 0, null);
|
||||||
|
foreach ($followers as $sub) {
|
||||||
|
try {
|
||||||
|
$this->to[]= Activitypub_profile::from_profile($discovery->lookup($sub)[0]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Not an ActivityPub Remote Follower, let it go
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($discovery);
|
||||||
|
}
|
||||||
|
|
||||||
$to_inboxes = [];
|
$to_inboxes = [];
|
||||||
foreach ($this->to as $to_profile) {
|
foreach ($this->to as $to_profile) {
|
||||||
$i = $to_profile->get_inbox();
|
$i = $to_profile->get_inbox();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user