use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\Item;
+use Friendica\Model\ItemURI;
use Friendica\Model\Profile;
use Friendica\Model\Photo;
-use Friendica\Model\Term;
+use Friendica\Model\Tag;
use Friendica\Model\User;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
class Transmitter
{
/**
- * collects the lost of followers of the given owner
+ * Collects a list of contacts of the given owner
*
- * @param array $owner Owner array
- * @param integer $page Page number
+ * @param array $owner Owner array
+ * @param int|array $rel The relevant value(s) contact.rel should match
+ * @param string $module The name of the relevant AP endpoint module (followers|following)
+ * @param integer $page Page number
*
* @return array of owners
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \Exception
*/
- public static function getFollowers($owner, $page = null)
+ public static function getContacts($owner, $rel, $module, $page = null)
{
- $condition = ['rel' => [Contact::FOLLOWER, Contact::FRIEND], 'network' => Protocol::FEDERATED, 'uid' => $owner['uid'],
- 'self' => false, 'deleted' => false, 'hidden' => false, 'archive' => false, 'pending' => false];
- $count = DBA::count('contact', $condition);
-
- $data = ['@context' => ActivityPub::CONTEXT];
- $data['id'] = DI::baseUrl() . '/followers/' . $owner['nickname'];
- $data['type'] = 'OrderedCollection';
- $data['totalItems'] = $count;
-
- // When we hide our friends we will only show the pure number but don't allow more.
- $profile = Profile::getByUID($owner['uid']);
- if (!empty($profile['hide-friends'])) {
- return $data;
- }
-
- if (empty($page)) {
- $data['first'] = DI::baseUrl() . '/followers/' . $owner['nickname'] . '?page=1';
- } else {
- $data['type'] = 'OrderedCollectionPage';
- $list = [];
-
- $contacts = DBA::select('contact', ['url'], $condition, ['limit' => [($page - 1) * 100, 100]]);
- while ($contact = DBA::fetch($contacts)) {
- $list[] = $contact['url'];
- }
+ $parameters = [
+ 'rel' => $rel,
+ 'uid' => $owner['uid'],
+ 'self' => false,
+ 'deleted' => false,
+ 'hidden' => false,
+ 'archive' => false,
+ 'pending' => false
+ ];
+ $condition = DBA::buildCondition($parameters);
- if (!empty($list)) {
- $data['next'] = DI::baseUrl() . '/followers/' . $owner['nickname'] . '?page=' . ($page + 1);
- }
+ $sql = "SELECT COUNT(*) as `count`
+ FROM `contact`
+ JOIN `apcontact` ON `apcontact`.`url` = `contact`.`url`
+ " . $condition;
- $data['partOf'] = DI::baseUrl() . '/followers/' . $owner['nickname'];
+ $contacts = DBA::fetchFirst($sql, ...$parameters);
- $data['orderedItems'] = $list;
- }
-
- return $data;
- }
-
- /**
- * Create list of following contacts
- *
- * @param array $owner Owner array
- * @param integer $page Page numbe
- *
- * @return array of following contacts
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
- */
- public static function getFollowing($owner, $page = null)
- {
- $condition = ['rel' => [Contact::SHARING, Contact::FRIEND], 'network' => Protocol::FEDERATED, 'uid' => $owner['uid'],
- 'self' => false, 'deleted' => false, 'hidden' => false, 'archive' => false, 'pending' => false];
- $count = DBA::count('contact', $condition);
+ $modulePath = '/' . $module . '/';
$data = ['@context' => ActivityPub::CONTEXT];
- $data['id'] = DI::baseUrl() . '/following/' . $owner['nickname'];
+ $data['id'] = DI::baseUrl() . $modulePath . $owner['nickname'];
$data['type'] = 'OrderedCollection';
- $data['totalItems'] = $count;
+ $data['totalItems'] = $contacts['count'];
// When we hide our friends we will only show the pure number but don't allow more.
$profile = Profile::getByUID($owner['uid']);
}
if (empty($page)) {
- $data['first'] = DI::baseUrl() . '/following/' . $owner['nickname'] . '?page=1';
+ $data['first'] = DI::baseUrl() . $modulePath . $owner['nickname'] . '?page=1';
} else {
$data['type'] = 'OrderedCollectionPage';
$list = [];
- $contacts = DBA::select('contact', ['url'], $condition, ['limit' => [($page - 1) * 100, 100]]);
+ $sql = "SELECT `contact`.`url`
+ FROM `contact`
+ JOIN `apcontact` ON `apcontact`.`url` = `contact`.`url`
+ " . $condition . "
+ LIMIT ?, ?";
+
+ $parameters[] = ($page - 1) * 100;
+ $parameters[] = 100;
+
+ $contacts = DBA::p($sql, ...$parameters);
while ($contact = DBA::fetch($contacts)) {
$list[] = $contact['url'];
}
+ DBA::close($contacts);
if (!empty($list)) {
- $data['next'] = DI::baseUrl() . '/following/' . $owner['nickname'] . '?page=' . ($page + 1);
+ $data['next'] = DI::baseUrl() . $modulePath . $owner['nickname'] . '?page=' . ($page + 1);
}
- $data['partOf'] = DI::baseUrl() . '/following/' . $owner['nickname'];
+ $data['partOf'] = DI::baseUrl() . $modulePath . $owner['nickname'];
$data['orderedItems'] = $list;
}
*/
public static function getOutbox($owner, $page = null)
{
- $public_contact = Contact::getIdForURL($owner['url'], 0, true);
+ $public_contact = Contact::getIdForURL($owner['url']);
$condition = ['uid' => 0, 'contact-id' => $public_contact, 'author-id' => $public_contact,
'private' => [Item::PUBLIC, Item::UNLISTED], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
$items = Item::select(['id'], $condition, ['limit' => [($page - 1) * 20, 20], 'order' => ['created' => true]]);
while ($item = Item::fetch($items)) {
$activity = self::createActivityFromItem($item['id'], true);
+ $activity['type'] = $activity['type'] == 'Update' ? 'Create' : $activity['type'];
+
// Only list "Create" activity objects here, no reshares
- if (is_array($activity['object']) && ($activity['type'] == 'Create')) {
+ if (!empty($activity['object']) && ($activity['type'] == 'Create')) {
$list[] = $activity['object'];
}
}
*/
public static function getProfile($uid)
{
- $condition = ['uid' => $uid, 'blocked' => false, 'account_expired' => false,
- 'account_removed' => false, 'verified' => true];
- $fields = ['guid', 'nickname', 'pubkey', 'account-type', 'page-flags'];
- $user = DBA::selectFirst('user', $fields, $condition);
- if (!DBA::isResult($user)) {
- return [];
- }
+ if ($uid != 0) {
+ $condition = ['uid' => $uid, 'blocked' => false, 'account_expired' => false,
+ 'account_removed' => false, 'verified' => true];
+ $fields = ['guid', 'nickname', 'pubkey', 'account-type', 'page-flags'];
+ $user = DBA::selectFirst('user', $fields, $condition);
+ if (!DBA::isResult($user)) {
+ return [];
+ }
- $fields = ['locality', 'region', 'country-name'];
- $profile = DBA::selectFirst('profile', $fields, ['uid' => $uid]);
- if (!DBA::isResult($profile)) {
- return [];
- }
+ $fields = ['locality', 'region', 'country-name'];
+ $profile = DBA::selectFirst('profile', $fields, ['uid' => $uid]);
+ if (!DBA::isResult($profile)) {
+ return [];
+ }
- $fields = ['name', 'url', 'location', 'about', 'avatar', 'photo'];
- $contact = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
- if (!DBA::isResult($contact)) {
- return [];
+ $fields = ['name', 'url', 'location', 'about', 'avatar', 'photo'];
+ $contact = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
+ if (!DBA::isResult($contact)) {
+ return [];
+ }
+ } else {
+ $contact = User::getSystemAccount();
+ $user = ['guid' => '', 'nickname' => $contact['nick'], 'pubkey' => $contact['pubkey'],
+ 'account-type' => $contact['contact-type'], 'page-flags' => User::PAGE_FLAGS_NORMAL];
+ $profile = ['locality' => '', 'region' => '', 'country-name' => ''];
}
$data = ['@context' => ActivityPub::CONTEXT];
$data['id'] = $contact['url'];
- $data['diaspora:guid'] = $user['guid'];
+
+ if (!empty($user['guid'])) {
+ $data['diaspora:guid'] = $user['guid'];
+ }
+
$data['type'] = ActivityPub::ACCOUNT_TYPES[$user['account-type']];
- $data['following'] = DI::baseUrl() . '/following/' . $user['nickname'];
- $data['followers'] = DI::baseUrl() . '/followers/' . $user['nickname'];
- $data['inbox'] = DI::baseUrl() . '/inbox/' . $user['nickname'];
- $data['outbox'] = DI::baseUrl() . '/outbox/' . $user['nickname'];
+
+ if ($uid != 0) {
+ $data['following'] = DI::baseUrl() . '/following/' . $user['nickname'];
+ $data['followers'] = DI::baseUrl() . '/followers/' . $user['nickname'];
+ $data['inbox'] = DI::baseUrl() . '/inbox/' . $user['nickname'];
+ $data['outbox'] = DI::baseUrl() . '/outbox/' . $user['nickname'];
+ } else {
+ $data['inbox'] = DI::baseUrl() . '/friendica/inbox';
+ }
+
$data['preferredUsername'] = $user['nickname'];
$data['name'] = $contact['name'];
- $data['vcard:hasAddress'] = ['@type' => 'vcard:Home', 'vcard:country-name' => $profile['country-name'],
- 'vcard:region' => $profile['region'], 'vcard:locality' => $profile['locality']];
- $data['summary'] = BBCode::convert($contact['about'], false);
+
+ if (!empty($profile['country-name'] . $profile['region'] . $profile['locality'])) {
+ $data['vcard:hasAddress'] = ['@type' => 'vcard:Home', 'vcard:country-name' => $profile['country-name'],
+ 'vcard:region' => $profile['region'], 'vcard:locality' => $profile['locality']];
+ }
+
+ if (!empty($contact['about'])) {
+ $data['summary'] = BBCode::convert($contact['about'], false);
+ }
+
$data['url'] = $contact['url'];
$data['manuallyApprovesFollowers'] = in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
$data['publicKey'] = ['id' => $contact['url'] . '#main-key',
}
$always_bcc = false;
+ $isforum = false;
// Check if we should always deliver our stuff via BCC
if (!empty($item['uid'])) {
- $profile = Profile::getByUID($item['uid']);
+ $profile = User::getOwnerDataById($item['uid']);
if (!empty($profile)) {
$always_bcc = $profile['hide-friends'];
+ $isforum = $profile['account-type'] == User::ACCOUNT_TYPE_COMMUNITY;
}
}
$always_bcc = true;
}
- if (self::isAnnounce($item) || DI::config()->get('debug', 'total_ap_delivery')) {
+ if ((self::isAnnounce($item) && !$isforum) || DI::config()->get('debug', 'total_ap_delivery')) {
// Will be activated in a later step
$networks = Protocol::FEDERATED;
} else {
$actor_profile = APContact::getByURL($item['author-link']);
}
- $terms = Term::tagArrayFromItemId($item['id'], [Term::MENTION, Term::IMPLICIT_MENTION]);
+ $terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
if ($item['private'] != Item::PRIVATE) {
// Directly mention the original author upon a quoted reshare.
continue;
}
+ if ($isforum && DBA::isResult($contact) && ($contact['dfrn'] == Protocol::DFRN)) {
+ continue;
+ }
+
if (!empty($profile = APContact::getByURL($contact['url'], false))) {
$data['to'][] = $profile['url'];
}
continue;
}
+ if ($isforum && DBA::isResult($contact) && ($contact['dfrn'] == Protocol::DFRN)) {
+ continue;
+ }
+
if (!empty($profile = APContact::getByURL($contact['url'], false))) {
if ($contact['hidden'] || $always_bcc) {
$data['bcc'][] = $profile['url'];
if ($item['gravity'] != GRAVITY_PARENT) {
// Comments to forums are directed to the forum
// But comments to forums aren't directed to the followers collection
- if ($profile['type'] == 'Group') {
+ // This rule is only valid when the actor isn't the forum.
+ // The forum needs to transmit their content to their followers.
+ if (($profile['type'] == 'Group') && ($profile['url'] != $actor_profile['url'])) {
$data['to'][] = $profile['url'];
} else {
$data['cc'][] = $profile['url'];
- if (($item['private'] != Item::PRIVATE) && $item['private'] && !empty($actor_profile['followers'])) {
+ if (($item['private'] != Item::PRIVATE) && !empty($actor_profile['followers'])) {
$data['cc'][] = $actor_profile['followers'];
}
}
{
$inboxes = [];
+ $isforum = false;
+
+ if (!empty($item['uid'])) {
+ $profile = User::getOwnerDataById($item['uid']);
+ if (!empty($profile)) {
+ $isforum = $profile['account-type'] == User::ACCOUNT_TYPE_COMMUNITY;
+ }
+ }
+
if (DI::config()->get('debug', 'total_ap_delivery')) {
// Will be activated in a later step
$networks = Protocol::FEDERATED;
continue;
}
+ if ($isforum && ($contact['dfrn'] == Protocol::DFRN)) {
+ continue;
+ }
+
if (Network::isUrlBlocked($contact['url'])) {
continue;
}
$item_profile = APContact::getByURL($item['owner-link'], false);
}
+ if (empty($item_profile)) {
+ return [];
+ }
+
+ $profile_uid = User::getIdForURL($item_profile['url']);
+
foreach (['to', 'cc', 'bto', 'bcc'] as $element) {
if (empty($permissions[$element])) {
continue;
continue;
}
- if ($receiver == $item_profile['followers']) {
+ if ($item_profile && ($receiver == $item_profile['followers']) && ($uid == $profile_uid)) {
$inboxes = array_merge($inboxes, self::fetchTargetInboxesforUser($uid, $personal));
} else {
if (Contact::isLocal($receiver)) {
return [];
}
+ $mail['uri-id'] = ItemURI::insert(['uri' => $mail['uri'], 'guid' => $mail['guid']]);
+
$reply = DBA::selectFirst('mail', ['uri'], ['parent-uri' => $mail['parent-uri'], 'reply' => false]);
// Making the post more compatible for Mastodon by:
$data = [];
}
- $data['id'] = $mail['uri'] . '#Create';
+ $data['id'] = $mail['uri'] . '/Create';
$data['type'] = 'Create';
$data['actor'] = $mail['author-link'];
$data['published'] = DateTimeFormat::utc($mail['created'] . '+00:00', DateTimeFormat::ATOM);
$type = 'Follow';
} elseif ($item['verb'] == Activity::TAG) {
$type = 'Add';
+ } elseif ($item['verb'] == Activity::ANNOUNCE) {
+ $type = 'Announce';
} else {
$type = '';
}
}
}
- $data = ActivityPub\Transmitter::createActivityFromItem($item_id);
+ $data = self::createActivityFromItem($item_id);
DI::cache()->set($cachekey, $data, Duration::QUARTER_HOUR);
return $data;
*/
public static function createActivityFromItem($item_id, $object_mode = false)
{
+ Logger::info('Fetching activity', ['item' => $item_id]);
$item = Item::selectFirst([], ['id' => $item_id, 'parent-network' => Protocol::NATIVE_SUPPORT]);
-
if (!DBA::isResult($item)) {
return false;
}
+ /// @todo This code should be removed by the end of the year 2020
if ($item['wall'] && ($item['uri'] == $item['parent-uri'])) {
$owner = User::getOwnerDataById($item['uid']);
if (($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) && ($item['author-link'] != $owner['url'])) {
$type = 'Announce';
// Disguise forum posts as reshares. Will later be converted to a real announce
- $item['body'] = share_header($item['author-name'], $item['author-link'], $item['author-avatar'],
- $item['guid'], $item['created'], $item['plink']) . $item['body'] . '[/share]';
+ $item['body'] = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'],
+ $item['plink'], $item['created'], $item['guid']) . $item['body'] . '[/share]';
+ }
+ }
+
+ /*
+ /// @todo This code should be activated by the end of the year 2020
+ // See also "tagDeliver";
+ // In case of a forum post ensure to return the original post if author and forum are on the same machine
+ if (!empty($item['forum_mode'])) {
+ $author = Contact::getById($item['author-id'], ['nurl']);
+ if (!empty($author['nurl'])) {
+ $self = Contact::selectFirst(['uid'], ['nurl' => $author['nurl'], 'self' => true]);
+ if (!empty($self['uid'])) {
+ $item = Item::selectFirst([], ['uri-id' => $item['uri-id'], 'uid' => $self['uid']]);
+ }
}
}
+ */
if (empty($type)) {
$condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB];
$conversation = DBA::selectFirst('conversation', ['source'], $condition);
if (DBA::isResult($conversation)) {
$data = json_decode($conversation['source'], true);
- if (!empty($data)) {
- return $data;
+ if (!empty($data['type'])) {
+ if (in_array($data['type'], ['Create', 'Update'])) {
+ if ($object_mode) {
+ unset($data['@context']);
+ unset($data['signature']);
+ }
+ Logger::info('Return stored conversation', ['item' => $item_id]);
+ return $data;
+ } elseif (in_array('as:' . $data['type'], Receiver::CONTENT_TYPES)) {
+ if (!empty($data['@context'])) {
+ $context = $data['@context'];
+ unset($data['@context']);
+ }
+ unset($data['actor']);
+ $object = $data;
+ }
}
}
}
if (!$object_mode) {
- $data = ['@context' => ActivityPub::CONTEXT];
+ $data = ['@context' => $context ?? ActivityPub::CONTEXT];
if ($item['deleted'] && ($item['gravity'] == GRAVITY_ACTIVITY)) {
$type = 'Undo';
$data = [];
}
- $data['id'] = $item['uri'] . '#' . $type;
+ $data['id'] = $item['uri'] . '/' . $type;
$data['type'] = $type;
- if (Item::isForumPost($item) && ($type != 'Announce')) {
+ if (($type != 'Announce') || ($item['gravity'] != GRAVITY_PARENT)) {
$data['actor'] = $item['author-link'];
} else {
$data['actor'] = $item['owner-link'];
$data = array_merge($data, self::createPermissionBlockForItem($item, false));
if (in_array($data['type'], ['Create', 'Update', 'Delete'])) {
- $data['object'] = self::createNote($item);
+ $data['object'] = $object ?? self::createNote($item);
} elseif ($data['type'] == 'Add') {
$data = self::createAddTag($item, $data);
} elseif ($data['type'] == 'Announce') {
- $data = self::createAnnounce($item, $data);
+ if ($item['verb'] == ACTIVITY::ANNOUNCE) {
+ $data['object'] = $item['thr-parent'];
+ } else {
+ $data = self::createAnnounce($item, $data);
+ }
} elseif ($data['type'] == 'Follow') {
$data['object'] = $item['parent-uri'];
} elseif ($data['type'] == 'Undo') {
$owner = User::getOwnerDataById($uid);
- if (!$object_mode && !empty($owner)) {
+ Logger::info('Fetched activity', ['item' => $item_id, 'uid' => $uid]);
+
+ // We don't sign if we aren't the actor. This is important for relaying content especially for forums
+ if (!$object_mode && !empty($owner) && ($data['actor'] == $owner['url'])) {
return LDSignature::sign($data, $owner);
} else {
return $data;
{
$tags = [];
- $terms = Term::tagArrayFromItemId($item['id'], [Term::HASHTAG, Term::MENTION, Term::IMPLICIT_MENTION]);
+ $terms = Tag::getByURIId($item['uri-id'], [Tag::HASHTAG, Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
foreach ($terms as $term) {
- if ($term['type'] == Term::HASHTAG) {
- $url = DI::baseUrl() . '/search?tag=' . urlencode($term['term']);
- $tags[] = ['type' => 'Hashtag', 'href' => $url, 'name' => '#' . $term['term']];
- } elseif ($term['type'] == Term::MENTION || $term['type'] == Term::IMPLICIT_MENTION) {
- $contact = Contact::getDetailsByURL($term['url']);
+ if ($term['type'] == Tag::HASHTAG) {
+ $url = DI::baseUrl() . '/search?tag=' . urlencode($term['name']);
+ $tags[] = ['type' => 'Hashtag', 'href' => $url, 'name' => '#' . $term['name']];
+ } else {
+ $contact = Contact::getByURL($term['url'], false, ['addr']);
+ if (empty($contact)) {
+ continue;
+ }
if (!empty($contact['addr'])) {
$mention = '@' . $contact['addr'];
} else {
return '';
}
- $data = Contact::getDetailsByURL($match[1]);
+ $data = Contact::getByURL($match[1], false, ['url', 'nick']);
if (empty($data['nick'])) {
return $match[0];
}
/**
* Returns if the post contains sensitive content ("nsfw")
*
- * @param integer $item_id
+ * @param integer $uri_id
*
* @return boolean
* @throws \Exception
*/
- private static function isSensitive($item_id)
+ private static function isSensitive($uri_id)
{
- $condition = ['otype' => TERM_OBJ_POST, 'oid' => $item_id, 'type' => TERM_HASHTAG, 'term' => 'nsfw'];
- return DBA::exists('term', $condition);
+ return DBA::exists('tag-view', ['uri-id' => $uri_id, 'name' => 'nsfw']);
}
/**
{
$event = [];
$event['name'] = $item['event-summary'];
- $event['content'] = BBCode::convert($item['event-desc'], false, 9);
+ $event['content'] = BBCode::convert($item['event-desc'], false, BBCode::ACTIVITYPUB);
$event['startTime'] = DateTimeFormat::utc($item['event-start'] . '+00:00', DateTimeFormat::ATOM);
if (!$item['event-nofinish']) {
$data['url'] = $item['plink'];
$data['attributedTo'] = $item['author-link'];
- $data['sensitive'] = self::isSensitive($item['id']);
+ $data['sensitive'] = self::isSensitive($item['uri-id']);
$data['context'] = self::fetchContextURLForItem($item);
if (!empty($item['title'])) {
$body = $item['body'];
if (empty($item['uid']) || !Feature::isEnabled($item['uid'], 'explicit_mentions')) {
- $body = self::prependMentions($body, $permission_block);
+ $body = self::prependMentions($body, $item['uri-id']);
}
if ($type == 'Note') {
$regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
$body = preg_replace_callback($regexp, ['self', 'mentionCallback'], $body);
- $data['content'] = BBCode::convert($body, false, 9);
+ $data['content'] = BBCode::convert($body, false, BBCode::ACTIVITYPUB);
}
// The regular "content" field does contain a minimized HTML. This is done since systems like
*/
private static function createAddTag($item, $data)
{
- $object = XML::parseString($item['object'], false);
- $target = XML::parseString($item["target"], false);
+ $object = XML::parseString($item['object']);
+ $target = XML::parseString($item["target"]);
$data['diaspora:guid'] = $item['guid'];
$data['actor'] = $item['author-link'];
*/
public static function isAnnounce($item)
{
+ if (!empty($item['verb']) && ($item['verb'] == Activity::ANNOUNCE)) {
+ return true;
+ }
+
$announce = self::getAnnounceArray($item);
if (empty($announce)) {
return false;
HTTPSignature::transmit($signed, $profile['inbox'], $uid);
}
- private static function prependMentions($body, array $permission_block)
+ private static function prependMentions($body, int $uriid)
{
- if (DI::config()->get('system', 'disable_implicit_mentions')) {
- return $body;
- }
-
$mentions = [];
- foreach ($permission_block['to'] as $profile_url) {
- $profile = Contact::getDetailsByURL($profile_url);
+ foreach (Tag::getByURIId($uriid, [Tag::IMPLICIT_MENTION]) as $tag) {
+ $profile = Contact::getByURL($tag['url'], false, ['addr', 'contact-type', 'nick']);
if (!empty($profile['addr'])
&& $profile['contact-type'] != Contact::TYPE_COMMUNITY
&& !strstr($body, $profile['addr'])
- && !strstr($body, $profile_url)
+ && !strstr($body, $tag['url'])
) {
- $mentions[] = '@[url=' . $profile_url . ']' . $profile['nick'] . '[/url]';
+ $mentions[] = '@[url=' . $tag['url'] . ']' . $profile['nick'] . '[/url]';
}
}