aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Dreport.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Dreport.php')
-rw-r--r--Zotlabs/Module/Dreport.php88
1 files changed, 26 insertions, 62 deletions
diff --git a/Zotlabs/Module/Dreport.php b/Zotlabs/Module/Dreport.php
index 0fc36dc29..d6f4e5979 100644
--- a/Zotlabs/Module/Dreport.php
+++ b/Zotlabs/Module/Dreport.php
@@ -5,33 +5,21 @@ namespace Zotlabs\Module;
class Dreport extends \Zotlabs\Web\Controller {
function get() {
-
+
if(! local_channel()) {
notice( t('Permission denied') . EOL);
return;
}
-
+
$table = 'item';
-
$channel = \App::get_channel();
-
- $mid = ((argc() > 1) ? argv(1) : '');
- $encoded_mid = '';
+ $mid = ((argc() > 1) ? unpack_link_id(argv(1)) : '');
- if(strpos($mid,'b64.') === 0) {
- $encoded_mid = $mid;
- $mid = @base64url_decode(substr($mid,4));
- }
if($mid === 'push') {
$table = 'push';
- $mid = ((argc() > 2) ? argv(2) : '');
-
- if(strpos($mid,'b64.') === 0) {
- $encoded_mid = $mid;
- $mid = @base64url_decode(substr($mid,4));
- }
+ $mid = ((argc() > 2) ? unpack_link_id(argv(2)) : '');
- if($mid) {
+ if($mid) {
$i = q("select id from item where mid = '%s' and uid = %d and ( author_xchan = '%s' or ( owner_xchan = '%s' and item_wall = 1 )) ",
dbesc($mid),
intval($channel['channel_id']),
@@ -43,23 +31,14 @@ class Dreport extends \Zotlabs\Web\Controller {
}
}
sleep(3);
- goaway(z_root() . '/dreport/' . (($encoded_mid) ? $encoded_mid : $mid));
+ goaway(z_root() . '/dreport/' . gen_link_id($mid));
}
- if($mid === 'mail') {
- $table = 'mail';
- $mid = ((argc() > 2) ? argv(2) : '');
- if(strpos($mid,'b64.') === 0)
- $mid = @base64url_decode(substr($mid,4));
-
- }
-
-
if(! $mid) {
notice( t('Invalid message') . EOL);
return;
}
-
+
switch($table) {
case 'item':
$i = q("select id from item where mid = '%s' and ( author_xchan = '%s' or ( owner_xchan = '%s' and item_wall = 1 )) ",
@@ -68,39 +47,33 @@ class Dreport extends \Zotlabs\Web\Controller {
dbesc($channel['channel_hash'])
);
break;
- case 'mail':
- $i = q("select id from mail where mid = '%s' and from_xchan = '%s'",
- dbesc($mid),
- dbesc($channel['channel_hash'])
- );
- break;
default:
break;
}
-
+
if(! $i) {
notice( t('Permission denied') . EOL);
return;
}
-
- $r = q("select * from dreport where (dreport_xchan = '%s' or dreport_xchan = '%s') and dreport_mid = '%s'",
+
+ $r = q("select * from dreport where dreport_xchan = '%s' and (dreport_mid = '%s' or dreport_mid = '%s')",
dbesc($channel['channel_hash']),
- dbesc($channel['channel_portable_id']),
- dbesc($mid)
+ dbesc($mid),
+ dbesc(str_replace('/item/', '/activity/', $mid))
);
-
+
if(! $r) {
notice( t('no results') . EOL);
// return;
}
-
+
for($x = 0; $x < count($r); $x++ ) {
-
+
// This has two purposes: 1. make the delivery report strings translateable, and
// 2. assign an ordering to item delivery results so we can group them and provide
// a readable report with more interesting events listed toward the top and lesser
// interesting items towards the bottom
-
+
switch($r[$x]['dreport_result']) {
case 'channel sync processed':
$r[$x]['gravity'] = 0;
@@ -132,27 +105,18 @@ class Dreport extends \Zotlabs\Web\Controller {
case 'recipient not found':
$r[$x]['dreport_result'] = t('recipient not found');
break;
- case 'mail recalled':
- $r[$x]['dreport_result'] = t('mail recalled');
- break;
- case 'duplicate mail received':
- $r[$x]['dreport_result'] = t('duplicate mail received');
- break;
- case 'mail delivered':
- $r[$x]['dreport_result'] = t('mail delivered');
- break;
default:
$r[$x]['gravity'] = 1;
break;
}
}
-
+
usort($r,'self::dreport_gravity_sort');
$entries = array();
foreach($r as $rr) {
- $entries[] = [
- 'name' => escape_tags($rr['dreport_name'] ?: $rr['dreport_recip']),
+ $entries[] = [
+ 'name' => escape_tags($rr['dreport_name'] ?: $rr['dreport_recip']),
'result' => escape_tags($rr['dreport_result']),
'time' => escape_tags(datetime_convert('UTC',date_default_timezone_get(),$rr['dreport_time']))
];
@@ -167,14 +131,14 @@ class Dreport extends \Zotlabs\Web\Controller {
'$push' => t('Redeliver'),
'$entries' => $entries
));
-
-
+
+
return $o;
-
-
-
+
+
+
}
-
+
private static function dreport_gravity_sort($a,$b) {
if($a['gravity'] == $b['gravity']) {
if($a['dreport_name'] === $b['dreport_name'])
@@ -183,5 +147,5 @@ class Dreport extends \Zotlabs\Web\Controller {
}
return (($a['gravity'] > $b['gravity']) ? 1 : (-1));
}
-
+
}