Store implicit mentions

2022.09-rc
Michael 2020-04-20 05:43:13 +00:00
rodzic f4543b2cf7
commit 21103a5735
3 zmienionych plików z 19 dodań i 9 usunięć

Wyświetl plik

@ -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)]);
}

Wyświetl plik

@ -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']);
}
}

Wyświetl plik

@ -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);
}
}
}