From 0ce3978f2c4b50f46d7ada12c511be1ed030f2be Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 1 May 2026 15:56:43 +1200 Subject: [PATCH] feat(notifications): add worker entrypoint and registration alongside Mails Adds the bin/worker-notifications entrypoint, Dockerfile chmod, and docker-compose service definitions for the new Notifications worker without disturbing the existing Mails worker, and re-adds the Mails queue/class constants on Event so the legacy callers still resolve. The full mail->notification swap (caller migration, Mails removal, worker rename) will land as a follow-up. Co-Authored-By: Claude Opus 4.7 (1M context) --- Dockerfile | 1 + bin/worker-notifications | 3 ++ docker-compose.yml | 41 ++++++++++++++++++++++ src/Appwrite/Event/Event.php | 3 ++ src/Appwrite/Platform/Services/Workers.php | 3 ++ tests/resources/docker/docker-compose.yml | 24 +++++++++++++ 6 files changed, 75 insertions(+) create mode 100755 bin/worker-notifications diff --git a/Dockerfile b/Dockerfile index 1922a0d2b9..8e13b83fc0 100755 --- a/Dockerfile +++ b/Dockerfile @@ -93,6 +93,7 @@ RUN chmod +x /usr/local/bin/doctor && \ chmod +x /usr/local/bin/worker-functions && \ chmod +x /usr/local/bin/worker-mails && \ chmod +x /usr/local/bin/worker-messaging && \ + chmod +x /usr/local/bin/worker-notifications && \ chmod +x /usr/local/bin/worker-migrations && \ chmod +x /usr/local/bin/worker-webhooks && \ chmod +x /usr/local/bin/worker-stats-usage && \ diff --git a/bin/worker-notifications b/bin/worker-notifications new file mode 100755 index 0000000000..1b7bf28745 --- /dev/null +++ b/bin/worker-notifications @@ -0,0 +1,3 @@ +#!/bin/sh + +exec php /usr/src/code/app/worker.php notifications "$@" diff --git a/docker-compose.yml b/docker-compose.yml index da5efac438..189177829c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -806,6 +806,47 @@ services: - _APP_OPTIONS_FORCE_HTTPS - _APP_DATABASE_SHARED_TABLES + appwrite-worker-notifications: + entrypoint: worker-notifications + <<: [*x-logging, *x-build] + container_name: appwrite-worker-notifications + image: appwrite-dev + networks: + - appwrite + volumes: + - ./app:/usr/src/code/app + - ./src:/usr/src/code/src + depends_on: + - redis + - maildev + - ${_APP_DB_HOST:-mariadb} + environment: + - _APP_ENV + - _APP_WORKER_PER_CORE + - _APP_POOL_ADAPTER + - _APP_OPENSSL_KEY_V1 + - _APP_SYSTEM_EMAIL_NAME + - _APP_SYSTEM_EMAIL_ADDRESS + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS + - _APP_DB_HOST + - _APP_DB_PORT + - _APP_DB_SCHEMA + - _APP_DB_USER + - _APP_DB_PASS + - _APP_DB_ADAPTER + - _APP_SMTP_HOST + - _APP_SMTP_PORT + - _APP_SMTP_SECURE + - _APP_SMTP_USERNAME + - _APP_SMTP_PASSWORD + - _APP_LOGGING_CONFIG + - _APP_DOMAIN + - _APP_OPTIONS_FORCE_HTTPS + - _APP_DATABASE_SHARED_TABLES + appwrite-worker-messaging: entrypoint: worker-messaging <<: [*x-logging, *x-build] diff --git a/src/Appwrite/Event/Event.php b/src/Appwrite/Event/Event.php index 06af738857..54841343e7 100644 --- a/src/Appwrite/Event/Event.php +++ b/src/Appwrite/Event/Event.php @@ -18,6 +18,9 @@ class Event public const AUDITS_QUEUE_NAME = 'v1-audits'; public const AUDITS_CLASS_NAME = 'AuditsV1'; + public const MAILS_QUEUE_NAME = 'v1-mails'; + public const MAILS_CLASS_NAME = 'MailsV1'; + public const NOTIFICATIONS_QUEUE_NAME = 'v1-notifications'; public const NOTIFICATIONS_CLASS_NAME = 'NotificationsV1'; diff --git a/src/Appwrite/Platform/Services/Workers.php b/src/Appwrite/Platform/Services/Workers.php index 8b4925c5a5..5af3d078de 100644 --- a/src/Appwrite/Platform/Services/Workers.php +++ b/src/Appwrite/Platform/Services/Workers.php @@ -7,8 +7,10 @@ use Appwrite\Platform\Workers\Certificates; use Appwrite\Platform\Workers\Deletes; use Appwrite\Platform\Workers\Executions; use Appwrite\Platform\Workers\Functions; +use Appwrite\Platform\Workers\Mails; use Appwrite\Platform\Workers\Messaging; use Appwrite\Platform\Workers\Migrations; +use Appwrite\Platform\Workers\Notifications; use Appwrite\Platform\Workers\StatsResources; use Appwrite\Platform\Workers\StatsUsage; use Appwrite\Platform\Workers\Webhooks; @@ -25,6 +27,7 @@ class Workers extends Service ->addAction(Deletes::getName(), new Deletes()) ->addAction(Executions::getName(), new Executions()) ->addAction(Functions::getName(), new Functions()) + ->addAction(Mails::getName(), new Mails()) ->addAction(Messaging::getName(), new Messaging()) ->addAction(Notifications::getName(), new Notifications()) ->addAction(Webhooks::getName(), new Webhooks()) diff --git a/tests/resources/docker/docker-compose.yml b/tests/resources/docker/docker-compose.yml index 47a69f077b..5942eea65f 100644 --- a/tests/resources/docker/docker-compose.yml +++ b/tests/resources/docker/docker-compose.yml @@ -292,6 +292,30 @@ services: - _APP_SMTP_HOST - _APP_SMTP_PORT + appwrite-worker-notifications: + entrypoint: worker-notifications + container_name: appwrite-worker-notifications + build: + context: . + restart: unless-stopped + networks: + - appwrite + depends_on: + - redis + - maildev + environment: + - _APP_ENV + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_DB_HOST + - _APP_DB_PORT + - _APP_DB_SCHEMA + - _APP_DB_USER + - _APP_DB_PASS + - _APP_DB_ADAPTER + - _APP_SMTP_HOST + - _APP_SMTP_PORT + appwrite-worker-builds: entrypoint: worker-builds container_name: appwrite-worker-builds