1
0
Fork 0

The tag table is now really used

This commit is contained in:
Michael 2020-04-26 15:24:58 +00:00
commit 5df5e9521b
9 changed files with 121 additions and 93 deletions

View file

@ -35,7 +35,6 @@ use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\Mail;
use Friendica\Model\Tag;
use Friendica\Model\Term;
use Friendica\Model\User;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
@ -1016,7 +1015,7 @@ class Processor
return [];
}
$parent_terms = Term::tagArrayFromItemId($parent['id'], [Term::MENTION, Term::IMPLICIT_MENTION]);
$parent_terms = Tag::ArrayFromURIId($parent['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
$parent_author = Contact::getDetailsByURL($parent['author-link'], 0);
@ -1084,8 +1083,8 @@ class Processor
foreach ($activity_tags as $index => $tag) {
if (in_array($tag['href'], $potential_mentions)) {
$activity_tags[$index]['name'] = preg_replace(
'/' . preg_quote(Term::TAG_CHARACTER[Term::MENTION], '/') . '/',
Term::TAG_CHARACTER[Term::IMPLICIT_MENTION],
'/' . preg_quote(Tag::TAG_CHARACTER[Tag::MENTION], '/') . '/',
Tag::TAG_CHARACTER[Tag::IMPLICIT_MENTION],
$activity_tags[$index]['name'],
1
);

View file

@ -36,7 +36,7 @@ use Friendica\Model\Conversation;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Model\Photo;
use Friendica\Model\Term;
use Friendica\Model\Tag;
use Friendica\Model\User;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
@ -405,7 +405,7 @@ class Transmitter
$actor_profile = APContact::getByURL($item['author-link']);
}
$terms = Term::tagArrayFromItemId($item['id'], [Term::MENTION, Term::IMPLICIT_MENTION]);
$terms = Tag::ArrayFromURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
if ($item['private'] != Item::PRIVATE) {
// Directly mention the original author upon a quoted reshare.
@ -1007,12 +1007,12 @@ class Transmitter
{
$tags = [];
$terms = Term::tagArrayFromItemId($item['id'], [Term::HASHTAG, Term::MENTION, Term::IMPLICIT_MENTION]);
$terms = Tag::ArrayFromURIId($item['uri-id'], [Tag::HASHTAG, Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
foreach ($terms as $term) {
if ($term['type'] == Term::HASHTAG) {
if ($term['type'] == Tag::HASHTAG) {
$url = DI::baseUrl() . '/search?tag=' . urlencode($term['term']);
$tags[] = ['type' => 'Hashtag', 'href' => $url, 'name' => '#' . $term['term']];
} elseif ($term['type'] == Term::MENTION || $term['type'] == Term::IMPLICIT_MENTION) {
} else {
$contact = Contact::getDetailsByURL($term['url']);
if (!empty($contact['addr'])) {
$mention = '@' . $contact['addr'];
@ -1211,15 +1211,14 @@ class Transmitter
/**
* Returns if the post contains sensitive content ("nsfw")
*
* @param integer $item_id
* @param integer $uri_id
*
* @return boolean
* @throws \Exception
*/
private static function isSensitive($item_id)
private static function isSensitive($uri_id)
{
$condition = ['otype' => Term::OBJECT_TYPE_POST, 'oid' => $item_id, 'type' => Term::HASHTAG, 'term' => 'nsfw'];
return DBA::exists('term', $condition);
return DBA::exists('tag-view', ['uri-id' => $uri_id, 'name' => 'nsfw']);
}
/**
@ -1301,7 +1300,7 @@ class Transmitter
$data['url'] = $item['plink'];
$data['attributedTo'] = $item['author-link'];
$data['sensitive'] = self::isSensitive($item['id']);
$data['sensitive'] = self::isSensitive($item['uri-id']);
$data['context'] = self::fetchContextURLForItem($item);
if (!empty($item['title'])) {

View file

@ -38,9 +38,7 @@ use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\ItemDeliveryData;
use Friendica\Model\Mail;
use Friendica\Model\Profile;
use Friendica\Model\Tag;
use Friendica\Model\Term;
use Friendica\Model\User;
use Friendica\Network\Probe;
use Friendica\Util\Crypto;
@ -114,7 +112,7 @@ class Diaspora
if (DI::config()->get("system", "relay_directly", false)) {
// We distribute our stuff based on the parent to ensure that the thread will be complete
$parent = Item::selectFirst(['parent'], ['id' => $item_id]);
$parent = Item::selectFirst(['uri-id'], ['id' => $item_id]);
if (!DBA::isResult($parent)) {
return;
}
@ -126,12 +124,12 @@ class Diaspora
}
// All tags of the current post
$condition = ['otype' => Term::OBJECT_TYPE_POST, 'type' => Term::HASHTAG, 'oid' => $parent['parent']];
$tags = DBA::select('term', ['term'], $condition);
$tags = DBA::select('tag-view', ['term'], ['uri-id' => $parent['uri-id'], 'type' => Tag::HASHTAG]);
$taglist = [];
while ($tag = DBA::fetch($tags)) {
$taglist[] = $tag['term'];
$taglist[] = $tag['name'];
}
DBA::close($tags);
// All servers who wants content with this tag
$tagserverlist = [];