From f94995ca064b886e6d31ea32daea7f47603b1aa4 Mon Sep 17 00:00:00 2001 From: Elorfin Date: Tue, 19 Sep 2023 08:48:24 +0200 Subject: [PATCH] [PeerTube] fixes resource validation cs peertube --- src/integration/peertube/Entity/Video.php | 3 ++- .../peertube/Resources/schemas/video.json | 16 ++++++++++++++++ .../peertube/Serializer/VideoSerializer.php | 8 ++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/integration/peertube/Resources/schemas/video.json diff --git a/src/integration/peertube/Entity/Video.php b/src/integration/peertube/Entity/Video.php index 29993113650..e6cc6e8ab24 100644 --- a/src/integration/peertube/Entity/Video.php +++ b/src/integration/peertube/Entity/Video.php @@ -7,6 +7,7 @@ /** * @ORM\Entity() + * * @ORM\Table(name="claro_peertube_video") */ class Video extends AbstractResource @@ -30,7 +31,7 @@ class Video extends AbstractResource private $originalUuid; /** - * The short UUID of the video (retrieved from the the PeerTube share URL). + * The short UUID of the video (retrieved from the PeerTube share URL). * * @ORM\Column(type="string") * diff --git a/src/integration/peertube/Resources/schemas/video.json b/src/integration/peertube/Resources/schemas/video.json new file mode 100644 index 00000000000..c0de5a8cc17 --- /dev/null +++ b/src/integration/peertube/Resources/schemas/video.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The uuid of the PeerTube video" + }, + "url": { + "type": "string", + "description": "The original URL of the PeerTube video" + } + }, + "required": ["url"], + "claroIds": ["id"] +} diff --git a/src/integration/peertube/Serializer/VideoSerializer.php b/src/integration/peertube/Serializer/VideoSerializer.php index b49a0af545d..c8fa5fc647b 100644 --- a/src/integration/peertube/Serializer/VideoSerializer.php +++ b/src/integration/peertube/Serializer/VideoSerializer.php @@ -11,8 +11,7 @@ class VideoSerializer { use SerializerTrait; - /** @var PeerTubeManager */ - private $peerTubeManager; + private PeerTubeManager $peerTubeManager; public function __construct(PeerTubeManager $peerTubeManager) { @@ -24,6 +23,11 @@ public function getClass(): string return Video::class; } + public function getSchema(): string + { + return '#/integration/peertube/video.json'; + } + public function serialize(Video $video, ?array $options = []): array { return [