More preparations for term to tag transition

This commit is contained in:
Michael 2020-04-26 16:15:39 +00:00
parent 5df5e9521b
commit 7f5f68a904
11 changed files with 33 additions and 21 deletions

View file

@ -29,7 +29,6 @@
*/
use Friendica\App;
use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
@ -396,7 +395,7 @@ function item_post(App $a) {
foreach ($tags as $tag) {
$tag_type = substr($tag, 0, 1);
if ($tag_type == Term::TAG_CHARACTER[Term::HASHTAG]) {
if ($tag_type == Tag::TAG_CHARACTER[Tag::HASHTAG]) {
continue;
}
@ -421,9 +420,9 @@ function item_post(App $a) {
$tagged[] = $tag;
}
// When the forum is private or the forum is addressed with a "!" make the post private
if (is_array($success['contact']) && (!empty($success['contact']['prv']) || ($tag_type == Term::TAG_CHARACTER[Term::EXCLUSIVE_MENTION]))) {
if (is_array($success['contact']) && (!empty($success['contact']['prv']) || ($tag_type == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]))) {
$private_forum = $success['contact']['prv'];
$only_to_forum = ($tag_type == Term::TAG_CHARACTER[Term::EXCLUSIVE_MENTION]);
$only_to_forum = ($tag_type == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]);
$private_id = $success['contact']['id'];
$forum_contact = $success['contact'];
} elseif (is_array($success['contact']) && !empty($success['contact']['forum']) &&
@ -907,7 +906,7 @@ function handle_tag(&$body, &$inform, &$str_tags, $profile_uid, $tag, $network =
$r = null;
//is it a person tag?
if (Term::isType($tag, Term::MENTION, Term::IMPLICIT_MENTION, Term::EXCLUSIVE_MENTION)) {
if (Term::isType($tag, Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION)) {
$tag_type = substr($tag, 0, 1);
//is it already replaced?
if (strpos($tag, '[url=')) {
@ -1050,7 +1049,7 @@ function item_add_implicit_mentions(array $tags, array $thread_parent_contact, $
if (DI::config()->get('system', 'disable_implicit_mentions')) {
// Add a tag if the parent contact is from ActivityPub or OStatus (This will notify them)
if (in_array($thread_parent_contact['network'], [Protocol::OSTATUS, Protocol::ACTIVITYPUB])) {
$contact = Term::TAG_CHARACTER[Term::MENTION] . '[url=' . $thread_parent_contact['url'] . ']' . $thread_parent_contact['nick'] . '[/url]';
$contact = Tag::TAG_CHARACTER[Tag::MENTION] . '[url=' . $thread_parent_contact['url'] . ']' . $thread_parent_contact['nick'] . '[/url]';
if (!stripos(implode($tags), '[url=' . $thread_parent_contact['url'] . ']')) {
$tags[] = $contact;
}
@ -1060,7 +1059,7 @@ function item_add_implicit_mentions(array $tags, array $thread_parent_contact, $
$thread_parent_contact['url'] => $thread_parent_contact['nick']
];
$parent_terms = Term::tagArrayFromItemId($thread_parent_id, [Term::MENTION, Term::IMPLICIT_MENTION]);
$parent_terms = Term::tagArrayFromItemId($thread_parent_id, [Tag::MENTION, Tag::IMPLICIT_MENTION]);
foreach ($parent_terms as $parent_term) {
$implicit_mentions[$parent_term['url']] = $parent_term['term'];
@ -1068,7 +1067,7 @@ function item_add_implicit_mentions(array $tags, array $thread_parent_contact, $
foreach ($implicit_mentions as $url => $label) {
if ($url != \Friendica\Model\Profile::getMyURL() && !stripos(implode($tags), '[url=' . $url . ']')) {
$tags[] = Term::TAG_CHARACTER[Term::IMPLICIT_MENTION] . '[url=' . $url . ']' . $label . '[/url]';
$tags[] = Tag::TAG_CHARACTER[Tag::IMPLICIT_MENTION] . '[url=' . $url . ']' . $label . '[/url]';
}
}
}

View file

@ -38,6 +38,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Model\Tag;
use Friendica\Model\Term;
use Friendica\Module\Security\Login;
use Friendica\Util\DateTimeFormat;
@ -793,7 +794,7 @@ function networkThreadedView(App $a, $update, $parent)
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
WHERE `item`.`uid` = 0 AND `item`.$ordering < ? AND `item`.$ordering > ? AND `item`.`gravity` = ?
AND NOT `author`.`hidden` AND NOT `author`.`blocked`" . $sql_tag_nets,
local_user(), Term::OBJECT_TYPE_POST, Term::HASHTAG,
local_user(), Term::OBJECT_TYPE_POST, Tag::HASHTAG,
$top_limit, $bottom_limit, GRAVITY_PARENT);
$data = DBA::toArray($items);

View file

@ -183,7 +183,7 @@ EOT;
q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)",
intval($item['id']),
$term_objtype,
Term::HASHTAG,
Tag::HASHTAG,
DBA::escape($term),
'',
intval($owner_uid)
@ -205,7 +205,7 @@ EOT;
q("INSERT INTO term (`oid`, `otype`, `type`, `term`, `url`, `uid`) VALUE (%d, %d, %d, '%s', '%s', %d)",
intval($original_item['id']),
$term_objtype,
Term::HASHTAG,
Tag::HASHTAG,
DBA::escape($term),
'',
intval($owner_uid)