aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2023-01-26 10:10:06 +0000
committerMario <mario@mariovavti.com>2023-01-26 10:10:06 +0000
commitcf1838f76eea5a33f1af78447c7dcf3f52dacc56 (patch)
tree8d83a7663c980e6969835799bd72c9a4fcefe03f
parent0db5016666af0006d07042969c71b9aad4e39c04 (diff)
downloadvolse-hubzilla-cf1838f76eea5a33f1af78447c7dcf3f52dacc56.tar.gz
volse-hubzilla-cf1838f76eea5a33f1af78447c7dcf3f52dacc56.tar.bz2
volse-hubzilla-cf1838f76eea5a33f1af78447c7dcf3f52dacc56.zip
minor cleanup and prevent duplicate recipients in some places
-rw-r--r--Zotlabs/Lib/DReport.php19
-rw-r--r--Zotlabs/Lib/Libzot.php24
-rw-r--r--include/items.php22
3 files changed, 26 insertions, 39 deletions
diff --git a/Zotlabs/Lib/DReport.php b/Zotlabs/Lib/DReport.php
index 2263529b2..e22ed65be 100644
--- a/Zotlabs/Lib/DReport.php
+++ b/Zotlabs/Lib/DReport.php
@@ -94,19 +94,6 @@ class DReport {
if(! $c)
return false;
- // legacy zot recipients add a space and their name to the xchan. remove it if true.
-
- $legacy_recipient = strpos($dr['recipient'], ' ');
- if($legacy_recipient !== false) {
- $legacy_recipient_parts = explode(' ', $dr['recipient'], 2);
- $rxchan = $legacy_recipient_parts[0];
- }
- else {
- $rxchan = $dr['recipient'];
- }
-
-
-
// is the recipient one of our connections, or do we want to store every report?
$pcf = get_pconfig($c[0]['channel_id'],'system','dreport_store_all');
@@ -117,7 +104,7 @@ class DReport {
// 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'))
+ if(($dr['location'] !== z_root()) && ($dr['sender'] === $dr['recipient']) && ($dr['status'] === 'recipient not found'))
return false;
// If you have a private post with a recipient list, every single site is going to report
@@ -126,14 +113,14 @@ class DReport {
// 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['recipient']),
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),
+ dbesc($dr['recipient']),
intval($c[0]['channel_id'])
);
if($r)
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index c635fdb17..e4be56157 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -1051,19 +1051,9 @@ class Libzot {
}
if (is_array($x) && array_key_exists('delivery_report', $x) && is_array($x['delivery_report'])) {
-
foreach ($x['delivery_report'] as $xx) {
call_hooks('dreport_process', $xx);
if (is_array($xx) && array_key_exists('message_id', $xx) && DReport::is_storable($xx)) {
-
- // legacy recipients add a space and their name to the xchan. split those if true.
- $legacy_recipient = strpos($xx['recipient'], ' ');
- if ($legacy_recipient !== false) {
- $legacy_recipient_parts = explode(' ', $xx['recipient'], 2);
- $xx['recipient'] = $legacy_recipient_parts[0];
- $xx['name'] = $legacy_recipient_parts[1];
- }
-
q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_name, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s', '%s','%s','%s','%s','%s' ) ",
dbesc($xx['message_id']),
dbesc($xx['location']),
@@ -1435,7 +1425,9 @@ class Libzot {
$r = [];
- $c = q("select channel_id, channel_hash from channel where channel_removed = 0");
+ $c = q("select channel_id, channel_hash from channel where channel_hash != '%s' and channel_removed = 0",
+ dbesc($msg['sender'])
+ );
if ($c) {
foreach ($c as $cc) {
@@ -1463,9 +1455,10 @@ class Libzot {
if ($tag['type'] === 'Mention' && (strpos($tag['href'], z_root()) !== false)) {
$address = basename($tag['href']);
if ($address) {
- $z = q("select channel_hash as hash from channel where channel_address = '%s'
+ $z = q("select channel_hash as hash from channel where channel_address = '%s' and channel_hash != '%s'
and channel_removed = 0 limit 1",
- dbesc($address)
+ dbesc($address),
+ dbesc($msg['sender'])
);
if ($z) {
$r[] = $z[0]['hash'];
@@ -1484,9 +1477,10 @@ class Libzot {
$thread_parent = self::find_parent($msg, $act);
if ($thread_parent) {
- $z = q("select channel_hash as hash from channel left join item on channel.channel_id = item.uid where ( item.thr_parent = '%s' OR item.parent_mid = '%s' ) ",
+ $z = q("select channel_hash as hash from channel left join item on channel.channel_id = item.uid where ( item.thr_parent = '%s' OR item.parent_mid = '%s' ) and channel_hash != '%s'",
+ dbesc($thread_parent),
dbesc($thread_parent),
- dbesc($thread_parent)
+ dbesc($msg['sender'])
);
if ($z) {
foreach ($z as $zv) {
diff --git a/include/items.php b/include/items.php
index 900ffe2fa..b795df90d 100644
--- a/include/items.php
+++ b/include/items.php
@@ -149,14 +149,16 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) {
// in the middle of a public thread. Unless we can guarantee beyond all doubt that
// this is public, don't allow it to go to thread listeners.
- if(! intval($item['item_private'])) {
+ if(!intval($item['item_private'])) {
$sys = get_sys_channel();
$recipients[] = $sys['xchan_hash'];
$r = ThreadListener::fetch_by_target($item['parent_mid']);
if($r) {
foreach($r as $rv) {
- $recipients[] = $rv['portable_id'];
+ if (!in_array($rv['portable_id'], $recipients)) {
+ $recipients[] = $rv['portable_id'];
+ }
}
}
}
@@ -172,9 +174,9 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) {
$r = q("select author_xchan from item where parent = %d",
intval($item['parent'])
);
- if($r) {
+ if ($r) {
foreach($r as $rv) {
- if(! in_array($rv['author_xchan'],$recipients)) {
+ if (!in_array($rv['author_xchan'], $recipients)) {
$recipients[] = $rv['author_xchan'];
}
}
@@ -185,7 +187,7 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) {
// This is a somewhat expensive operation but important.
// Don't send this item to anybody who isn't allowed to see it
- $recipients = check_list_permissions($item['uid'],$recipients,'view_stream');
+ $recipients = check_list_permissions($item['uid'], $recipients, 'view_stream');
// remove any upstream recipients from our list.
// If it is ourself we'll add it back in a second.
@@ -193,7 +195,7 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) {
// sending to anybody who is on our list of those who sent it to us.
if($item['route']) {
- $route = explode(',',$item['route']);
+ $route = explode(',', $item['route']);
if(count($route)) {
$route = array_unique($route);
$recipients = array_diff($recipients,$route);
@@ -202,9 +204,13 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) {
// add ourself just in case we have nomadic clones that need to get a copy.
- $recipients[] = $item['author_xchan'];
- if($item['owner_xchan'] != $item['author_xchan'])
+ if (!in_array($item['author_xchan'], $recipients)) {
+ $recipients[] = $item['author_xchan'];
+ }
+
+ if($item['owner_xchan'] !== $item['author_xchan'] && !in_array($item['owner_xchan'], $recipients)) {
$recipients[] = $item['owner_xchan'];
+ }
return $recipients;
}