aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-04-07 07:28:43 +0000
committerMario <mario@mariovavti.com>2022-04-07 07:28:43 +0000
commit930b9820f2829a129a93ed619a68754d2b43b530 (patch)
tree84e635b8522bd815b92c8ca7d941971fb6fe5d1a
parent1390e1db399c06cb76e191437eb5be24dd95a5c7 (diff)
downloadvolse-hubzilla-930b9820f2829a129a93ed619a68754d2b43b530.tar.gz
volse-hubzilla-930b9820f2829a129a93ed619a68754d2b43b530.tar.bz2
volse-hubzilla-930b9820f2829a129a93ed619a68754d2b43b530.zip
Revert "move AP addressing to pubcrawl"
This reverts commit 1390e1db399c06cb76e191437eb5be24dd95a5c7
-rw-r--r--Zotlabs/Lib/Activity.php136
1 files changed, 122 insertions, 14 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 6814c2acd..7663131bb 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -530,18 +530,71 @@ class Activity {
$ret['attachment'] = $a;
}
- if (intval($i['item_private']) === 0) {
+ $public = (($i['item_private']) ? false : true);
+ $top_level = (($i['mid'] === $i['parent_mid']) ? true : false);
+
+ if ($public) {
+
$ret['to'] = [ACTIVITY_PUBLIC_INBOX];
+ $ret['cc'] = [z_root() . '/followers/' . substr($i['author']['xchan_addr'], 0, strpos($i['author']['xchan_addr'], '@'))];
}
+ else {
- $hookinfo = [
- 'item' => $i,
- 'encoded' => $ret
- ];
+ // private activity
+
+ if ($top_level) {
+ $ret['to'] = self::map_acl($i);
+ }
+ else {
+ $ret['to'] = [];
+ if ($ret['tag']) {
+ foreach ($ret['tag'] as $mention) {
+ if (is_array($mention) && array_key_exists('href', $mention) && $mention['href']) {
+ $h = q("select * from hubloc where hubloc_id_url = '%s' limit 1",
+ dbesc($mention['href'])
+ );
+ if ($h) {
+ if ($h[0]['hubloc_network'] === 'activitypub') {
+ $addr = $h[0]['hubloc_hash'];
+ }
+ else {
+ $addr = $h[0]['hubloc_id_url'];
+ }
+ if (!in_array($addr, $ret['to'])) {
+ $ret['to'][] = $addr;
+ }
+ }
+ }
+ }
+ }
+ $d = q("select hubloc.* from hubloc left join item on hubloc_hash = owner_xchan where item.id = %d and hubloc_deleted = 0 order by hubloc_id desc limit 1",
+ intval($i['parent'])
+ );
+ if ($d) {
+ if ($d[0]['hubloc_network'] === 'activitypub') {
+ $addr = $d[0]['hubloc_hash'];
+ }
+ else {
+ $addr = $d[0]['hubloc_id_url'];
+ }
+ if (!in_array($addr, $ret['to'])) {
+ $ret['cc'][] = $addr;
+ }
+ }
+ }
+ }
- call_hooks('encode_item', $hookinfo);
+ $mentions = self::map_mentions($i);
+ if (count($mentions) > 0) {
+ if (!$ret['to']) {
+ $ret['to'] = $mentions;
+ }
+ else {
+ $ret['to'] = array_values(array_unique(array_merge($ret['to'], $mentions)));
+ }
+ }
- return $hookinfo['encoded'];
+ return $ret;
}
@@ -888,18 +941,73 @@ class Activity {
$ret['attachment'] = $a;
}
- if (intval($i['item_private']) === 0) {
+ // addressing madness
+
+ $public = (($i['item_private']) ? false : true);
+ $top_level = (($reply) ? false : true);
+
+ if ($public) {
$ret['to'] = [ACTIVITY_PUBLIC_INBOX];
+ $ret['cc'] = [z_root() . '/followers/' . substr($i['author']['xchan_addr'], 0, strpos($i['author']['xchan_addr'], '@'))];
}
+ else {
- $hookinfo = [
- 'item' => $i,
- 'encoded' => $ret
- ];
+ // private activity
- call_hooks('encode_activity', $hookinfo);
+ if ($top_level) {
+ $ret['to'] = self::map_acl($i);
+ }
+ else {
+ $ret['to'] = [];
+ if ($ret['tag']) {
+ foreach ($ret['tag'] as $mention) {
+ if (is_array($mention) && array_key_exists('href', $mention) && $mention['href']) {
+ $h = q("select * from hubloc where hubloc_id_url = '%s' limit 1",
+ dbesc($mention['href'])
+ );
+ if ($h) {
+ if ($h[0]['hubloc_network'] === 'activitypub') {
+ $addr = $h[0]['hubloc_hash'];
+ }
+ else {
+ $addr = $h[0]['hubloc_id_url'];
+ }
+ if (!in_array($addr, $ret['to'])) {
+ $ret['to'][] = $addr;
+ }
+ }
+ }
+ }
+ }
- return $hookinfo['encoded'];
+ $d = q("select hubloc.* from hubloc left join item on hubloc_hash = owner_xchan where item.id = %d and hubloc_deleted = 0 order by hubloc_id desc limit 1",
+ intval($i['parent'])
+ );
+ if ($d) {
+ if ($d[0]['hubloc_network'] === 'activitypub') {
+ $addr = $d[0]['hubloc_hash'];
+ }
+ else {
+ $addr = $d[0]['hubloc_id_url'];
+ }
+ if (!in_array($addr, $ret['to'])) {
+ $ret['cc'][] = $addr;
+ }
+ }
+ }
+ }
+
+ $mentions = self::map_mentions($i);
+ if (count($mentions) > 0) {
+ if (!$ret['to']) {
+ $ret['to'] = $mentions;
+ }
+ else {
+ $ret['to'] = array_values(array_unique(array_merge($ret['to'], $mentions)));
+ }
+ }
+
+ return $ret;
}
// Returns an array of URLS for any mention tags found in the item array $i.