From 30b64306089d3a0adfc89c3e24028fbd2ee60750 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Sun, 3 Jan 2021 02:07:43 +0100
Subject: [PATCH] Generator jitsi url

---
 .gitlab-ci.yml             |  2 +-
 lib/CF/Controller/Jitsi.pm | 24 +++++++++++++++++++++++
 openapi.yaml               | 40 +++++++++++++++++++++++++++++++++++++-
 3 files changed, 64 insertions(+), 2 deletions(-)
 create mode 100644 lib/CF/Controller/Jitsi.pm

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 95d5fc7..47a1efb 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,7 +3,7 @@ image: docker:19.03.1
 variables:
   DOCKER_TLS_CERTDIR: "/certs"
   IMAGE_TAG: $CI_REGISTRY_IMAGE
-  IMAGE_VER: 1.3.0
+  IMAGE_VER: 1.4.0
 
 services:
   - docker:19.03.1-dind
diff --git a/lib/CF/Controller/Jitsi.pm b/lib/CF/Controller/Jitsi.pm
new file mode 100644
index 0000000..9ae967d
--- /dev/null
+++ b/lib/CF/Controller/Jitsi.pm
@@ -0,0 +1,24 @@
+package CF::Controller::Jitsi;
+
+use Mojo::Base 'Mojolicious::Controller';
+use feature 'signatures';
+no warnings qw{ experimental::signatures };
+
+sub url ($c) {
+    $c->openapi->valid_input or return;
+
+    my $args = $c->req->json;
+
+    $c->render(
+        status  => 200,
+        openapi => {
+            url => $c->jitsi_url(
+                $args->{room} // $c->cfg->{jitsi_room},
+                $args->{token_lifetime} // $c->cfg->{jitsi_token_lifetime},
+                %{ $args },
+            )
+        },
+    );
+};
+
+1;
diff --git a/openapi.yaml b/openapi.yaml
index 84bd655..1f3a9ea 100644
--- a/openapi.yaml
+++ b/openapi.yaml
@@ -1,7 +1,7 @@
 openapi: 3.0.3
 
 info:
-  version: 0.1.0
+  version: 1.4.0
   title: CF Online
   description: CF Online
   license:
@@ -588,3 +588,41 @@ paths:
         204:
           description: Status changed
 
+  /jitsi/url:
+    post:
+      x-mojo-to: jitsi#url
+      security:
+        - Bearer: ['chairman']
+      tags:
+        - jitsi
+      summary: "Vygenerovat odkaz pro jitsi"
+      operationId: jitsiUrl
+      requestBody:
+        content:
+          application/json:
+            schema:
+              type: object
+              properties:
+                name:
+                  type: string
+                email:
+                  type: string
+                avatar:
+                  type: string
+                room:
+                  type: string
+                token_lifetime:
+                  type: integer
+              required:
+                - name
+      responses:
+        200:
+          description: Jitsi url
+          content:
+            application/json:
+              schema:
+                type: object
+                properties:
+                  url:
+                    type: string
+                    description: Jitsi meet url
-- 
GitLab