Merge pull request #5965 from annando/ap-nick
Use nickname based mentions for AP
This commit is contained in:
commit
6e164ed09f
|
@ -743,6 +743,26 @@ class Transmitter
|
||||||
return $attachments;
|
return $attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Callback function to replace a Friendica style mention in a mention that is used on AP
|
||||||
|
*
|
||||||
|
* @param array $match Matching values for the callback
|
||||||
|
* @return string Replaced mention
|
||||||
|
*/
|
||||||
|
private static function MentionCallback($match)
|
||||||
|
{
|
||||||
|
if (empty($match[1])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = Contact::getDetailsByURL($match[1]);
|
||||||
|
if (empty($data) || empty($data['nick'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '@[url=' . $data['url'] . ']' . $data['nick'] . '[/url]';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove image elements and replaces them with links to the image
|
* Remove image elements and replaces them with links to the image
|
||||||
*
|
*
|
||||||
|
@ -851,6 +871,9 @@ class Transmitter
|
||||||
$body = self::removePictures($body);
|
$body = self::removePictures($body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
|
||||||
|
$body = preg_replace_callback($regexp, ['self', 'MentionCallback'], $body);
|
||||||
|
|
||||||
$data['content'] = BBCode::convert($body, false, 7);
|
$data['content'] = BBCode::convert($body, false, 7);
|
||||||
$data['source'] = ['content' => $item['body'], 'mediaType' => "text/bbcode"];
|
$data['source'] = ['content' => $item['body'], 'mediaType' => "text/bbcode"];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue