*/
public static function normalizeMentionLinks(string $body): string
{
- return preg_replace('%\[url=([^\[\]]*)]([#@!])(.*?)\[/url]%ism', '$2[url=$1]$3[/url]', $body);
+ $body = preg_replace('%\[url=([^\[\]]*)]([#@!])(.*?)\[/url]%ism', '$2[url=$1]$3[/url]', $body);
+ $body = preg_replace('%([#@!])\[zrl=([^\[\]]*)](.*?)\[/zrl]%ism', '$1[url=$2]$3[/url]', $body);
+ return $body;
}
/**
$item['changed'] = DateTimeFormat::utcNow();
$item['edited'] = DateTimeFormat::utc($activity['updated']);
+ Post\Media::deleteByURIId($item['uri-id'], [Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE, Post\Media::HTML]);
$item = self::processContent($activity, $item);
if (empty($item)) {
Queue::remove($activity);
{
try {
$curlResult = HTTPSignature::fetchRaw($url, 0);
- } catch (\Throwable $th) {
- Logger::notice('Error fetching url', ['url' => $url, 'error' => $th]);
+ } catch (\Exception $exception) {
+ Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
return true;
}
Logger::warning('Unknown parent item.', ['uri' => $parent_uri]);
return false;
}
- if (!empty($activity['type']) && in_array($activity['type'], Receiver::CONTENT_TYPES) && ($item['private'] == Item::PRIVATE) && ($parent['private'] != Item::PRIVATE)) {
- Logger::warning('Item is private but the parent is not. Dropping.', ['item-uri' => $item['uri'], 'thr-parent' => $item['thr-parent']]);
- return false;
- }
-
$content = self::removeImplicitMentionsFromBody($content, $parent);
}
$item['content-warning'] = HTML::toBBCode($activity['summary'] ?? '');
return true;
}
- if (in_array($activity['completion-mode'] ?? Receiver::COMPLETION_NONE, [Receiver::COMPLETION_MANUAL, Receiver::COMPLETION_ANNOUCE])) {
+ if (in_array($activity['completion-mode'] ?? Receiver::COMPLETION_NONE, [Receiver::COMPLETION_MANUAL, Receiver::COMPLETION_ANNOUNCE])) {
// Manual completions and completions caused by reshares are allowed without any further checks.
Logger::debug('Message is in completion mode - accepted', ['mode' => $activity['completion-mode'], 'uri-id' => $item['uri-id'], 'guid' => $item['guid'], 'url' => $item['uri']]);
return true;
$name = Receiver::PUBLIC_COLLECTION;
} elseif ($path = parse_url($receiver, PHP_URL_PATH)) {
$name = trim($path, '/');
+ } elseif ($host = parse_url($receiver, PHP_URL_HOST)) {
+ $name = $host;
} else {
- Logger::warning('Unable to coerce name from receiver', ['receiver' => $receiver]);
+ Logger::warning('Unable to coerce name from receiver', ['element' => $element, 'type' => $type, 'receiver' => $receiver]);
$name = '';
}