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