From: Michael Date: Mon, 20 Apr 2020 05:43:13 +0000 (+0000) Subject: Store implicit mentions X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=21103a57355b7fa7c91d8d45d72bd0f3fd6abe13;p=friendica.git Store implicit mentions --- diff --git a/src/Model/Tag.php b/src/Model/Tag.php index 7ef4a2d82e..f99a83daef 100644 --- a/src/Model/Tag.php +++ b/src/Model/Tag.php @@ -115,7 +115,18 @@ class Tag } } - DBA::insert('post-tag', ['uri-id' => $uriid, 'type' => $type, 'tid' => $tagid, 'cid' => $cid], true); + $fields = ['uri-id' => $uriid, 'type' => $type, 'tid' => $tagid, 'cid' => $cid]; + + if (in_array($type, [Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION])) { + $condition = $fields; + $condition['type'] = [Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION]; + if (DBA::exists('post-tag', $condition)) { + Logger::info('Tag already exists', $fields); + return; + } + } + + DBA::insert('post-tag', $fields, true); Logger::info('Stored tag/mention', ['uri-id' => $uriid, 'tag-id' => $tagid, 'contact-id' => $cid, 'callstack' => System::callstack(8)]); } diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index b770e8a0de..2c0176257f 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -407,6 +407,7 @@ class Processor $item['tag'] = self::constructTagString($activity['tags'], $activity['sensitive']); + Tag::storeFromBody($item['uri-id'], $item['body'], '@!'); self::storeTags($item['uri-id'], $activity['tags']); $item['location'] = $activity['location']; @@ -602,9 +603,8 @@ class Processor Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION], Tag::TAG_CHARACTER[Tag::IMPLICIT_MENTION]])) { $tag['name'] = substr($tag['name'], 1); - } else { - $hash = '#'; } + $type = Tag::IMPLICIT_MENTION; if (!empty($tag['href'])) { $apcontact = APContact::getByURL($tag['href']); @@ -613,18 +613,17 @@ class Processor } } } elseif ($tag['type'] == 'Hashtag') { - if (substr($tag['name'], 0, 1) == Term::TAG_CHARACTER[Term::HASHTAG]) { + if ($hash == Tag::TAG_CHARACTER[Tag::HASHTAG]) { $tag['name'] = substr($tag['name'], 1); - } else { - $hash = '@'; } + $type = Tag::HASHTAG; } if (empty($tag['name'])) { continue; } - Tag::storeByHash($uriid, $hash, $tag['name'], $tag['href']); + Tag::store($uriid, $type, $tag['name'], $tag['href']); } } diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 653e5c242b..83010f811e 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -2410,7 +2410,7 @@ class DFRN $item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]); - Tag::storeFromBody($item['uri-id'], $item["body"], '#'); + Tag::storeFromBody($item['uri-id'], $item["body"]); // We store the data from "dfrn:diaspora_signature" in a different table, this is done in "Item::insert" $dsprsig = XML::unescape(XML::getFirstNodeValue($xpath, "dfrn:diaspora_signature/text()", $entry)); @@ -2466,7 +2466,7 @@ class DFRN $item["tag"] .= $termhash . "[url=" . $termurl . "]" . $term . "[/url]"; - Tag::storeByHash($item['uri-id'], $termhash, $term, $termurl); + Tag::store($item['uri-id'], Tag::IMPLICIT_MENTION, $term, $termurl); } } }