add delivery reports to mail (not backported to redmatrix)
This commit is contained in:
parent
54e7d5d260
commit
9bdb7bef5d
@ -11,6 +11,7 @@
|
||||
require_once('include/crypto.php');
|
||||
require_once('include/items.php');
|
||||
require_once('include/hubloc.php');
|
||||
require_once('include/DReport.php');
|
||||
|
||||
|
||||
/**
|
||||
@ -1556,7 +1557,6 @@ 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();
|
||||
|
||||
@ -1569,7 +1569,6 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
||||
}
|
||||
}
|
||||
|
||||
logger('sender: ' . print_r($sender,true));
|
||||
|
||||
foreach($deliveries as $d) {
|
||||
$local_public = $public;
|
||||
@ -2043,20 +2042,26 @@ function process_mail_delivery($sender, $arr, $deliveries) {
|
||||
}
|
||||
|
||||
foreach($deliveries as $d) {
|
||||
|
||||
$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'],'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() . '>');
|
||||
|
||||
if(! perm_is_allowed($channel['channel_id'],$sender['hash'],'post_mail')) {
|
||||
logger("permission denied for mail delivery {$channel['channel_id']}");
|
||||
$result[] = array($d['hash'],'permission denied',$channel['channel_name'],$arr['mid']);
|
||||
$DR->update('permission denied');
|
||||
$result[] = $DR->get();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2070,11 +2075,13 @@ function process_mail_delivery($sender, $arr, $deliveries) {
|
||||
intval($r[0]['id']),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
$result[] = array($d['hash'],'mail recalled',$channel['channel_name'],$arr['mid']);
|
||||
$DR->update('mail recalled');
|
||||
$result[] = $DR->get();
|
||||
logger('mail_recalled');
|
||||
}
|
||||
else {
|
||||
$result[] = array($d['hash'],'duplicate mail received',$channel['channel_name'],$arr['mid']);
|
||||
$DR->update('duplicate mail received');
|
||||
$result[] = $DR->get();
|
||||
logger('duplicate mail received');
|
||||
}
|
||||
continue;
|
||||
@ -2083,7 +2090,8 @@ function process_mail_delivery($sender, $arr, $deliveries) {
|
||||
$arr['account_id'] = $channel['channel_account_id'];
|
||||
$arr['channel_id'] = $channel['channel_id'];
|
||||
$item_id = mail_store($arr);
|
||||
$result[] = array($d['hash'],'mail delivered',$channel['channel_name'],$arr['mid']);
|
||||
$DR->update('mail delivered');
|
||||
$result[] = $DR->get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,14 +7,44 @@ function dreport_content(&$a) {
|
||||
return;
|
||||
}
|
||||
|
||||
$table = 'item';
|
||||
|
||||
$channel = $a->get_channel();
|
||||
|
||||
$mid = ((argc() > 1) ? argv(1) : '');
|
||||
|
||||
if($mid === 'mail') {
|
||||
$table = 'mail';
|
||||
$mid = ((argc() > 2) ? argv(2) : '');
|
||||
}
|
||||
|
||||
|
||||
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' ",
|
||||
dbesc($mid),
|
||||
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' and dreport_mid = '%s'",
|
||||
dbesc($channel['channel_hash']),
|
||||
@ -33,6 +63,11 @@ function dreport_content(&$a) {
|
||||
for($x = 0; $x < count($r); $x++ ) {
|
||||
$r[$x]['name'] = escape_tags(substr($r[$x]['dreport_recip'],strpos($r[$x]['dreport_recip'],' ')));
|
||||
|
||||
// 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;
|
||||
@ -61,6 +96,18 @@ function dreport_content(&$a) {
|
||||
$r[$x]['dreport_result'] = t('permission denied');
|
||||
$r[$x]['gravity'] = 6;
|
||||
break;
|
||||
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;
|
||||
|
@ -324,6 +324,7 @@ function mail_content(&$a) {
|
||||
$mails[] = array(
|
||||
'mailbox' => $mailbox,
|
||||
'id' => $message['id'],
|
||||
'mid' => $message['mid'],
|
||||
'from_name' => $message['from']['xchan_name'],
|
||||
'from_url' => chanlink_hash($message['from_xchan']),
|
||||
'from_photo' => $message['from']['xchan_photo_s'],
|
||||
@ -333,6 +334,7 @@ function mail_content(&$a) {
|
||||
'subject' => $message['title'],
|
||||
'body' => smilies(bbcode($message['body']) . $s),
|
||||
'delete' => t('Delete message'),
|
||||
'dreport' => t('Delivery report'),
|
||||
'recall' => t('Recall message'),
|
||||
'can_recall' => (($channel['channel_hash'] == $message['from_xchan']) ? true : false),
|
||||
'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''),
|
||||
|
@ -9,6 +9,7 @@
|
||||
<div class="mail-conv-body">{{$mail.body}}</div>
|
||||
<div class="btn-group pull-right" id="mail-conv-delete-wrapper-{{$mail.id}}" >
|
||||
{{if $mail.can_recall}}
|
||||
<a href="dreport/mail/{{$mail.mid}}" title="{{$mail.dreport}}" id="mail-conv-dreport-icon-{{$mail.id}}" class="btn btn-default" ><i class="icon-barcode mail-icons"></i></a>
|
||||
<a href="mail/{{$mail.mailbox}}/recall/{{$mail.id}}" title="{{$mail.recall}}" id="mail-conv-recall-icon-{{$mail.id}}" class="btn btn-default" ><i class="icon-undo mail-icons"></i></a>
|
||||
{{/if}}
|
||||
<a href="#" onclick="dropItem('mail/{{$mail.mailbox}}/drop/{{$mail.id}}', '#mail-{{$mail.id}}'); return false;" title="{{$mail.delete}}" id="mail-conv-delete-icon-{{$mail.id}}" class="btn btn-default" ><i class="icon-trash mail-icons"></i></a>
|
||||
|
Reference in New Issue
Block a user