<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
return $match[0];
}
- return '[url=' . ($data['alias'] ?: $data['url']) . ']@' . $data['nick'] . '[/url]';
+ return '[url=' . $data['url'] . ']@' . $data['nick'] . '[/url]';
+ }
+
+ /**
+ * Callback function to replace a Friendica style mention in a mention for a summary
+ *
+ * @param array $match Matching values for the callback
+ * @return string Replaced mention
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ private static function mentionAddrCallback($match)
+ {
+ if (empty($match[1])) {
+ return '';
+ }
+
+ $data = Contact::getByURL($match[1], false, ['addr']);
+ if (empty($data['addr'])) {
+ return $match[0];
+ }
+
+ return '@' . $data['addr'];
}
/**
* @return array with the event data
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function createEvent($item)
+ private static function createEvent($item)
{
$event = [];
$event['name'] = $item['event-summary'];
$event['location'] = self::createLocation($item);
}
+ $event['dfrn:adjust'] = (bool)$item['event-adjust'];
+
return $event;
}
if ($type == 'Note') {
$body = $item['raw-body'] ?? self::removePictures($body);
} elseif (($type == 'Article') && empty($data['summary'])) {
- $data['summary'] = BBCode::toPlaintext(Plaintext::shorten(self::removePictures($body), 1000));
+ $regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
+ $summary = preg_replace_callback($regexp, ['self', 'mentionAddrCallback'], $body);
+ $data['summary'] = BBCode::toPlaintext(Plaintext::shorten(self::removePictures($summary), 1000));
}
if (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions')) {