mirror of
https://github.com/friendica/friendica
synced 2024-12-22 18:40:17 +00:00
"media" is added to the search text
This commit is contained in:
parent
7faa42882b
commit
fc05daefb5
2 changed files with 27 additions and 8 deletions
|
@ -71,6 +71,10 @@ Alternatives are presented with "|".
|
|||
* source:service | source:news - The posts originates from a service account. This source type is often used to mark bot accounts.
|
||||
* source:application | source:relay - The post is created by an application. This is most likely unused in the fediverse for post creation.
|
||||
* tag - Use "tag:tagname" to search for a specific tag.
|
||||
* media - With this keyword you can search for attached media.
|
||||
* media:image | media:photo | media:picture - The post contains an image
|
||||
* media:video - The post contains a video
|
||||
* media:audio - The post contains audio
|
||||
* network | net - Use this to include or exclude some networks from your channel.
|
||||
* network:apub | network:activitypub - ActivityPub (Used by the systems in the Fediverse)
|
||||
* network:dfrn | network:friendica - Legacy Friendica protocol. Nowayday Friendica mostly uses ActivityPub.
|
||||
|
|
|
@ -39,10 +39,12 @@ use Friendica\Util\DateTimeFormat;
|
|||
|
||||
class Engagement
|
||||
{
|
||||
const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language'];
|
||||
const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language', 'media'];
|
||||
const SHORTCUTS = ['lang' => 'language', 'net' => 'network', 'relay' => 'application'];
|
||||
const ALTERNATIVES = ['source:news' => 'source:service', 'source:relay' => 'source:application',
|
||||
'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn', 'network:diaspora' => 'network:dspr', 'network:ostatus' => 'network:stat',
|
||||
'media:picture' => 'media:image', 'media:photo' => 'media:image',
|
||||
'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn',
|
||||
'network:diaspora' => 'network:dspr', 'network:ostatus' => 'network:stat',
|
||||
'network:discourse' => 'network:dscs', 'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky'];
|
||||
|
||||
/**
|
||||
|
@ -93,7 +95,7 @@ class Engagement
|
|||
$store = !empty($mediatype);
|
||||
}
|
||||
|
||||
$searchtext = self::getSearchTextForItem($parent);
|
||||
$searchtext = self::getSearchTextForItem($parent, $mediatype);
|
||||
$language = !empty($parent['language']) ? (array_key_first(json_decode($parent['language'], true)) ?? L10n::UNDETERMINED_LANGUAGE) : L10n::UNDETERMINED_LANGUAGE;
|
||||
if (!$store) {
|
||||
$store = DI::userDefinedChannel()->match($searchtext, $language);
|
||||
|
@ -172,7 +174,7 @@ class Engagement
|
|||
}
|
||||
}
|
||||
|
||||
return self::getSearchText($item, $receivers, $tags);
|
||||
return self::getSearchText($item, $receivers, $tags, 0);
|
||||
}
|
||||
|
||||
public static function getSearchTextForUriId(int $uri_id, bool $refresh = false): string
|
||||
|
@ -190,17 +192,18 @@ class Engagement
|
|||
if (empty($post['uri-id'])) {
|
||||
return '';
|
||||
}
|
||||
return self::getSearchTextForItem($post);
|
||||
$mediatype = self::getMediaType($uri_id);
|
||||
return self::getSearchTextForItem($post, $mediatype);
|
||||
}
|
||||
|
||||
private static function getSearchTextForItem(array $item): string
|
||||
private static function getSearchTextForItem(array $item, int $mediatype): string
|
||||
{
|
||||
$receivers = array_column(Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION, Tag::AUDIENCE]), 'url');
|
||||
$tags = array_column(Tag::getByURIId($item['uri-id'], [Tag::HASHTAG]), 'name');
|
||||
return self::getSearchText($item, $receivers, $tags);
|
||||
return self::getSearchText($item, $receivers, $tags, $mediatype);
|
||||
}
|
||||
|
||||
private static function getSearchText(array $item, array $receivers, array $tags): string
|
||||
private static function getSearchText(array $item, array $receivers, array $tags, int $mediatype): string
|
||||
{
|
||||
$body = '[nosmile]network_' . $item['network'];
|
||||
|
||||
|
@ -286,6 +289,18 @@ class Engagement
|
|||
$body .= ' language_' . array_key_first($languages);
|
||||
}
|
||||
|
||||
if ($mediatype & 1) {
|
||||
$body .= ' media_image';
|
||||
}
|
||||
|
||||
if ($mediatype & 2) {
|
||||
$body .= ' media_video';
|
||||
}
|
||||
|
||||
if ($mediatype & 4) {
|
||||
$body .= ' media_audio';
|
||||
}
|
||||
|
||||
$body .= ' ' . $item['title'] . ' ' . $item['content-warning'] . ' ' . $item['body'];
|
||||
|
||||
return BBCode::toSearchText($body, $item['uri-id']);
|
||||
|
|
Loading…
Reference in a new issue