Skip to content

Commit

Permalink
Merge pull request #210 from aroskanalen/feature/366-quick-book
Browse files Browse the repository at this point in the history
Slide Interaction - Calendar Instant Booking
  • Loading branch information
tuj authored Aug 19, 2024
2 parents a6ee440 + da336bc commit 254cdce
Show file tree
Hide file tree
Showing 25 changed files with 1,269 additions and 19 deletions.
16 changes: 12 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,25 @@ CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###> App ###
APP_DEFAULT_DATE_FORMAT='Y-m-d\TH:i:s.v\Z'
APP_ACTIVATION_CODE_EXPIRE_INTERNAL=P2D
APP_KEY_VAULT_SOURCE=ENVIRONMENT
APP_KEY_VAULT_JSON="{}"
###< App ###

###> lexik/jwt-authentication-bundle ###
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=APP_JWT_PASSPHRASE
JWT_TOKEN_TTL=3600 # 1 hour
JWT_SCREEN_TOKEN_TTL=1296000 # 15 days
# 1 hour
JWT_TOKEN_TTL=3600
# 15 days
JWT_SCREEN_TOKEN_TTL=1296000
###< lexik/jwt-authentication-bundle ###

###> gesdinet/jwt-refresh-token-bundle ###
JWT_REFRESH_TOKEN_TTL=7200 # 2 hours
JWT_SCREEN_REFRESH_TOKEN_TTL=2592000 # 30 days
# 2 hours
JWT_REFRESH_TOKEN_TTL=7200
# 30 days
JWT_SCREEN_REFRESH_TOKEN_TTL=2592000
###< gesdinet/jwt-refresh-token-bundle ###

###> itk-dev/openid-connect-bundle ###
Expand All @@ -75,6 +81,7 @@ EXTERNAL_OIDC_REDIRECT_URI=EXTERNAL_OIDC_REDIRECT_URI
EXTERNAL_OIDC_LEEWAY=30
EXTERNAL_OIDC_HASH_SALT=
EXTERNAL_OIDC_CLAIM_ID=signinname
###< itk-dev/openid-connect-bundle ###

# cli redirect url
OIDC_CLI_REDIRECT=APP_CLI_REDIRECT_URI
Expand All @@ -84,3 +91,4 @@ OIDC_CLI_REDIRECT=APP_CLI_REDIRECT_URI
REDIS_CACHE_PREFIX=DisplayApiService
REDIS_CACHE_DSN=redis://redis:6379/0
###< redis ###

8 changes: 4 additions & 4 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ DATABASE_URL="mysql://root:password@mariadb:3306/db_test?serverVersion=mariadb-1
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=APP_JWT_PASSPHRASE
JWT_TOKEN_TTL=1800 # 30 min
JWT_SCREEN_TOKEN_TTL=43200 # 12 hours
JWT_TOKEN_TTL=1800
JWT_SCREEN_TOKEN_TTL=43200
###< lexik/jwt-authentication-bundle ###

###> gesdinet/jwt-refresh-token-bundle ###
JWT_REFRESH_TOKEN_TTL=3600 # 1 hour
JWT_SCREEN_REFRESH_TOKEN_TTL=86400 # 24 hours
JWT_REFRESH_TOKEN_TTL=3600
JWT_SCREEN_REFRESH_TOKEN_TTL=86400
###< gesdinet/jwt-refresh-token-bundle ###
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

- [#193](https://github.com/os2display/display-api-service/pull/193)
- Adds support for interactive slides.
- Adds interactivity for creating quick bookings from a slide through Microsoft Graph.
- Adds KeyVaultService that can serve key-value entries from the environment for storing secrets.

## [2.0.6] - 2024-06-28

- [#208](https://github.com/os2display/display-api-service/pull/208)
Expand Down
20 changes: 20 additions & 0 deletions config/api_platform/slide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,26 @@ resources:
tags:
- Slides

_api_Slide_perform_action:
input: App\Dto\InteractiveSlideActionInput
class: ApiPlatform\Metadata\POST
method: POST
uriTemplate: '/slides/{id}/action'
controller: App\Controller\InteractiveController
openapiContext:
description: Perform an action for a slide.
summary: Performs an action for a slide.
tags:
- Slides
parameters:
- schema:
type: string
format: ulid
pattern: "^[A-Za-z0-9]{26}$"
name: id
in: path
required: true

# Our DTO must be a resource to get a proper URL
# @see https://stackoverflow.com/a/75705084
# @see https://github.com/api-platform/core/issues/5451
Expand Down
6 changes: 6 additions & 0 deletions config/packages/cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ framework:
adapter: cache.adapter.redis
# Default expire set to 1 day
default_lifetime: 86400

# Creates a "interactive_slide.cache" service
interactive_slide.cache:
adapter: cache.adapter.redis
# Default expire set to 12 hours
default_lifetime: 43200
8 changes: 8 additions & 0 deletions config/packages/dev/monolog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ monolog:
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event", "!doctrine", "!deprecation"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
console:
type: console
process_psr_3_messages: false
Expand Down
12 changes: 12 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ services:
- { name: api_platform.doctrine.orm.query_extension.collection }
- { name: api_platform.doctrine.orm.query_extension.item }

App\InteractiveSlide\InteractiveSlideInterface:
tags: [app.interactive.interactive]

# Specify primary UserProviderInterface
Symfony\Component\Security\Core\User\UserProviderInterface: '@security.user.provider.concrete.app_user_provider'

Expand All @@ -48,6 +51,11 @@ services:
Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface: '@Lexik\Bundle\JWTAuthenticationBundle\Security\Http\Authentication\AuthenticationFailureHandler'
Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface: '@Lexik\Bundle\JWTAuthenticationBundle\Security\Http\Authentication\AuthenticationSuccessHandler'

App\Service\KeyVaultService:
arguments:
$keyVaultSource: '%env(string:APP_KEY_VAULT_SOURCE)%'
$keyVaultArray: '%env(json:APP_KEY_VAULT_JSON)%'

App\Service\UserService:
arguments:
$hashSalt: '%env(EXTERNAL_OIDC_HASH_SALT)%'
Expand Down Expand Up @@ -81,6 +89,10 @@ services:
arguments:
- !tagged_iterator app.feed.feed_type

App\Service\InteractiveSlideService:
arguments:
- !tagged_iterator app.interactive.interactive

App\Security\ScreenAuthenticator:
arguments:
$jwtScreenRefreshTokenTtl: '%env(int:JWT_SCREEN_REFRESH_TOKEN_TTL)%'
Expand Down
33 changes: 33 additions & 0 deletions migrations/Version20240403043527.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240403043527 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE interactive_slide (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', version INT DEFAULT 1 NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, configuration JSON DEFAULT NULL COMMENT \'(DC2Type:json)\', implementation_class VARCHAR(255) NOT NULL, INDEX IDX_138E544D9033212A (tenant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE interactive_slide ADD CONSTRAINT FK_138E544D9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE interactive_slide DROP FOREIGN KEY FK_138E544D9033212A');
$this->addSql('DROP TABLE interactive_slide');
}
}
6 changes: 0 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -495,16 +495,10 @@
</UndefinedDocblockClass>
</file>
<file src="src/Feed/KobaFeedType.php">
<InvalidThrow>
<code><![CDATA[throw new MissingFeedConfigurationException('Koba event_name is not string');]]></code>
</InvalidThrow>
<RiskyTruthyFalsyComparison>
<code><![CDATA[$filterList]]></code>
<code><![CDATA[$rewriteBookedTitles]]></code>
</RiskyTruthyFalsyComparison>
<UndefinedClass>
<code><![CDATA[MissingFeedConfigurationException]]></code>
</UndefinedClass>
</file>
<file src="src/Feed/SparkleIOFeedType.php">
<UndefinedInterfaceMethod>
Expand Down
118 changes: 118 additions & 0 deletions public/api-spec-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -5039,6 +5039,86 @@
},
"parameters": []
},
"/v2/slides/{id}/action": {
"post": {
"operationId": "api_Slide_perform_action",
"tags": [
"Slides"
],
"responses": {
"201": {
"description": "Slide resource created",
"content": {
"application/ld+json": {
"schema": {
"$ref": "#/components/schemas/Slide.Slide.jsonld"
}
},
"text/html": {
"schema": {
"$ref": "#/components/schemas/Slide.Slide"
}
},
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/Slide.Slide"
}
}
},
"links": {}
},
"400": {
"description": "Invalid input"
},
"422": {
"description": "Unprocessable entity"
}
},
"summary": "Performs an action for a slide.",
"description": "Perform an action for a slide.",
"parameters": [
{
"name": "id",
"in": "path",
"description": "",
"required": true,
"deprecated": false,
"allowEmptyValue": false,
"schema": {
"type": "string",
"format": "ulid",
"pattern": "^[A-Za-z0-9]{26}$"
},
"style": "simple",
"explode": false,
"allowReserved": false
}
],
"requestBody": {
"description": "The new Slide resource",
"content": {
"application/ld+json": {
"schema": {
"$ref": "#/components/schemas/Slide.InteractiveSlideActionInput.jsonld"
}
},
"text/html": {
"schema": {
"$ref": "#/components/schemas/Slide.InteractiveSlideActionInput"
}
},
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/Slide.InteractiveSlideActionInput"
}
}
},
"required": true
},
"deprecated": false
},
"parameters": []
},
"/v2/slides/{id}/playlists": {
"get": {
"operationId": "put-v2-slide-playlist-id",
Expand Down Expand Up @@ -13102,6 +13182,44 @@
}
}
},
"Slide.InteractiveSlideActionInput": {
"type": "object",
"description": "",
"deprecated": false,
"properties": {
"action": {
"type": [
"string",
"null"
]
},
"data": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"Slide.InteractiveSlideActionInput.jsonld": {
"type": "object",
"description": "",
"deprecated": false,
"properties": {
"action": {
"type": [
"string",
"null"
]
},
"data": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"Slide.Slide": {
"type": "object",
"description": "",
Expand Down
Loading

0 comments on commit 254cdce

Please sign in to comment.