Commit 07e6bc25 authored by Zot's avatar Zot

merge conflicts

parent 63407599
......@@ -25,8 +25,7 @@ class Inbox extends \Zotlabs\Web\Controller {
if(! $data)
return;
logger('inbox_activity: ' . $data, LOGGER_DATA);
logger('inbox_activity: ' . jindent($data), LOGGER_DATA);
$AS = new \ActivityStreams($data);
......@@ -95,19 +94,10 @@ class Inbox extends \Zotlabs\Web\Controller {
}
}
function get() {
// logger('config: ' . print_r(\App::$config,true));
}
}
......
......@@ -275,10 +275,11 @@ function pubcrawl_notifier_process(&$arr) {
if(! $arr['normal_mode'])
continue;
$qi = pubcrawl_queue_message($jmsg,$arr['channel'],$contact,$target_item['mid']);
if($qi)
$arr['queued'][] = $qi;
if($single) {
$qi = pubcrawl_queue_message($jmsg,$arr['channel'],$contact,$target_item['mid']);
if($qi)
$arr['queued'][] = $qi;
}
continue;
}
......@@ -289,10 +290,13 @@ function pubcrawl_notifier_process(&$arr) {
$contact = $arr['hub'];
$qi = pubcrawl_queue_message($jmsg,$arr['channel'],$contact,$target_item['mid']);
if($qi)
$arr['queued'][] = $qi;
$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;
}
......@@ -391,162 +395,6 @@ function pubcrawl_permissions_create(&$x) {
}
function pubcrawl_notifier_process(&$arr) {
if($arr['hub']['hubloc_network'] !== 'activitypub')
return;
logger('upstream: ' . intval($arr['upstream']));
// logger('notifier_array: ' . print_r($arr,true), LOGGER_ALL, LOG_INFO);
// allow this to be set per message
if($arr['mail']) {
logger('Cannot send mail to activitypub.');
return;
}
$allowed = get_pconfig($arr['channel']['channel_id'],'system','activitypub_allowed');
if(! intval($allowed)) {
logger('pubcrawl: disallowed for channel ' . $arr['channel']['channel_name']);
return;
}
if($arr['location'])
return;
if(array_key_exists('target_item',$arr) && is_array($arr['target_item'])) {
if(intval($arr['target_item']['item_obscured'])) {
logger('Cannot send raw data as an activitypub activity.');
return;
}
if(strpos($arr['target_item']['postopts'],'nopub') !== false) {
return;
}
}
$target_item = $arr['target_item'];
$prv_recips = $arr['env_recips'];
$msg = array_merge(['@context' => [
'https://www.w3.org/ns/activitystreams',
[ 'me' => 'http://salmon-protocol.org/ns/magic-env' ],
[ 'zot' => 'http://purl.org/zot/protocol' ]
]], asencode_activity($target_item));
$jmsg = json_encode($msg);
if($prv_recips) {
$hashes = array();
// re-explode the recipients, but only for this hub/pod
foreach($prv_recips as $recip)
$hashes[] = "'" . $recip['hash'] . "'";
$r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url = '%s'
and xchan_hash in (" . implode(',', $hashes) . ") and xchan_network = 'activitypub' ",
dbesc($arr['hub']['hubloc_url'])
);
if(! $r) {
logger('activitypub_process_outbound: no recipients');
return;
}
foreach($r as $contact) {
// is $contact connected with this channel - and if the channel is cloned, also on this hub?
$single = deliverable_singleton($arr['channel']['channel_id'],$contact);
if(! $arr['normal_mode'])
continue;
$qi = pubcrawl_queue_message($jmsg,$arr['channel'],$contact,$target_item['mid']);
if($qi)
$arr['queued'][] = $qi;
continue;
}
}
else {
// public message
$contact = $arr['hub'];
$qi = pubcrawl_queue_message($jmsg,$arr['channel'],$contact,$target_item['mid']);
if($qi)
$arr['queued'][] = $qi;
return;
}
}
function pubcrawl_queue_message($msg,$sender,$recip,$message_id = '') {
$allowed = get_pconfig($sender['channel_id'],'system','activitypub_allowed',1);
if(! intval($allowed)) {
return false;
}
// if($public_batch)
// $dest_url = $recip['hubloc_callback'] . '/public';
// else
$dest_url = $recip['hubloc_callback'];
logger('URL: ' . $dest_url, LOGGER_DEBUG);
if(intval(get_config('system','activitypub_test')) || intval(get_pconfig($sender['channel_id'],'system','activitypub_test'))) {
logger('test mode - delivery disabled');
return false;
}
$hash = random_string();
logger('queue: ' . $hash . ' ' . $dest_url, LOGGER_DEBUG);
queue_insert(array(
'hash' => $hash,
'account_id' => $sender['channel_account_id'],
'channel_id' => $sender['channel_id'],
'driver' => 'pubcrawl',
'posturl' => $dest_url,
'notify' => '',
'msg' => $msg
));
if($message_id && (! get_config('system','disable_dreport'))) {
q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan, dreport_queue ) values ( '%s','%s','%s','%s','%s','%s','%s' ) ",
dbesc($message_id),
dbesc($dest_url),
dbesc($dest_url),
dbesc('queued'),
dbesc(datetime_convert()),
dbesc($sender['channel_hash']),
dbesc($hash)
);
}
return $hash;
}
function pubcrawl_profile_mod_init($x) {
if(pubcrawl_is_as_request()) {
......
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