Repository navigation
Notificar en Discord cuando se publica un vídeo - #407
Open
lapencadev wants to merge 3 commits into
Open
lapencadev wants to merge 3 commits into
lapencadev wants to merge 3 commits into
Conversation
- Bump xdebug to 3.4.2: 3.3.0 no longer compiles on the current php:8.3-fpm-alpine image - Add --allow-all-ip to symfony serve: Symfony CLI >= 5.10.3 only listens on 127.0.0.1, so the apps were unreachable from the host - Keep tracked var/.gitkeep files when running make clean-cache - Update README with the existing Makefile targets (make build / make deps no longer exist)
Videos could not be persisted: the videos table was missing, VideoType (an enum) was mapped as an embeddable and VideoUrl had no mapping.
NotifyOnVideoCreated listens to VideoCreatedDomainEvent and uses the VideoPublishedNotifier port, implemented with a Discord webhook.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mi implementación del ejercicio: cuando se crea un vídeo, se manda un mensaje a un canal de Discord por webhook.
Cómo está montado:
VideoPublishedNotifier, la interfaz (el puerto).NotifyOnVideoCreatedescuchaVideoCreatedDomainEventy llama al caso de usoVideoPublishedNotificator.DiscordVideoPublishedNotifier, que hace el POST al webhook con el HttpClient de Symfony.Para poder probarlo de verdad he tenido que añadir algunas cosas que faltaban:
PUT /videos/{id}, porque no había forma de crear vídeos desde fuera.videosy un par de mapeos de Doctrine, porque los vídeos no se podían guardar.--allow-all-ipensymfony servey el README), porque con lo que hay ahora el proyecto no levanta. Van en un commit aparte y también en Arreglar el entorno local para que el proyecto vuelva a levantar #406 por si os sirven por separado.Para probarlo:
DISCORD_WEBHOOK_URLen.env.test.local(conAPP_ENV=testno se lee.env.local).make startydocker exec codely-php_ddd_skeleton-mooc_backend-php ./apps/mooc/backend/bin/console codely:domain-events:rabbitmq:configurecurl -X PUT localhost:8030/videos/<uuid> -H 'Content-Type: application/json' -d '{"type":"screencast","title":"Prueba","url":"https://codely.com","course_id":"1aab45ba-3c7a-4344-8936-78466eca77fa"}'docker exec codely-php_ddd_skeleton-mooc_backend-php ./apps/mooc/backend/bin/console codely:domain-events:rabbitmq:consume codelytv.mooc.videos.notify_on_video_created 10Tests: uno unitario del subscriber con el notifier mockeado, uno del adaptador con
MockHttpClient(sin llamar a Discord) y un Behat para el endpoint.