From d5bf3068848d3b4aca14a087737b47c82e4434bd Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 6 Feb 2024 06:34:16 +0000 Subject: [PATCH] We now use xonstants --- src/Model/Post/Engagement.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/Model/Post/Engagement.php b/src/Model/Post/Engagement.php index d13fef7c4b..e5de964d04 100644 --- a/src/Model/Post/Engagement.php +++ b/src/Model/Post/Engagement.php @@ -46,6 +46,12 @@ class Engagement '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']; + 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 @@ -292,23 +298,23 @@ class Engagement $body .= ' language_' . array_key_first($languages); } - if ($mediatype & 1) { + if ($mediatype & self::MEDIA_IMAGE) { $body .= ' media_image'; } - if ($mediatype & 2) { + if ($mediatype & self::MEDIA_VIDEO) { $body .= ' media_video'; } - if ($mediatype & 4) { + if ($mediatype & self::MEDIA_AUDIO) { $body .= ' media_audio'; } - if ($mediatype & 8) { + if ($mediatype & self::MEDIA_CARD) { $body .= ' media_card'; } - if ($mediatype & 16) { + if ($mediatype & self::MEDIA_POST) { $body .= ' media_post'; } @@ -345,18 +351,18 @@ class Engagement public static function getMediaType(int $uri_id, int $quote_uri_id = null): int { $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) { if ($entry['type'] == Post\Media::IMAGE) { - $type = $type | 1; + $type = $type | self::MEDIA_IMAGE; } elseif ($entry['type'] == Post\Media::VIDEO) { - $type = $type | 2; + $type = $type | self::MEDIA_VIDEO; } elseif ($entry['type'] == Post\Media::AUDIO) { - $type = $type | 4; + $type = $type | self::MEDIA_AUDIO; } elseif ($entry['type'] == Post\Media::HTML) { - $type = $type | 8; + $type = $type | self::MEDIA_CARD; } elseif ($entry['type'] == Post\Media::ACTIVITY) { - $type = $type | 16; + $type = $type | self::MEDIA_POST; } } return $type;