Commit e3bac422 authored by Marcelo Rivera's avatar Marcelo Rivera
Browse files

(fix): don't do anything if the entity isn't an image or video

parent 142d395f
Loading
Loading
Loading
Loading
+13 −1
Original line number Original line Diff line number Diff line
@@ -36,6 +36,13 @@ class media implements Interfaces\Api, Interfaces\ApiIgnorePam
                return Factory::response(['status' => 'error']);
                return Factory::response(['status' => 'error']);
            }
            }


            if (!in_array($this->getType($entity), ['object:video', 'object:image'], true)) {
                return Factory::response([
                    'status' => 'error',
                    'message' => 'Entity is not a media entity',
                ]);
            }

            switch ($entity->subtype) {
            switch ($entity->subtype) {
                case "video":
                case "video":
                    // Helpers\Counters::increment($pages[0], 'plays');
                    // Helpers\Counters::increment($pages[0], 'plays');
@@ -356,4 +363,9 @@ class media implements Interfaces\Api, Interfaces\ApiIgnorePam


        return $response;
        return $response;
    }
    }

    private function getType($entity): string
    {
        return $entity->subtype ? "{$entity->type}:{$entity->subtype}" : $entity->type;
    }
}
}