From f2a4ea7254ba36329f84d0ffb07d3012a8526376 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 31 Dec 2012 21:33:11 -0800 Subject: add individual message delivery reporting --- include/zot.php | 24 ++++++++++++++++++------ mod/post.php | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/zot.php b/include/zot.php index 3a06366f6..5e64e79da 100644 --- a/include/zot.php +++ b/include/zot.php @@ -672,7 +672,7 @@ function zot_fetch($arr) { $fetch = zot_zot($url,$datatosend); $result = zot_import($fetch); - + return $result; } @@ -741,7 +741,7 @@ function zot_import($arr) { logger('Activity recipients: ' . print_r($deliveries,true)); $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') { @@ -751,7 +751,7 @@ function zot_import($arr) { 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') { @@ -760,12 +760,15 @@ function zot_import($arr) { logger('Profile received: ' . print_r($arr,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) { + + $result = array(); foreach($deliveries as $d) { $r = q("select * from channel where channel_hash = '%s' limit 1", dbesc($d['hash']) ); - if(! $r) + if(! $r) { + $result[] = array($d['hash'],'not found'); continue; - + } $channel = $r[0]; $perm = (($arr['uri'] == $arr['parent_uri']) ? 'send_stream' : 'post_comments'); if(! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) { logger("permission denied for delivery {$channel['channel_id']}"); + $result[] = array($d['hash'],'permission denied'); continue; } if($arr['item_restrict'] & ITEM_DELETED) { delete_imported_item($sender,$arr,$channel['channel_id']); + $result[] = array($d['hash'],'deleted'); continue; } @@ -858,19 +866,23 @@ function process_delivery($sender,$arr,$deliveries,$relay) { if($r) { if($arr['edited'] > $r[0]['edited']) update_imported_item($sender,$arr,$channel['channel_id']); + $result[] = array($d['hash'],'updated'); $item_id = $r[0]['id']; } else { $arr['aid'] = $channel['channel_account_id']; $arr['uid'] = $channel['channel_id']; $item_id = item_store($arr); + $result[] = array($d['hash'],'posted'); } if($relay && $item_id) { logger('process_delivery: invoking relay'); proc_run('php','include/notifier.php','relay',intval($item_id)); + $result[] = array($d['hash'],'relayed'); } } + return $result; } diff --git a/mod/post.php b/mod/post.php index 5abf7ac0f..53180e1c1 100644 --- a/mod/post.php +++ b/mod/post.php @@ -151,13 +151,13 @@ function post_post(&$a) { if($msgtype === 'notify') { $async = get_config('system','queued_fetch'); - if($async) { // add to receive queue // qreceive_add($data); } else { $x = zot_fetch($data); + $ret['delivery_report'] = $x; } $ret['result'] = true; -- cgit v1.2.3