diff options
Diffstat (limited to 'Zotlabs/Lib/Activity.php')
-rw-r--r-- | Zotlabs/Lib/Activity.php | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index ced361fe5..dbf7f7b46 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -459,6 +459,30 @@ class Activity { $ret['id'] = ((strpos($i['mid'], 'http') === 0) ? $i['mid'] : z_root() . '/item/' . urlencode($i['mid'])); $ret['diaspora:guid'] = $i['uuid']; + $images = []; + $has_images = preg_match_all('/\[[zi]mg(.*?)](.*?)\[/ism', $i['body'], $images, PREG_SET_ORDER); + + // provide ocap access token for private media. + // set this for descendants even if the current item is not private + // because it may have been relayed from a private item. + + $token = get_iconfig($i, 'ocap', 'relay'); + if ($token && $has_images) { + $matches_processed = []; + for ($n = 0; $n < count($images); $n++) { + $match = $images[$n]; + if (str_starts_with($match[1], '=http') && str_contains($match[1], z_root() . '/photo/') && !in_array($match[1], $matches_processed)) { + $i['body'] = str_replace($match[1], $match[1] . '?token=' . $token, $i['body']); + $images[$n][2] = substr($match[1], 1) . '?token=' . $token; + $matches_processed[] = $match[1]; + } elseif (str_contains($match[2], z_root() . '/photo/') && !in_array($match[2], $matches_processed)) { + $i['body'] = str_replace($match[2], $match[2] . '?token=' . $token, $i['body']); + $images[$n][2] = $match[2] . '?token=' . $token; + $matches_processed[] = $match[2]; + } + } + } + if ($i['title']) $ret['name'] = $i['title']; @@ -627,10 +651,10 @@ class Activity { } if (isset($att['type']) && strpos($att['type'], 'image')) { - $ret[] = ['type' => 'Image', 'url' => $att['href']]; + $ret[] = ['type' => 'Image', 'mediaType' => $att['type'], 'name' => $att['title'], 'url' => $att['href']]; } else { - $ret[] = ['type' => 'Link', 'mediaType' => $att['type'], 'href' => $att['href']]; + $ret[] = ['type' => 'Link', 'mediaType' => $att['type'], 'name' => $att['title'], 'href' => $att['href']]; } } } @@ -841,7 +865,7 @@ class Activity { if (isset($i['app']) && $i['app']) { $ret['generator'] = ['type' => 'Application', 'name' => $i['app']]; } - if (isset($i['location']) || isset($i['coord'])) { + if (!empty($i['location']) || !empty($i['coord'])) { $ret['location'] = ['type' => 'Place']; if ($i['location']) { $ret['location']['name'] = $i['location']; @@ -929,7 +953,6 @@ class Activity { ]; call_hooks('encode_activity', $hookinfo); - return $hookinfo['encoded']; } @@ -974,10 +997,14 @@ class Activity { $tmp = expand_acl($i['allow_cid']); $list = stringify_array($tmp, true); if ($list) { - $details = q("select hubloc_id_url from hubloc where hubloc_hash in (" . $list . ") and hubloc_id_url != '' and hubloc_deleted = 0"); + $details = q("select hubloc_id_url, hubloc_hash, hubloc_network from hubloc where hubloc_hash in (" . $list . ") and hubloc_id_url != '' and hubloc_deleted = 0"); if ($details) { foreach ($details as $d) { - $ret[] = $d['hubloc_id_url']; + if ($d['hubloc_network'] === 'activitypub') { + $ret[] = $d['hubloc_hash']; + } else { + $ret[] = $d['hubloc_id_url']; + } } } } @@ -3128,6 +3155,16 @@ class Activity { } } + // private conversation, but this comment went rogue and was published publicly + // hide it from everybody except the channel owner + + if (intval($parent[0]['item_private'])) { + if (!intval($item['item_private'])) { + $item['item_private'] = intval($parent_item['item_private']); + $item['allow_cid'] = '<' . $channel['channel_hash'] . '>'; + $item['allow_gid'] = $item['deny_cid'] = $item['deny_gid'] = ''; + } + } } // An ugly and imperfect way to recognise a mastodon direct message @@ -3896,12 +3933,11 @@ class Activity { } if (array_path_exists('source/mediaType', $act) && array_path_exists('source/content', $act)) { - if (in_array($act['source']['mediaType'], ['text/bbcode', 'text/x-multicode'])) { + if (in_array($act['source']['mediaType'], ['text/bbcode'])) { $content['bbcode'] = purify_html($act['source']['content']); } } - return $content; } |