mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 01:15:13 +00:00
new delivery report format
This commit is contained in:
parent
efcb4abfd0
commit
a679081993
2 changed files with 42 additions and 13 deletions
|
@ -24,6 +24,15 @@ class DReport {
|
|||
$this->date = datetime_convert();
|
||||
}
|
||||
|
||||
function addto_recipient($name) {
|
||||
$this->recipient = $this->recipient . ' ' . $name;
|
||||
}
|
||||
|
||||
function addto_update($status) {
|
||||
$this->status = $this->status . ' ' . $status;
|
||||
}
|
||||
|
||||
|
||||
function set($arr) {
|
||||
$this->location = $arr['location'];
|
||||
$this->sender = $arr['sender'];
|
||||
|
|
|
@ -1547,6 +1547,7 @@ function allowed_public_recips($msg) {
|
|||
function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $request = false) {
|
||||
|
||||
$result = array();
|
||||
require_once('include/DReport.php');
|
||||
|
||||
$result['site'] = z_root();
|
||||
|
||||
|
@ -1561,16 +1562,22 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
|||
|
||||
foreach($deliveries as $d) {
|
||||
$local_public = $public;
|
||||
|
||||
$DR = new DReport(z_root(),$sender['hash'],$d['hash'],$arr['mid']);
|
||||
|
||||
$r = q("select * from channel where channel_hash = '%s' limit 1",
|
||||
dbesc($d['hash'])
|
||||
);
|
||||
|
||||
if(! $r) {
|
||||
$result[] = array($d['hash'], 'recipients not found');
|
||||
$DR->update('recipient not found');
|
||||
$result[] = $DR->get();
|
||||
continue;
|
||||
}
|
||||
|
||||
$channel = $r[0];
|
||||
$DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>');
|
||||
|
||||
|
||||
// allow public postings to the sys channel regardless of permissions, but not
|
||||
// for comments travelling upstream. Wait and catch them on the way down.
|
||||
|
@ -1609,7 +1616,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
|||
|
||||
if((! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) && (! $tag_delivery) && (! $local_public)) {
|
||||
logger("permission denied for delivery to channel {$channel['channel_id']} {$channel['channel_address']}");
|
||||
$result[] = array($d['hash'],'permission denied',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update('permission denied');
|
||||
$result[] = $DR->get();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1626,7 +1634,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
|||
intval($channel['channel_id'])
|
||||
);
|
||||
if(! $r) {
|
||||
$result[] = array($d['hash'],'comment parent not found',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update('comment parent not found');
|
||||
$result[] = $DR->get();
|
||||
|
||||
// We don't seem to have a copy of this conversation or at least the parent
|
||||
// - so request a copy of the entire conversation to date.
|
||||
|
@ -1681,7 +1690,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
|||
if($last_hop && $last_hop != $sender['hash']) {
|
||||
logger('comment route mismatch: parent route = ' . $r[0]['route'] . ' expected = ' . $current_route, LOGGER_DEBUG);
|
||||
logger('comment route mismatch: parent msg = ' . $r[0]['id'],LOGGER_DEBUG);
|
||||
$result[] = array($d['hash'],'comment route mismatch',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update('comment route mismatch');
|
||||
$result[] = $DR->get();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1710,12 +1720,14 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
|||
$arr['uid'] = $channel['channel_id'];
|
||||
|
||||
$item_id = delete_imported_item($sender,$arr,$channel['channel_id'],$relay);
|
||||
$result[] = array($d['hash'],(($item_id) ? 'deleted' : 'delete_failed'),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update(($item_id) ? 'deleted' : 'delete_failed');
|
||||
$result[] = $DR->get();
|
||||
|
||||
if($relay && $item_id) {
|
||||
logger('process_delivery: invoking relay');
|
||||
proc_run('php','include/notifier.php','relay',intval($item_id));
|
||||
$result[] = array($d['hash'],'relayed',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update('relayed');
|
||||
$result[] = $DR->get();
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -1730,7 +1742,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
|||
$item_id = $r[0]['id'];
|
||||
if($r[0]['item_restrict'] & ITEM_DELETED) {
|
||||
// It was deleted locally.
|
||||
$result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update('update ignored');
|
||||
$result[] = $DR->get();
|
||||
continue;
|
||||
}
|
||||
// Maybe it has been edited?
|
||||
|
@ -1738,17 +1751,21 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
|||
$arr['id'] = $r[0]['id'];
|
||||
$arr['uid'] = $channel['channel_id'];
|
||||
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) {
|
||||
$result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update('update ignored');
|
||||
$result[] = $DR->get();
|
||||
}
|
||||
else {
|
||||
update_imported_item($sender,$arr,$channel['channel_id']);
|
||||
$result[] = array($d['hash'],'updated',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update('updated');
|
||||
$result[] = $DR->get();
|
||||
if(! $relay)
|
||||
add_source_route($item_id,$sender['hash']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update('update ignored');
|
||||
$result[] = $DR->get();
|
||||
|
||||
// We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit),
|
||||
// and at the same time not relay any other relayable posts more than once, because to do so is very wasteful.
|
||||
if(! ($r[0]['item_flags'] & ITEM_ORIGIN))
|
||||
|
@ -1768,7 +1785,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
|||
$item_id = 0;
|
||||
|
||||
if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) {
|
||||
$result[] = array($d['hash'],'post ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update('post ignored');
|
||||
$result[] = $DR->get();
|
||||
}
|
||||
else {
|
||||
$item_result = item_store($arr);
|
||||
|
@ -1780,14 +1798,16 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
|||
if(! $relay)
|
||||
add_source_route($item_id,$sender['hash']);
|
||||
}
|
||||
$result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed:' . $item_result['message']),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->update(($item_id) ? 'posted' : 'storage failed: ' . $item_result['message']);
|
||||
$result[] = $DR->get();
|
||||
}
|
||||
}
|
||||
|
||||
if($relay && $item_id) {
|
||||
logger('process_delivery: invoking relay');
|
||||
proc_run('php','include/notifier.php','relay',intval($item_id));
|
||||
$result[] = array($d['hash'],'relayed',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
$DR->addto_update('relayed');
|
||||
$result[] = $DR->get();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue