Commit 3252b0e5 authored by Mario's avatar Mario

deliver comments on public AP items to abook contacts

parent d73d572c
......@@ -34,6 +34,7 @@ function pubcrawl_load() {
'permissions_create' => 'pubcrawl_permissions_create',
'permissions_accept' => 'pubcrawl_permissions_accept',
'connection_remove' => 'pubcrawl_connection_remove',
'notifier_process' => 'pubcrawl_notifier_process',
'notifier_hub' => 'pubcrawl_notifier_hub',
'channel_links' => 'pubcrawl_channel_links',
'personal_xrd' => 'pubcrawl_personal_xrd',
......@@ -396,6 +397,47 @@ function pubcrawl_channel_mod_init($x) {
}
}
function pubcrawl_notifier_process(&$arr) {
//add additional recipients to public comments on AP posts
if($arr['cmd'] !== 'comment-new')
return;
if($arr['target_item']['item_private'])
return;
if($arr['parent_item']['owner']['xchan_network'] !== 'activitypub')
return;
if($arr['parent_item']['author']['xchan_network'] !== 'activitypub')
return;
if($arr['target_item']['id'] == $arr['target_item']['parent'])
return;
if(! Apps::addon_app_installed($arr['channel']['channel_id'],'pubcrawl'))
return;
$x = [];
$r = q("select abook_xchan, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 and abook_pending = 0 and abook_archived = 0 and not abook_xchan in ( '%s', '%s', '%s' ) ",
intval($arr['target_item']['uid']),
dbesc($arr['target_item']['author_xchan']),
dbesc($arr['target_item']['owner_xchan']),
dbesc($arr['target_item']['source_xchan'])
);
if($r) {
foreach($r as $rv) {
$x[] = $rv['abook_xchan'];
}
$sys = get_sys_channel();
$x[] = $sys['channel_hash'];
stringify_array_elms($x);
}
$arr['recipients'] = array_unique(array_merge($arr['recipients'], $x));
}
function pubcrawl_notifier_hub(&$arr) {
if($arr['hub']['hubloc_network'] !== 'activitypub')
......
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