mirror of
https://github.com/friendica/friendica
synced 2025-04-27 05:50:10 +00:00
The tag table is now really used
This commit is contained in:
parent
af97df96bd
commit
5df5e9521b
9 changed files with 121 additions and 93 deletions
|
@ -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
|
||||
);
|
||||
|
|
|
@ -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'])) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue