Store implicit mentions

This commit is contained in:
Michael 2020-04-20 05:43:13 +00:00
parent f4543b2cf7
commit 21103a5735
3 changed files with 19 additions and 9 deletions

View file

@ -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)]); Logger::info('Stored tag/mention', ['uri-id' => $uriid, 'tag-id' => $tagid, 'contact-id' => $cid, 'callstack' => System::callstack(8)]);
} }

View file

@ -407,6 +407,7 @@ class Processor
$item['tag'] = self::constructTagString($activity['tags'], $activity['sensitive']); $item['tag'] = self::constructTagString($activity['tags'], $activity['sensitive']);
Tag::storeFromBody($item['uri-id'], $item['body'], '@!');
self::storeTags($item['uri-id'], $activity['tags']); self::storeTags($item['uri-id'], $activity['tags']);
$item['location'] = $activity['location']; $item['location'] = $activity['location'];
@ -602,9 +603,8 @@ class Processor
Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION], Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION],
Tag::TAG_CHARACTER[Tag::IMPLICIT_MENTION]])) { Tag::TAG_CHARACTER[Tag::IMPLICIT_MENTION]])) {
$tag['name'] = substr($tag['name'], 1); $tag['name'] = substr($tag['name'], 1);
} else {
$hash = '#';
} }
$type = Tag::IMPLICIT_MENTION;
if (!empty($tag['href'])) { if (!empty($tag['href'])) {
$apcontact = APContact::getByURL($tag['href']); $apcontact = APContact::getByURL($tag['href']);
@ -613,18 +613,17 @@ class Processor
} }
} }
} elseif ($tag['type'] == 'Hashtag') { } 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); $tag['name'] = substr($tag['name'], 1);
} else {
$hash = '@';
} }
$type = Tag::HASHTAG;
} }
if (empty($tag['name'])) { if (empty($tag['name'])) {
continue; continue;
} }
Tag::storeByHash($uriid, $hash, $tag['name'], $tag['href']); Tag::store($uriid, $type, $tag['name'], $tag['href']);
} }
} }

View file

@ -2410,7 +2410,7 @@ class DFRN
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]); $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" // 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)); $dsprsig = XML::unescape(XML::getFirstNodeValue($xpath, "dfrn:diaspora_signature/text()", $entry));
@ -2466,7 +2466,7 @@ class DFRN
$item["tag"] .= $termhash . "[url=" . $termurl . "]" . $term . "[/url]"; $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);
} }
} }
} }