diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-10-17 13:26:55 -0700 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-10-17 13:26:55 -0700 |
commit | 4b984f98193d8f9fad4c89aade378e7df238a708 (patch) | |
tree | 97e70d998bfdc4b05f4ee2c86c15fafb8a80ae86 /include | |
parent | e8882a516722b60e647af479b52f6593426bcfdd (diff) | |
download | volse-hubzilla-4b984f98193d8f9fad4c89aade378e7df238a708.tar.gz volse-hubzilla-4b984f98193d8f9fad4c89aade378e7df238a708.tar.bz2 volse-hubzilla-4b984f98193d8f9fad4c89aade378e7df238a708.zip |
filter delivery reports
Diffstat (limited to 'include')
-rw-r--r-- | include/deliver.php | 18 | ||||
-rw-r--r-- | include/zot.php | 44 |
2 files changed, 53 insertions, 9 deletions
diff --git a/include/deliver.php b/include/deliver.php index a338d1a89..11c1b249e 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -138,14 +138,16 @@ function deliver_run($argv, $argc) { if($dresult && is_array($dresult)) { foreach($dresult as $xx) { if(is_array($xx) && array_key_exists('message_id',$xx)) { - q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", - dbesc($xx['message_id']), - dbesc($xx['location']), - dbesc($xx['recipient']), - dbesc($xx['status']), - dbesc(datetime_convert($xx['date'])), - dbesc($xx['sender']) - ); + if(delivery_report_is_storable($xx)) { + q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", + dbesc($xx['message_id']), + dbesc($xx['location']), + dbesc($xx['recipient']), + dbesc($xx['status']), + dbesc(datetime_convert($xx['date'])), + dbesc($xx['sender']) + ); + } } } } diff --git a/include/zot.php b/include/zot.php index b1cb5a8ec..26baeddaf 100644 --- a/include/zot.php +++ b/include/zot.php @@ -965,7 +965,7 @@ function zot_process_response($hub, $arr, $outq) { if(is_array($x) && array_key_exists('delivery_report',$x) && is_array($x['delivery_report'])) { foreach($x['delivery_report'] as $xx) { - if(is_array($xx) && array_key_exists('message_id',$xx)) { + if(is_array($xx) && array_key_exists('message_id',$xx) && delivery_report_is_storable($xx)) { q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", dbesc($xx['message_id']), dbesc($xx['location']), @@ -3882,3 +3882,45 @@ function check_zotinfo($channel,$locations,&$ret) { } } } + +function delivery_report_is_storable($dr) { + + call_hooks('dreport_is_storable',$dr); + + // let plugins accept or reject - if neither, continue on + if(array_key_exists('accept',$dr) && intval($dr['accept'])) + return true; + if(array_key_exists('reject',$dr) && intval($dr['reject'])) + return false; + + if(! ($dr['sender'])) + return false; + + // Is the sender one of our channels? + + $c = q("select channel_id from channel where channel_hash = '%s' limit 1", + dbesc($dr['sender']) + ); + if(! $c) + return false; + + // is the recipient one of our connections, or do we want to store every report? + + $r = explode(' ', $dr['recipient']); + $rxchan = $r[0]; + $pcf = get_pconfig($c[0]['channel_id'],'system','dreport_store_all'); + if($pcf) + return true; + + $r = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($rxchan), + intval($c[0]['channel_id']) + ); + if($r) + return true; + + return false; + +} + + |