mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:15:13 +00:00
refactor recip list one more time. Mentions were not getting added correctly.
This commit is contained in:
parent
b10fcd3166
commit
718d5aee94
1 changed files with 25 additions and 37 deletions
|
@ -3,6 +3,7 @@
|
|||
use Code\Access\Permissions;
|
||||
use Code\Access\PermissionLimits;
|
||||
use Code\Extend\Hook;
|
||||
use Code\Lib\Libzot;
|
||||
|
||||
require_once('include/security.php');
|
||||
|
||||
|
@ -543,45 +544,18 @@ function check_deliver_permissions($item, $arr)
|
|||
if (!in_array($recipient,$willNotSend)) {
|
||||
$deliverable = true;
|
||||
}
|
||||
if (in_array($recipient, [$item['author_xchan'], $item['owner_xchan']])) {
|
||||
$deliverable = $accepting = true;
|
||||
}
|
||||
if (!$deliverable || !$accepting) {
|
||||
if ($deliverable || !$accepting) {
|
||||
// Groups don't generally provide send_stream permission as they aren't really following you,
|
||||
// but they do allow you to send them group targeted posts.
|
||||
if ($deliverable) {
|
||||
$r = q("select xchan_hash from xchan where xchan_hash = '%s' and xchan_type = %d",
|
||||
dbesc($recipient),
|
||||
intval(XCHAN_TYPE_GROUP)
|
||||
);
|
||||
if ($r) {
|
||||
if ($r && !in_array($recipient, $result)) {
|
||||
$result[] = $recipient;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Send mentions even if you have no permission to do so. They might allow it.
|
||||
if ($terms) {
|
||||
foreach ($terms as $term) {
|
||||
if (in_array($term['url'], $result)) {
|
||||
continue;
|
||||
}
|
||||
// activitypub is easy because $x will match directly on the mention url
|
||||
if ($recipient === $term['url'] && (!in_array($recipient, $result))) {
|
||||
$result[] = $recipient;
|
||||
break;
|
||||
}
|
||||
// zot/nomad is harder because we will need to match the portable_id to the mention url
|
||||
// and won't be able to perform duplicate detection
|
||||
$r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_id_url = '%s' and hubloc_deleted = 0",
|
||||
dbesc($recipient),
|
||||
dbesc($term['url'])
|
||||
);
|
||||
if ($r && !in_array($recipient, $result)) {
|
||||
$result[] = $recipient;
|
||||
break;
|
||||
}
|
||||
|
||||
$r = q("select xchan_hash from xchan where xchan_hash = '%s' and xchan_type = %d",
|
||||
dbesc($recipient),
|
||||
intval(XCHAN_TYPE_GROUP)
|
||||
);
|
||||
if ($r) {
|
||||
if ($r && !in_array($recipient, $result)) {
|
||||
$result[] = $recipient;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -590,6 +564,20 @@ function check_deliver_permissions($item, $arr)
|
|||
$result[] = $recipient;
|
||||
}
|
||||
}
|
||||
// Send mentions even if you have no permission to do so. They might allow it.
|
||||
if ($terms) {
|
||||
foreach ($terms as $term) {
|
||||
$r = q("select * from hubloc where hubloc_hash = '%s' or hubloc_id_url = '%s' and hubloc_deleted = 0",
|
||||
dbesc($term['url']),
|
||||
dbesc($term['url'])
|
||||
);
|
||||
$r = Libzot::zot_record_preferred($r);
|
||||
if ($r && !in_array($r['hubloc_hash'], $result)) {
|
||||
$result[] = $r['hubloc_hash'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return($result);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue