From 0f02181e33cd2d8ffdc52eebc2d3db03002e0f2e Mon Sep 17 00:00:00 2001 From: dongli Date: Sun, 2 Mar 2025 17:08:08 -0800 Subject: [PATCH 01/23] Expose prometheus metrics for all apps --- apps/authentication/requirements.txt | 3 ++- apps/authentication/webapi/bootstrap/application.py | 3 +++ apps/central_storage/requirements.txt | 3 ++- apps/central_storage/webapi/bootstrap/application.py | 4 ++++ apps/content/requirements.txt | 3 ++- apps/content/webapi/bootstrap/application.py | 3 +++ apps/notification/requirements.txt | 3 ++- apps/notification/webapi/bootstrap/application.py | 3 +++ 8 files changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/authentication/requirements.txt b/apps/authentication/requirements.txt index 1105c5e..77456b6 100644 --- a/apps/authentication/requirements.txt +++ b/apps/authentication/requirements.txt @@ -12,4 +12,5 @@ aio-pika httpx pydantic-settings python-jose -passlib[bcrypt] \ No newline at end of file +passlib[bcrypt] +prometheus_fastapi_instrumentator==7.0.2 diff --git a/apps/authentication/webapi/bootstrap/application.py b/apps/authentication/webapi/bootstrap/application.py index e060fbf..1f9568f 100644 --- a/apps/authentication/webapi/bootstrap/application.py +++ b/apps/authentication/webapi/bootstrap/application.py @@ -11,6 +11,7 @@ from webapi.providers import database from webapi.providers import exception_handler from .freeleaps_app import FreeleapsApp +from prometheus_fastapi_instrumentator import Instrumentator def create_app() -> FastAPI: logging.info("App initializing") @@ -26,6 +27,8 @@ def create_app() -> FastAPI: # Call the custom_openapi function to change the OpenAPI version customize_openapi_security(app) + # expose prometheus metrics + Instrumentator().instrument(app).expose(app) return app diff --git a/apps/central_storage/requirements.txt b/apps/central_storage/requirements.txt index 2b9f8cc..a157f90 100644 --- a/apps/central_storage/requirements.txt +++ b/apps/central_storage/requirements.txt @@ -12,4 +12,5 @@ python-multipart python-jose azure-storage-blob==12.22.0 azure-identity -azure-core[aio] \ No newline at end of file +azure-core[aio] +prometheus_fastapi_instrumentator==7.0.2 diff --git a/apps/central_storage/webapi/bootstrap/application.py b/apps/central_storage/webapi/bootstrap/application.py index 8d0844d..4520aad 100644 --- a/apps/central_storage/webapi/bootstrap/application.py +++ b/apps/central_storage/webapi/bootstrap/application.py @@ -10,6 +10,8 @@ from webapi.providers import scheduler from webapi.providers import exception_handler from .freeleaps_app import FreeleapsApp +from prometheus_fastapi_instrumentator import Instrumentator + def create_app() -> FastAPI: logging.info("App initializing") @@ -25,6 +27,8 @@ def create_app() -> FastAPI: # Call the custom_openapi function to change the OpenAPI version customize_openapi_security(app) + # expose prometheus metrics + Instrumentator().instrument(app).expose(app) return app diff --git a/apps/content/requirements.txt b/apps/content/requirements.txt index 1d1525f..80dd460 100644 --- a/apps/content/requirements.txt +++ b/apps/content/requirements.txt @@ -30,4 +30,5 @@ azure-storage-blob[aio] azure-identity azure-core[aio] sendgrid -httpx \ No newline at end of file +httpx +prometheus_fastapi_instrumentator==7.0.2 diff --git a/apps/content/webapi/bootstrap/application.py b/apps/content/webapi/bootstrap/application.py index 7d0b26d..418d081 100644 --- a/apps/content/webapi/bootstrap/application.py +++ b/apps/content/webapi/bootstrap/application.py @@ -11,6 +11,7 @@ from webapi.providers import scheduler from webapi.providers import exception_handler from .freeleaps_app import FreeleapsApp +from prometheus_fastapi_instrumentator import Instrumentator def create_app() -> FastAPI: logging.info("App initializing") @@ -26,6 +27,8 @@ def create_app() -> FastAPI: # Call the custom_openapi function to change the OpenAPI version customize_openapi_security(app) + # expose prometheus metrics + Instrumentator().instrument(app).expose(app) return app diff --git a/apps/notification/requirements.txt b/apps/notification/requirements.txt index 36afe9a..46541c2 100644 --- a/apps/notification/requirements.txt +++ b/apps/notification/requirements.txt @@ -11,4 +11,5 @@ aio-pika twilio pydantic-settings python-multipart -python-jose \ No newline at end of file +python-jose +prometheus_fastapi_instrumentator==7.0.2 diff --git a/apps/notification/webapi/bootstrap/application.py b/apps/notification/webapi/bootstrap/application.py index 718c166..bdd788d 100644 --- a/apps/notification/webapi/bootstrap/application.py +++ b/apps/notification/webapi/bootstrap/application.py @@ -11,6 +11,7 @@ from webapi.providers import message_queue from webapi.providers import exception_handler from .freeleaps_app import FreeleapsApp +from prometheus_fastapi_instrumentator import Instrumentator def create_app() -> FastAPI: logging.info("App initializing") @@ -27,6 +28,8 @@ def create_app() -> FastAPI: # Call the custom_openapi function to change the OpenAPI version customize_openapi_security(app) + # expose prometheus metrics + Instrumentator().instrument(app).expose(app) return app From 4aa45cc2cb14302d78d58ce51e7973a39de27fd7 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 5 Mar 2025 18:43:00 +0000 Subject: [PATCH 02/23] chore(release): bump version to 1.0.0 and upload released assets [ci skip] --- CHANGELOG.md | 11 +++++++++++ VERSION | 1 + 2 files changed, 12 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 VERSION diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..fc1d88a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# 1.0.0 (2025-03-05) + + +### Bug Fixes + +* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) + + +### Features + +* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 From 54fc72a3927b36d11a0fa965c10669cb75b7628e Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 07:31:20 +0000 Subject: [PATCH 03/23] chore: cleanup semantic releasing assets --- CHANGELOG.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index fc1d88a..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# 1.0.0 (2025-03-05) - - -### Bug Fixes - -* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) - - -### Features - -* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) From 1a7f03dc8f8936922f4474fc2ee7970a7dcf23fc Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 07:31:29 +0000 Subject: [PATCH 04/23] chore: cleanup semantic releasing assets --- VERSION | 1 - 1 file changed, 1 deletion(-) delete mode 100644 VERSION diff --git a/VERSION b/VERSION deleted file mode 100644 index 3eefcb9..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.0 From e1ffaa52511878c5c8bec45d9e28b822c3a3a016 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 6 Mar 2025 07:35:39 +0000 Subject: [PATCH 05/23] chore(release): bump version to 1.0.0 and upload released assets [ci skip] --- CHANGELOG.md | 11 +++++++++++ VERSION | 1 + 2 files changed, 12 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 VERSION diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..05e6f24 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# 1.0.0 (2025-03-06) + + +### Bug Fixes + +* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) + + +### Features + +* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 From a38fe80bf16f6e73fb3bd8e8fe8240cc6f29866d Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 08:16:15 +0000 Subject: [PATCH 06/23] chore: reset semantic release --- CHANGELOG.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 05e6f24..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# 1.0.0 (2025-03-06) - - -### Bug Fixes - -* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) - - -### Features - -* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) From 66e3fb7dfa4444635ea364b69e76101ce582a50b Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 08:16:24 +0000 Subject: [PATCH 07/23] chore: reset semantic release --- VERSION | 1 - 1 file changed, 1 deletion(-) delete mode 100644 VERSION diff --git a/VERSION b/VERSION deleted file mode 100644 index 3eefcb9..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.0 From 576463103bedaec18ea2d2575f008a9ae649d59c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 6 Mar 2025 08:19:38 +0000 Subject: [PATCH 08/23] chore(release): bump version to 1.0.0 and upload released assets [ci skip] --- CHANGELOG.md | 11 +++++++++++ VERSION | 1 + 2 files changed, 12 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 VERSION diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..05e6f24 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# 1.0.0 (2025-03-06) + + +### Bug Fixes + +* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) + + +### Features + +* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 From 4447c46889557bc3f6ec37933c71fa73793a2768 Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 09:18:46 +0000 Subject: [PATCH 09/23] chore: reset semantic releasing state --- CHANGELOG.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 05e6f24..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# 1.0.0 (2025-03-06) - - -### Bug Fixes - -* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) - - -### Features - -* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) From 2add60a5d0a91fdd55724fc5ecc9faec835d160e Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 09:18:55 +0000 Subject: [PATCH 10/23] chore: reset semantic releasing state --- VERSION | 1 - 1 file changed, 1 deletion(-) delete mode 100644 VERSION diff --git a/VERSION b/VERSION deleted file mode 100644 index 3eefcb9..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.0 From b1b77a6a01b7d27a52b8e471b6acc455c7e99f55 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 6 Mar 2025 16:42:44 +0000 Subject: [PATCH 11/23] chore(release): bump version to 1.0.0 and upload released assets [ci skip] --- CHANGELOG.md | 11 +++++++++++ VERSION | 1 + 2 files changed, 12 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 VERSION diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..05e6f24 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# 1.0.0 (2025-03-06) + + +### Bug Fixes + +* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) + + +### Features + +* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 From bf6f92d6f09801804c6004dff9e05862f5fe61ff Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 17:30:45 +0000 Subject: [PATCH 12/23] chore: reset semantic release state --- CHANGELOG.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 05e6f24..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# 1.0.0 (2025-03-06) - - -### Bug Fixes - -* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) - - -### Features - -* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) From cefe2227bf6855d9b75a3399bae9f432ba6c09c5 Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 17:30:53 +0000 Subject: [PATCH 13/23] chore: reset semantic release state --- Dockerfile | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index a527cf6..0000000 --- a/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# Dockerfile for Python Service -FROM python:3.11-slim - -# Set working directory -WORKDIR /app - -# Copy requirements file and install dependencies -COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt && rm -rf /root/.cache/pip - -# Copy application code -COPY . . - -# Run the Python script -CMD ["python", "main.py"] \ No newline at end of file From 3c34a018488312de40a046c0399864dce96d4836 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 6 Mar 2025 17:34:57 +0000 Subject: [PATCH 14/23] chore(release): bump version to 1.0.0 and upload released assets [ci skip] --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..05e6f24 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# 1.0.0 (2025-03-06) + + +### Bug Fixes + +* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) + + +### Features + +* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) From ea9dcb22cb19acbded45f0e2332fe6783df14156 Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 17:52:29 +0000 Subject: [PATCH 15/23] build(pip): bump content deps fastapi to 0.114.0 --- apps/content/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/content/requirements.txt b/apps/content/requirements.txt index 80dd460..d94ea05 100644 --- a/apps/content/requirements.txt +++ b/apps/content/requirements.txt @@ -1,4 +1,4 @@ -fastapi==0.100.1 +fastapi==0.114.0 fastapi-mail==1.4.1 loguru~=0.6.0 uvicorn==0.23.2 From d65f46f04c74f3f601636fb95ea755d6364758c9 Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 17:52:53 +0000 Subject: [PATCH 16/23] chore: reset semantic release state --- CHANGELOG.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 05e6f24..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# 1.0.0 (2025-03-06) - - -### Bug Fixes - -* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) - - -### Features - -* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) From 2f5c12d44b369f954d6064dde0af1d03e49f72c8 Mon Sep 17 00:00:00 2001 From: Zhenyu Sun Date: Thu, 6 Mar 2025 17:53:06 +0000 Subject: [PATCH 17/23] chore: reset semantic release state --- VERSION | 1 - 1 file changed, 1 deletion(-) delete mode 100644 VERSION diff --git a/VERSION b/VERSION deleted file mode 100644 index 3eefcb9..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.0 From 2043baf4ab7c9462b460d7bc34c427c6a88023b0 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 6 Mar 2025 17:56:23 +0000 Subject: [PATCH 18/23] chore(release): bump version to 1.0.0 and upload released assets [ci skip] --- CHANGELOG.md | 11 +++++++++++ VERSION | 1 + 2 files changed, 12 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 VERSION diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..05e6f24 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# 1.0.0 (2025-03-06) + + +### Bug Fixes + +* **rabbitmq:** correct syntax for port and virtual host parameters in AsyncMQClient ([78c7217](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/78c72179ec3fdb15d4af01bee15a441f0e383638)) + + +### Features + +* **notification:** add rabbitmq credentials relates notification services configs ([853d817](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/853d81793332513e89286d61429444d520252c27)) diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 From b12f8cc965a84762d630b11eab2570508226d940 Mon Sep 17 00:00:00 2001 From: Jet Li Date: Thu, 13 Mar 2025 23:46:49 -0700 Subject: [PATCH 19/23] Fix the concatenation issue with message --- .../backend/business/notification_manager.py | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/apps/notification/backend/business/notification_manager.py b/apps/notification/backend/business/notification_manager.py index 786338f..eac6f63 100644 --- a/apps/notification/backend/business/notification_manager.py +++ b/apps/notification/backend/business/notification_manager.py @@ -86,26 +86,44 @@ class NotificationManager: properties: dict, region: Optional[UserRegion] = None, ) -> str: - # leverage the information in properties to enrich the message. - message_subject = None - message = None - if subject.lower() == "payment": - pass - - # Default region to be international if not set + # Default region to international if not set if region is None: region = UserRegion.OTHER - message_subject = SystemNotifications[region][subject.lower()][event.lower()][ - "message_subject" - ] - message = SystemNotifications[region][subject.lower()][event.lower()]["message"] + subject_lower = subject.lower() + event_lower = event.lower() - if event.lower() == "authentication": - message = message.format(properties["auth_code"]) - if not message: - raise RuntimeError("unsupported event:{}".format(event)) - return message, message_subject + try: + # Get message template and subject from SystemNotifications + notification_config = SystemNotifications[region][subject_lower][event_lower] + message = notification_config["message"] + message_subject = notification_config["message_subject"] + + # Handle authentication specific formatting + if event_lower == "authentication" and "auth_code" in properties: + message = message.format(properties["auth_code"]) + + # Append content_text if it exists in properties + if properties.get("content_text"): + if isinstance(properties["content_text"], dict): + # If content_text is a dictionary, use format with kwargs + message = message.format(**properties["content_text"]) + elif isinstance(properties["content_text"], str): + # If content_text is a string, append it with proper spacing + content = properties["content_text"].strip() + if message and content: + # Use HTML line breaks for email compatibility + message = f"{message.rstrip()}

{content}" + else: + # If either is empty, just use the non-empty one + message = message or content + + return message, message_subject + + except KeyError as e: + raise RuntimeError(f"Unsupported configuration - subject: {subject_lower}, event: {event_lower}, error: {str(e)}") + except ValueError as e: + raise RuntimeError(f"Invalid message format - error: {str(e)}") async def send_in_app_notification( self, receiver_id: str, subject: str, event: str, properties: dict = None From 5e66fa806b96edef0d74384bd98d9ec44ab25ab3 Mon Sep 17 00:00:00 2001 From: dongli Date: Sun, 16 Mar 2025 13:13:43 -0700 Subject: [PATCH 20/23] Log urls at create_account_link --- apps/payment/backend/business/stripe_manager.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/payment/backend/business/stripe_manager.py b/apps/payment/backend/business/stripe_manager.py index 49fef8a..9b8b749 100644 --- a/apps/payment/backend/business/stripe_manager.py +++ b/apps/payment/backend/business/stripe_manager.py @@ -25,6 +25,14 @@ class StripeManager: async def create_account_link(self, account_id: str, link_type: str = "account_onboarding") -> Optional[str]: account = stripe.Account.retrieve(account_id) # For account_update, try to show dashboard if TOS is accepted + + self.module_logger.log_info("create_account_link urls", + { + "redirect_url": "{}/work".format(self.site_url_root), + "refresh_url": "{}/front-door".format(self.site_url_root), + "return_url": "{}/work".format(self.site_url_root) + } + ) if link_type == "account_update" and account.tos_acceptance.date: login_link = stripe.Account.create_login_link( account_id, From d184ba9d5d3629a1346d84e144f0e51b89e72253 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 17 Mar 2025 09:52:42 +0000 Subject: [PATCH 21/23] chore(release): bump version to 1.1.0 and upload released assets [ci skip] --- CHANGELOG.md | 8 ++++++++ VERSION | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05e6f24..d193e87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# [1.1.0](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/compare/v1.0.0...v1.1.0) (2025-03-17) + + +### Features + +* **observability:** add configuration options and implement metrics/probes APIs ([d5e42d3](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/d5e42d31a4ce1ac64f6c5dcf5688c0acae1fdaa6)) +* **probes:** add metrics and probes APIs for application health checks ([9754576](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/9754576d28066c9805e5e4673e03fd79b3a603bd)) + # 1.0.0 (2025-03-06) diff --git a/VERSION b/VERSION index 3eefcb9..9084fa2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.1.0 From 21b49df49cf25434bfc37846c262d504ff09acfe Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 17 Mar 2025 13:57:21 +0000 Subject: [PATCH 22/23] chore(release): bump version to 1.1.1 and upload released assets [ci skip] --- CHANGELOG.md | 7 +++++++ VERSION | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d193e87..e21a1e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.1.1](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/compare/v1.1.0...v1.1.1) (2025-03-17) + + +### Bug Fixes + +* invalid import path for app config ([4dfbab4](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/commit/4dfbab4d4de83fbe5140c05071d8138cb09ef688)) + # [1.1.0](https://dev.azure.com/freeleaps/freeleaps-service-hub/_git/freeleaps-service-hub/compare/v1.0.0...v1.1.0) (2025-03-17) diff --git a/VERSION b/VERSION index 9084fa2..524cb55 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.1.1 From b95a818e305d5499e89ecd63f93b6a9b54eb1e27 Mon Sep 17 00:00:00 2001 From: Jet Li Date: Sun, 20 Apr 2025 00:05:00 -0700 Subject: [PATCH 23/23] Update payment redirect and scheduler job for deleting document id --- .../backend/document/document_manager.py | 6 +++++- apps/content/scheduler/scheduler_manager.py | 21 ++++++++----------- .../backend/business/stripe_manager.py | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/apps/content/backend/document/document_manager.py b/apps/content/backend/document/document_manager.py index 1d62ebc..8db5f40 100644 --- a/apps/content/backend/document/document_manager.py +++ b/apps/content/backend/document/document_manager.py @@ -1,6 +1,7 @@ from common.config.app_settings import app_settings from backend.content.models import DocumentDoc from backend.document.models import BasicProfileDoc +from datetime import datetime, timezone import httpx import base64 @@ -53,9 +54,12 @@ class DocumentManager: print(f"Failed to queue deletion: {response.text}") async def cleanup_document(self): + # Get today's date at midnight (UTC) + today_start = datetime.now(timezone.utc).replace(hour=0, minute=0, second=0, microsecond=0) # Corrected query with regex documents = await DocumentDoc.find( - {"created_by": {"$regex": "^content-service-"}} + {"created_by": {"$regex": "^content-service-"}, + "create_time": {"$lt": today_start}} ).to_list() if documents: diff --git a/apps/content/scheduler/scheduler_manager.py b/apps/content/scheduler/scheduler_manager.py index d35fe86..fe1bb79 100755 --- a/apps/content/scheduler/scheduler_manager.py +++ b/apps/content/scheduler/scheduler_manager.py @@ -1,5 +1,6 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler from apscheduler.triggers.date import DateTrigger +from apscheduler.triggers.cron import CronTrigger from datetime import datetime, timedelta from scheduler.refresh_sharepoint_content_job import ( refresh_sharepoint_content_job, @@ -28,15 +29,11 @@ async def register_job(scheduler: AsyncIOScheduler): "date", run_date=datetime(2025, 2, 7, 20, 0, 0), ) - # Register cleanup_document_job as a one-time job - # This job is just one-time job for removing many unused documents - # Run already, now comment it out - # await init_lock(ScheduleJobLocker.CLEANUP_DOCUMENT_JOB_LOCKER) - # execution_time = datetime.now() + timedelta( - # seconds=60 - # ) # Schedule to run 60 seconds from now - # scheduler.add_job( - # cleanup_document_job, # Job function - # trigger=DateTrigger(run_date=execution_time), # One-time trigger - # id="cleanup_document_one_time", # Optional: Give the job an ID - # ) + + await init_lock(ScheduleJobLocker.CLEANUP_DOCUMENT_JOB_LOCKER) + scheduler.add_job( + cleanup_document_job, + trigger=CronTrigger(hour=2, minute=0), # Runs every day at 2:00 AM + id="cleanup_document_daily", + ) + diff --git a/apps/payment/backend/business/stripe_manager.py b/apps/payment/backend/business/stripe_manager.py index 9b8b749..656f884 100644 --- a/apps/payment/backend/business/stripe_manager.py +++ b/apps/payment/backend/business/stripe_manager.py @@ -292,10 +292,10 @@ class StripeManager: }, }, mode="payment", - success_url="{}/work-space".format( + success_url="{}/projects".format( self.site_url_root ), # needs to be set, local: http://localhost/ - cancel_url="{}/work-space".format(self.site_url_root), + cancel_url="{}/projects".format(self.site_url_root), ) if session: