Merge remote-tracking branch 'upstream/develop' into issue-13845
This commit is contained in:
commit
0153c2a027
|
@ -75,6 +75,8 @@ Alternatives are presented with "|".
|
||||||
* media:image | media:photo | media:picture - The post contains an image
|
* media:image | media:photo | media:picture - The post contains an image
|
||||||
* media:video - The post contains a video
|
* media:video - The post contains a video
|
||||||
* media:audio - The post contains audio
|
* media:audio - The post contains audio
|
||||||
|
* media:card - The post contains a link preview card
|
||||||
|
* media:post - The post links another post, means it is a quoted post
|
||||||
* network | net - Use this to include or exclude some networks from your channel.
|
* 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:apub | network:activitypub - ActivityPub (Used by the systems in the Fediverse)
|
||||||
* network:dfrn | network:friendica - Legacy Friendica protocol. Nowayday Friendica mostly uses ActivityPub.
|
* network:dfrn | network:friendica - Legacy Friendica protocol. Nowayday Friendica mostly uses ActivityPub.
|
||||||
|
|
|
@ -46,6 +46,12 @@ class Engagement
|
||||||
'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn',
|
'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn',
|
||||||
'network:diaspora' => 'network:dspr', 'network:ostatus' => 'network:stat',
|
'network:diaspora' => 'network:dspr', 'network:ostatus' => 'network:stat',
|
||||||
'network:discourse' => 'network:dscs', 'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky'];
|
'network:discourse' => 'network:dscs', 'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky'];
|
||||||
|
const MEDIA_NONE = 0;
|
||||||
|
const MEDIA_IMAGE = 1;
|
||||||
|
const MEDIA_VIDEO = 2;
|
||||||
|
const MEDIA_AUDIO = 4;
|
||||||
|
const MEDIA_CARD = 8;
|
||||||
|
const MEDIA_POST = 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store engagement data from an item array
|
* Store engagement data from an item array
|
||||||
|
@ -60,8 +66,10 @@ class Engagement
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = Post::selectFirst(['uri-id', 'created', 'author-id', 'owner-id', 'uid', 'private', 'contact-contact-type', 'language', 'network',
|
$parent = Post::selectFirst(['uri-id', 'created', 'uid', 'private', 'quote-uri-id',
|
||||||
'title', 'content-warning', 'body', 'author-contact-type', 'author-nick', 'author-addr', 'author-gsid', 'owner-contact-type', 'owner-nick', 'owner-addr', 'owner-gsid'],
|
'contact-contact-type', 'network', 'title', 'content-warning', 'body', 'language',
|
||||||
|
'author-id', 'author-contact-type', 'author-nick', 'author-addr', 'author-gsid',
|
||||||
|
'owner-id', 'owner-contact-type', 'owner-nick', 'owner-addr', 'owner-gsid'],
|
||||||
['uri-id' => $item['parent-uri-id']]);
|
['uri-id' => $item['parent-uri-id']]);
|
||||||
|
|
||||||
if ($parent['created'] < self::getCreationDateLimit(false)) {
|
if ($parent['created'] < self::getCreationDateLimit(false)) {
|
||||||
|
@ -89,7 +97,7 @@ class Engagement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$mediatype = self::getMediaType($item['parent-uri-id']);
|
$mediatype = self::getMediaType($item['parent-uri-id'], $parent['quote-uri-id']);
|
||||||
|
|
||||||
if (!$store) {
|
if (!$store) {
|
||||||
$store = !empty($mediatype);
|
$store = !empty($mediatype);
|
||||||
|
@ -166,6 +174,7 @@ class Engagement
|
||||||
'owner-nick' => $author['nick'],
|
'owner-nick' => $author['nick'],
|
||||||
'owner-addr' => $author['addr'],
|
'owner-addr' => $author['addr'],
|
||||||
'owner-gsid' => $author['gsid'],
|
'owner-gsid' => $author['gsid'],
|
||||||
|
'quote-uri-id' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($receivers as $receiver) {
|
foreach ($receivers as $receiver) {
|
||||||
|
@ -187,12 +196,12 @@ class Engagement
|
||||||
}
|
}
|
||||||
|
|
||||||
$post = Post::selectFirstPost(['uri-id', 'network', 'title', 'content-warning', 'body', 'private',
|
$post = Post::selectFirstPost(['uri-id', 'network', 'title', 'content-warning', 'body', 'private',
|
||||||
'author-id', 'author-contact-type', 'author-nick', 'author-addr', 'author-gsid',
|
'author-id', 'author-contact-type', 'author-nick', 'author-addr', 'author-gsid', 'quote-uri-id',
|
||||||
'owner-id', 'owner-contact-type', 'owner-nick', 'owner-addr', 'owner-gsid'], ['uri-id' => $uri_id]);
|
'owner-id', 'owner-contact-type', 'owner-nick', 'owner-addr', 'owner-gsid'], ['uri-id' => $uri_id]);
|
||||||
if (empty($post['uri-id'])) {
|
if (empty($post['uri-id'])) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$mediatype = self::getMediaType($uri_id);
|
$mediatype = self::getMediaType($uri_id, $post['quote-uri-id']);
|
||||||
return self::getSearchTextForItem($post, $mediatype);
|
return self::getSearchTextForItem($post, $mediatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,18 +298,26 @@ class Engagement
|
||||||
$body .= ' language_' . array_key_first($languages);
|
$body .= ' language_' . array_key_first($languages);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mediatype & 1) {
|
if ($mediatype & self::MEDIA_IMAGE) {
|
||||||
$body .= ' media_image';
|
$body .= ' media_image';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mediatype & 2) {
|
if ($mediatype & self::MEDIA_VIDEO) {
|
||||||
$body .= ' media_video';
|
$body .= ' media_video';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mediatype & 4) {
|
if ($mediatype & self::MEDIA_AUDIO) {
|
||||||
$body .= ' media_audio';
|
$body .= ' media_audio';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($mediatype & self::MEDIA_CARD) {
|
||||||
|
$body .= ' media_card';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mediatype & self::MEDIA_POST) {
|
||||||
|
$body .= ' media_post';
|
||||||
|
}
|
||||||
|
|
||||||
$body .= ' ' . $item['title'] . ' ' . $item['content-warning'] . ' ' . $item['body'];
|
$body .= ' ' . $item['title'] . ' ' . $item['content-warning'] . ' ' . $item['body'];
|
||||||
|
|
||||||
return BBCode::toSearchText($body, $item['uri-id']);
|
return BBCode::toSearchText($body, $item['uri-id']);
|
||||||
|
@ -331,17 +348,21 @@ class Engagement
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMediaType(int $uri_id): int
|
public static function getMediaType(int $uri_id, int $quote_uri_id = null): int
|
||||||
{
|
{
|
||||||
$media = Post\Media::getByURIId($uri_id);
|
$media = Post\Media::getByURIId($uri_id);
|
||||||
$type = 0;
|
$type = !empty($quote_uri_id) ? self::MEDIA_POST : self::MEDIA_NONE;
|
||||||
foreach ($media as $entry) {
|
foreach ($media as $entry) {
|
||||||
if ($entry['type'] == Post\Media::IMAGE) {
|
if ($entry['type'] == Post\Media::IMAGE) {
|
||||||
$type = $type | 1;
|
$type = $type | self::MEDIA_IMAGE;
|
||||||
} elseif ($entry['type'] == Post\Media::VIDEO) {
|
} elseif ($entry['type'] == Post\Media::VIDEO) {
|
||||||
$type = $type | 2;
|
$type = $type | self::MEDIA_VIDEO;
|
||||||
} elseif ($entry['type'] == Post\Media::AUDIO) {
|
} elseif ($entry['type'] == Post\Media::AUDIO) {
|
||||||
$type = $type | 4;
|
$type = $type | self::MEDIA_AUDIO;
|
||||||
|
} elseif ($entry['type'] == Post\Media::HTML) {
|
||||||
|
$type = $type | self::MEDIA_CARD;
|
||||||
|
} elseif ($entry['type'] == Post\Media::ACTIVITY) {
|
||||||
|
$type = $type | self::MEDIA_POST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $type;
|
return $type;
|
||||||
|
|
|
@ -47,12 +47,12 @@ class SearchIndex
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = Post::selectFirstPost(['created', 'owner-id', 'private', 'language', 'network', 'title', 'content-warning', 'body'], ['uri-id' => $uri_id]);
|
$item = Post::selectFirstPost(['created', 'owner-id', 'private', 'language', 'network', 'title', 'content-warning', 'body', 'quote-uri-id'], ['uri-id' => $uri_id]);
|
||||||
|
|
||||||
$search = [
|
$search = [
|
||||||
'uri-id' => $uri_id,
|
'uri-id' => $uri_id,
|
||||||
'owner-id' => $item['owner-id'],
|
'owner-id' => $item['owner-id'],
|
||||||
'media-type' => Engagement::getMediaType($uri_id),
|
'media-type' => Engagement::getMediaType($uri_id, $item['quote-uri-id']),
|
||||||
'language' => substr(!empty($item['language']) ? (array_key_first(json_decode($item['language'], true)) ?? L10n::UNDETERMINED_LANGUAGE) : L10n::UNDETERMINED_LANGUAGE, 0, 2),
|
'language' => substr(!empty($item['language']) ? (array_key_first(json_decode($item['language'], true)) ?? L10n::UNDETERMINED_LANGUAGE) : L10n::UNDETERMINED_LANGUAGE, 0, 2),
|
||||||
'searchtext' => Post\Engagement::getSearchTextForUriId($uri_id, $refresh),
|
'searchtext' => Post\Engagement::getSearchTextForUriId($uri_id, $refresh),
|
||||||
'size' => Engagement::getContentSize($item),
|
'size' => Engagement::getContentSize($item),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user