]> git.mxchange.org Git - friendica.git/commitdiff
We now use xonstants
authorMichael <heluecht@pirati.ca>
Tue, 6 Feb 2024 06:34:16 +0000 (06:34 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 6 Feb 2024 06:34:16 +0000 (06:34 +0000)
src/Model/Post/Engagement.php

index d13fef7c4be708c1c4851e2a1b2322ca5e8e4cd5..e5de964d04a85f003f958524dc347c3a4a591c0e 100644 (file)
@@ -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;