aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/deliver.php23
-rw-r--r--include/notifier.php12
-rw-r--r--include/poller.php11
-rw-r--r--include/zot.php12
4 files changed, 56 insertions, 2 deletions
diff --git a/include/deliver.php b/include/deliver.php
index 26739fb06..7a43e3d47 100644
--- a/include/deliver.php
+++ b/include/deliver.php
@@ -15,7 +15,10 @@ function deliver_run($argv, $argc) {
logger('deliver: invoked: ' . print_r($argv,true), LOGGER_DATA);
+
for($x = 1; $x < $argc; $x ++) {
+
+ $dresult = null;
$r = q("select * from outq where outq_hash = '%s' limit 1",
dbesc($argv[$x])
);
@@ -98,11 +101,29 @@ function deliver_run($argv, $argc) {
}
else {
$msg = array('body' => json_encode(array('success' => true, 'pickup' => array(array('notify' => $notify,'message' => $m)))));
- zot_import($msg,z_root());
+ $dresult = zot_import($msg,z_root());
}
$r = q("delete from outq where outq_hash = '%s'",
dbesc($argv[$x])
);
+ 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'])
+ );
+ }
+ }
+ }
+
+ q("delete from dreport where dreport_queue = '%s' limit 1",
+ dbesc($argv[$x])
+ );
}
}
else {
diff --git a/include/notifier.php b/include/notifier.php
index e16f80ecf..fd95d53e2 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -662,6 +662,18 @@ function notifier_run($argv, $argc){
dbesc($n),
dbesc(json_encode($encoded_item))
);
+ // only create delivery reports for normal undeleted items
+ if(array_key_exists('postopts',$target_item) && (! $target_item['item_deleted'])) {
+ q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan, dreport_queue ) values ( '%s','%s','%s','%s','%s','%s','%s' ) ",
+ dbesc($target_item['mid']),
+ dbesc($hub['hubloc_host']),
+ dbesc($hub['hubloc_host']),
+ dbesc('queued'),
+ dbesc(datetime_convert()),
+ dbesc($channel['channel_hash']),
+ dbesc($hash)
+ );
+ }
}
$deliver[] = $hash;
diff --git a/include/poller.php b/include/poller.php
index 72f22d946..031fb4533 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -201,6 +201,17 @@ function poller_run($argv, $argc){
db_utcnow(), db_quoteinterval('30 DAY')
);
+ // expire old delivery reports
+
+ $keep_reports = intval(get_config('system','expire_delivery_reports'));
+ if($keep_reports === 0)
+ $keep_reports = 30;
+
+ q("delete from dreport where dreport_time < %s - INTERVAL %s",
+ db_utcnow(),
+ db_quoteinterval($keep_reports . ' DAY')
+ );
+
// expire any expired accounts
downgrade_accounts();
diff --git a/include/zot.php b/include/zot.php
index f728d8fb9..942998b98 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -971,7 +971,11 @@ function zot_process_response($hub, $arr, $outq) {
}
}
}
-
+
+ q("delete from dreport where dreport_queue = '%s' limit 1",
+ dbesc($outq['outq_hash'])
+ );
+
// update the timestamp for this site
q("update site set site_dead = 0, site_update = '%s' where site_url = '%s'",
@@ -1575,6 +1579,12 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
continue;
}
+ if($d['hash'] === $sender['hash']) {
+ $DR->update('self delivery ignored');
+ $result[] = $DR->get();
+ continue;
+ }
+
$channel = $r[0];
$DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>');