Commit 7962cc49 authored by Zot's avatar Zot

use the sharedInbox if it exists for public messages

parent a2c3ce6a
......@@ -783,12 +783,12 @@ function as_actor_store($url,$person_obj) {
$collections['inbox'] = $inbox;
if($person_obj['outbox'])
$collections['outbox'] = $person_obj['outbox'];
if($person_obj['sharedInbox'])
$collections['sharedInbox'] = $person_obj['sharedInbox'];
if($person_obj['followers'])
$collections['followers'] = $person_obj['followers'];
if($person_obj['following'])
$collections['following'] = $person_obj['following'];
if($person_obj['endpoints'] && $person_obj['endpoints']['sharedInbox'])
$collections['sharedInbox'] = $person_obj['endpoints']['sharedInbox'];
}
if(array_key_exists('publicKey',$person_obj) && array_key_exists('publicKeyPem',$person_obj['publicKey'])) {
......
......@@ -301,6 +301,7 @@ function pubcrawl_notifier_process(&$arr) {
$jmsg = json_encode($msg);
if($prv_recips) {
$hashes = array();
......@@ -340,25 +341,43 @@ function pubcrawl_notifier_process(&$arr) {
// public message
$r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url = '%s' and xchan_network = 'activitypub' ",
dbesc($arr['hub']['hubloc_url'])
);
// See if we can deliver all of them at once
if(! $r) {
logger('activitypub_process_outbound: no recipients');
return;
$x = get_xconfig($arr['hub']['hubloc_hash'],'activitypub','collections');
if($x && $x['sharedInbox']) {
logger('using publicInbox delivery for ' . $arr['hub']['hubloc_url'], LOGGER_DEBUG);
$contact['hubloc_callback'] = $x['sharedInbox'];
$qi = pubcrawl_queue_message($jmsg,$arr['channel'],$contact,$target_item['mid']);
if($qi) {
$arr['queued'][] = $qi;
}
}
else {
foreach($r as $contact) {
$single = deliverable_singleton($arr['channel']['channel_id'],$contact);
$r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url = '%s' and xchan_network = 'activitypub' ",
dbesc($arr['hub']['hubloc_url'])
);
if($single) {
$qi = pubcrawl_queue_message($jmsg,$arr['channel'],$contact,$target_item['mid']);
if($qi)
$arr['queued'][] = $qi;
if(! $r) {
logger('activitypub_process_outbound: no recipients');
return;
}
}
foreach($r as $contact) {
$single = deliverable_singleton($arr['channel']['channel_id'],$contact);
if($single) {
$qi = pubcrawl_queue_message($jmsg,$arr['channel'],$contact,$target_item['mid']);
if($qi)
$arr['queued'][] = $qi;
}
}
}
}
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment