Moved the share interpretation
This commit is contained in:
parent
1ef5730d3d
commit
ef934db614
|
@ -1021,6 +1021,19 @@ class BBCode
|
||||||
public static function fetchShareAttributes(string $text): array
|
public static function fetchShareAttributes(string $text): array
|
||||||
{
|
{
|
||||||
DI::profiler()->startRecording('rendering');
|
DI::profiler()->startRecording('rendering');
|
||||||
|
if (preg_match('#(.*?)\[share](.*)\[/share]#', $text, $matches)) {
|
||||||
|
return [
|
||||||
|
'author' => '',
|
||||||
|
'profile' => '',
|
||||||
|
'avatar' => '',
|
||||||
|
'link' => '',
|
||||||
|
'posted' => '',
|
||||||
|
'guid' => '',
|
||||||
|
'message_id' => $matches[2],
|
||||||
|
'comment' => trim($matches[1]),
|
||||||
|
'shared' => '',
|
||||||
|
];
|
||||||
|
}
|
||||||
// See Issue https://github.com/friendica/friendica/issues/10454
|
// See Issue https://github.com/friendica/friendica/issues/10454
|
||||||
// Hashtags in usernames are expanded to links. This here is a quick fix.
|
// Hashtags in usernames are expanded to links. This here is a quick fix.
|
||||||
$text = preg_replace('~([@!#])\[url=.*?](.*?)\[/url]~ism', '$1$2', $text);
|
$text = preg_replace('~([@!#])\[url=.*?](.*?)\[/url]~ism', '$1$2', $text);
|
||||||
|
|
|
@ -3666,19 +3666,10 @@ class Item
|
||||||
*/
|
*/
|
||||||
public static function improveSharedDataInBody(array $item): string
|
public static function improveSharedDataInBody(array $item): string
|
||||||
{
|
{
|
||||||
if (preg_match('#\[share](.*)\[/share]#', $item['body'], $matches)) {
|
$shared = BBCode::fetchShareAttributes($item['body']);
|
||||||
$shared = [
|
if (empty($shared['link']) && empty($shared['message_id'])) {
|
||||||
'message_id' => $matches[1],
|
return $item['body'];
|
||||||
'link' => '',
|
}
|
||||||
'guid' => '',
|
|
||||||
'profile' => '',
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
$shared = BBCode::fetchShareAttributes($item['body']);
|
|
||||||
if (empty($shared['link']) && empty($shared['message_id'])) {
|
|
||||||
return $item['body'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = self::fetchByLink($shared['link'] ?: $shared['message_id']);
|
$id = self::fetchByLink($shared['link'] ?: $shared['message_id']);
|
||||||
Logger::debug('Fetched shared post', ['uri-id' => $item['uri-id'], 'id' => $id, 'author' => $shared['profile'], 'url' => $shared['link'], 'guid' => $shared['guid'], 'uri' => $shared['message_id'], 'callstack' => System::callstack()]);
|
Logger::debug('Fetched shared post', ['uri-id' => $item['uri-id'], 'id' => $id, 'author' => $shared['profile'], 'url' => $shared['link'], 'guid' => $shared['guid'], 'uri' => $shared['message_id'], 'callstack' => System::callstack()]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user