add individual message delivery reporting
This commit is contained in:
parent
8d32477bff
commit
f2a4ea7254
@ -672,7 +672,7 @@ function zot_fetch($arr) {
|
|||||||
$fetch = zot_zot($url,$datatosend);
|
$fetch = zot_zot($url,$datatosend);
|
||||||
|
|
||||||
$result = zot_import($fetch);
|
$result = zot_import($fetch);
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -741,7 +741,7 @@ function zot_import($arr) {
|
|||||||
logger('Activity recipients: ' . print_r($deliveries,true));
|
logger('Activity recipients: ' . print_r($deliveries,true));
|
||||||
|
|
||||||
$relay = ((array_key_exists('flags',$i['message']) && in_array('relay',$i['message']['flags'])) ? true : false);
|
$relay = ((array_key_exists('flags',$i['message']) && in_array('relay',$i['message']['flags'])) ? true : false);
|
||||||
process_delivery($i['notify']['sender'],$arr,$deliveries,$relay);
|
$result = process_delivery($i['notify']['sender'],$arr,$deliveries,$relay);
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif($i['message']['type'] === 'mail') {
|
elseif($i['message']['type'] === 'mail') {
|
||||||
@ -751,7 +751,7 @@ function zot_import($arr) {
|
|||||||
logger('Mail recipients: ' . print_r($deliveries,true));
|
logger('Mail recipients: ' . print_r($deliveries,true));
|
||||||
|
|
||||||
|
|
||||||
process_mail_delivery($i['notify']['sender'],$arr,$deliveries);
|
$result = process_mail_delivery($i['notify']['sender'],$arr,$deliveries);
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif($i['message']['type'] === 'profile') {
|
elseif($i['message']['type'] === 'profile') {
|
||||||
@ -760,12 +760,15 @@ function zot_import($arr) {
|
|||||||
logger('Profile received: ' . print_r($arr,true));
|
logger('Profile received: ' . print_r($arr,true));
|
||||||
logger('Profile recipients: ' . print_r($deliveries,true));
|
logger('Profile recipients: ' . print_r($deliveries,true));
|
||||||
|
|
||||||
process_profile_delivery($i['notify']['sender'],$arr,$deliveries);
|
$result = process_profile_delivery($i['notify']['sender'],$arr,$deliveries);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -827,27 +830,32 @@ function public_recips($msg) {
|
|||||||
|
|
||||||
function process_delivery($sender,$arr,$deliveries,$relay) {
|
function process_delivery($sender,$arr,$deliveries,$relay) {
|
||||||
|
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
|
||||||
foreach($deliveries as $d) {
|
foreach($deliveries as $d) {
|
||||||
$r = q("select * from channel where channel_hash = '%s' limit 1",
|
$r = q("select * from channel where channel_hash = '%s' limit 1",
|
||||||
dbesc($d['hash'])
|
dbesc($d['hash'])
|
||||||
);
|
);
|
||||||
|
|
||||||
if(! $r)
|
if(! $r) {
|
||||||
|
$result[] = array($d['hash'],'not found');
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
$channel = $r[0];
|
$channel = $r[0];
|
||||||
|
|
||||||
$perm = (($arr['uri'] == $arr['parent_uri']) ? 'send_stream' : 'post_comments');
|
$perm = (($arr['uri'] == $arr['parent_uri']) ? 'send_stream' : 'post_comments');
|
||||||
|
|
||||||
if(! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) {
|
if(! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) {
|
||||||
logger("permission denied for delivery {$channel['channel_id']}");
|
logger("permission denied for delivery {$channel['channel_id']}");
|
||||||
|
$result[] = array($d['hash'],'permission denied');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($arr['item_restrict'] & ITEM_DELETED) {
|
if($arr['item_restrict'] & ITEM_DELETED) {
|
||||||
delete_imported_item($sender,$arr,$channel['channel_id']);
|
delete_imported_item($sender,$arr,$channel['channel_id']);
|
||||||
|
$result[] = array($d['hash'],'deleted');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -858,19 +866,23 @@ function process_delivery($sender,$arr,$deliveries,$relay) {
|
|||||||
if($r) {
|
if($r) {
|
||||||
if($arr['edited'] > $r[0]['edited'])
|
if($arr['edited'] > $r[0]['edited'])
|
||||||
update_imported_item($sender,$arr,$channel['channel_id']);
|
update_imported_item($sender,$arr,$channel['channel_id']);
|
||||||
|
$result[] = array($d['hash'],'updated');
|
||||||
$item_id = $r[0]['id'];
|
$item_id = $r[0]['id'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$arr['aid'] = $channel['channel_account_id'];
|
$arr['aid'] = $channel['channel_account_id'];
|
||||||
$arr['uid'] = $channel['channel_id'];
|
$arr['uid'] = $channel['channel_id'];
|
||||||
$item_id = item_store($arr);
|
$item_id = item_store($arr);
|
||||||
|
$result[] = array($d['hash'],'posted');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($relay && $item_id) {
|
if($relay && $item_id) {
|
||||||
logger('process_delivery: invoking relay');
|
logger('process_delivery: invoking relay');
|
||||||
proc_run('php','include/notifier.php','relay',intval($item_id));
|
proc_run('php','include/notifier.php','relay',intval($item_id));
|
||||||
|
$result[] = array($d['hash'],'relayed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,13 +151,13 @@ function post_post(&$a) {
|
|||||||
if($msgtype === 'notify') {
|
if($msgtype === 'notify') {
|
||||||
$async = get_config('system','queued_fetch');
|
$async = get_config('system','queued_fetch');
|
||||||
|
|
||||||
|
|
||||||
if($async) {
|
if($async) {
|
||||||
// add to receive queue
|
// add to receive queue
|
||||||
// qreceive_add($data);
|
// qreceive_add($data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$x = zot_fetch($data);
|
$x = zot_fetch($data);
|
||||||
|
$ret['delivery_report'] = $x;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret['result'] = true;
|
$ret['result'] = true;
|
||||||
|
Reference in New Issue
Block a user