Merge branch 'dev' of /home/macgirvin/z into dev

This commit is contained in:
nobody 2021-02-04 20:39:57 -08:00
commit 10a3b33dac
2 changed files with 20 additions and 4 deletions

View file

@ -2738,7 +2738,7 @@ class Activity {
}
static function rewrite_mentions_sub(&$s, $pref) {
static function rewrite_mentions_sub(&$s, $pref, &$obj = null) {
if ($s['term']) {
foreach ($s['term'] as $tag) {
@ -2795,6 +2795,20 @@ class Activity {
'@[zrl=' . $x[0]['xchan_url'] . ']' . $txt . '[/zrl]',$s['body']);
$s['body'] = preg_replace('/\[url\=' . preg_quote($x[0]['xchan_hash'],'/') . '\]@(.*?)\[\/url\]/ism',
'@[url=' . $x[0]['xchan_url'] . ']' . $txt . '[/url]',$s['body']);
if ($obj) {
if (! is_array($obj)) {
$obj = json_decode($obj,true);
}
if (array_path_exists('source/content',$obj)) {
$obj['source']['content'] = preg_replace('/\@\[zrl\=' . preg_quote($x[0]['xchan_url'],'/') . '\](.*?)\[\/zrl\]/ism',
'@[zrl=' . $x[0]['xchan_url'] . ']' . $txt . '[/zrl]',$obj['source']['content']);
$obj['source']['content'] = preg_replace('/\@\[url\=' . preg_quote($x[0]['xchan_url'],'/') . '\](.*?)\[\/url\]/ism',
'@[url=' . $x[0]['xchan_url'] . ']' . $txt . '[/url]',$obj['source']['content']);
}
$obj['content'] = preg_replace('/\@(.*?)\<a (.*?)href\=\"' . preg_quote($x[0]['xchan_url'],'/') . '\"(.*?)\>(.*?)\<\/a\>/ism',
'@$1<a $2 href="' . $x[0]['xchan_url'] . '"$3>' . $txt . '</a>', $obj['content']);
}
}
}
}

View file

@ -91,10 +91,12 @@ class ActivityPub {
// the username or webfinger address when displaying names. This is likely to
// only cause confusion on nomadic networks where there could be any number
// of applicable webfinger addresses for a given identity.
Activity::rewrite_mentions_sub($target_item, 1);
Activity::rewrite_mentions_sub($target_item, 1, $target_item['obj']);
$ti = Activity::encode_activity($target_item, true);
if (! $ti) {
return;
}