We now use xonstants
This commit is contained in:
parent
4cd2fde6f2
commit
d5bf306884
1 changed files with 17 additions and 11 deletions
|
@ -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
|
||||||
|
@ -292,23 +298,23 @@ 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 & 8) {
|
if ($mediatype & self::MEDIA_CARD) {
|
||||||
$body .= ' media_card';
|
$body .= ' media_card';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mediatype & 16) {
|
if ($mediatype & self::MEDIA_POST) {
|
||||||
$body .= ' media_post';
|
$body .= ' media_post';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,18 +351,18 @@ class Engagement
|
||||||
public static function getMediaType(int $uri_id, int $quote_uri_id = null): 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 = !empty($quote_uri_id) ? 16 : 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) {
|
} elseif ($entry['type'] == Post\Media::HTML) {
|
||||||
$type = $type | 8;
|
$type = $type | self::MEDIA_CARD;
|
||||||
} elseif ($entry['type'] == Post\Media::ACTIVITY) {
|
} elseif ($entry['type'] == Post\Media::ACTIVITY) {
|
||||||
$type = $type | 16;
|
$type = $type | self::MEDIA_POST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $type;
|
return $type;
|
||||||
|
|
Loading…
Reference in a new issue