aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/DReport.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-11-12 16:08:22 -0800
committerzotlabs <mike@macgirvin.com>2018-11-12 16:08:22 -0800
commit770fdb2b7d095d763d43ffe8d2f6b5b2182673cb (patch)
treeb3e991040552b9f7b1d71487bf24b806b2e86aa3 /Zotlabs/Lib/DReport.php
parent171ff54ea407595a85e971f62abc556faf3dec73 (diff)
downloadvolse-hubzilla-770fdb2b7d095d763d43ffe8d2f6b5b2182673cb.tar.gz
volse-hubzilla-770fdb2b7d095d763d43ffe8d2f6b5b2182673cb.tar.bz2
volse-hubzilla-770fdb2b7d095d763d43ffe8d2f6b5b2182673cb.zip
dreport updates
Diffstat (limited to 'Zotlabs/Lib/DReport.php')
-rw-r--r--Zotlabs/Lib/DReport.php84
1 files changed, 82 insertions, 2 deletions
diff --git a/Zotlabs/Lib/DReport.php b/Zotlabs/Lib/DReport.php
index a68d6c18f..21b320cac 100644
--- a/Zotlabs/Lib/DReport.php
+++ b/Zotlabs/Lib/DReport.php
@@ -14,6 +14,7 @@ class DReport {
$this->location = $location;
$this->sender = $sender;
$this->recipient = $recipient;
+ $this->name = EMPTY_STR;
$this->message_id = $message_id;
$this->status = $status;
$this->date = datetime_convert();
@@ -24,8 +25,8 @@ class DReport {
$this->date = datetime_convert();
}
- function addto_recipient($name) {
- $this->recipient = $this->recipient . ' ' . $name;
+ function set_name($name) {
+ $this->name = $name;
}
function addto_update($status) {
@@ -37,6 +38,7 @@ class DReport {
$this->location = $arr['location'];
$this->sender = $arr['sender'];
$this->recipient = $arr['recipient'];
+ $this->name = $arr['name'];
$this->message_id = $arr['message_id'];
$this->status = $arr['status'];
$this->date = $arr['date'];
@@ -47,9 +49,87 @@ class DReport {
'location' => $this->location,
'sender' => $this->sender,
'recipient' => $this->recipient,
+ 'name' => $this->name,
'message_id' => $this->message_id,
'status' => $this->status,
'date' => $this->date
);
}
+
+ /**
+ * @brief decide whether to store a returned delivery report
+ *
+ * @param array $dr
+ * @return boolean
+ */
+
+ static function is_storable($dr) {
+
+ if(get_config('system', 'disable_dreport'))
+ return false;
+
+ /**
+ * @hooks dreport_is_storable
+ * Called before storing a dreport record to determine whether to store it.
+ * * \e array
+ */
+
+ 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?
+
+
+ $rxchan = $dr['recipient'];
+ $pcf = get_pconfig($c[0]['channel_id'],'system','dreport_store_all');
+ if($pcf)
+ return true;
+
+ // We always add ourself as a recipient to private and relayed posts
+ // So if a remote site says they can't find us, that's no big surprise
+ // and just creates a lot of extra report noise
+
+ if(($dr['location'] !== z_root()) && ($dr['sender'] === $rxchan) && ($dr['status'] === 'recipient_not_found'))
+ return false;
+
+ // If you have a private post with a recipient list, every single site is going to report
+ // back a failed delivery for anybody on that list that isn't local to them. We're only
+ // concerned about this if we have a local hubloc record which says we expected them to
+ // have a channel on that site.
+
+ $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_url = '%s'",
+ dbesc($rxchan),
+ dbesc($dr['location'])
+ );
+ if((! $r) && ($dr['status'] === 'recipient_not_found'))
+ return false;
+
+ $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;
+ }
+
+
}