Skip to content

feat: user subscriptions + subscription endpoints impl#1740

Open
cka-y wants to merge 4 commits into
mainfrom
feat/1692
Open

feat: user subscriptions + subscription endpoints impl#1740
cka-y wants to merge 4 commits into
mainfrom
feat/1692

Conversation

@cka-y

@cka-y cka-y commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary:
This pull request introduces a complete implementation of notification subscription management for both authenticated users and unauthenticated (public) APIs, including integration with the Brevo email provider for announcement subscriptions. It adds new API endpoints, shared helpers, and comprehensive unit tests, enabling users to manage their notification subscriptions and ensuring synchronization with the external email provider.

Key changes include:

API and Endpoint Additions

  • Added new public and authenticated subscription management endpoints by implementing SubscriptionsApiImpl and fully implementing subscription methods in UsersApiImpl, allowing users to create, update, list, and delete notification subscriptions. [1] [2]
  • Registered the new subscriptions_api routes with the main application to expose these endpoints. [1] [2] [3]

Brevo Integration

  • Refactored and expanded Brevo (email provider) integration: extracted contact/list management into reusable helpers, enabled syncing of api.announcements subscriptions with Brevo, and handled provider errors gracefully. [1] [2] [3]

Database and Model Layer

  • Added NotificationSubscriptionImpl for converting ORM subscription objects to Pydantic models, supporting both API layers.

Testing

  • Added comprehensive unit tests for the new public subscriptions API, covering success, error, and edge cases, including Brevo integration and error handling.
  • Updated test imports to support mocking Brevo helpers.

These changes provide robust, production-ready notification subscription management with external provider synchronization and thorough test coverage.
Summarize the changes in the pull request including how it relates to any issues (include the #number, or link them).

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with ./scripts/api-tests.sh to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)

@cka-y cka-y linked an issue Jun 15, 2026 that may be closed by this pull request
@cka-y cka-y marked this pull request as ready for review June 15, 2026 19:21
Comment thread docs/UserServiceAPI.yaml

/v1/subscriptions/{id}:
get:
summary: Get a subscription by ID (unauthenticated)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint is, in fact, protected by authentication/authorization.

email=email,
attributes={"MDB_SUBSCRIPTION_ID": subscription_id},
list_ids=[list_id],
update_enabled=True,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

sib_api_v3_sdk.CreateContact(
email=email,
attributes={"MDB_SUBSCRIPTION_ID": subscription_id},
list_ids=[list_id],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question]: Does the update_enabled add the list_id to the lists, or does it reset the list to only one list?

Comment thread docs/UserServiceAPI.yaml
"404":
description: Subscription not found.
delete:
summary: Delete a subscription by ID (unauthenticated)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here; this endpoint is authenticated, even though it's not an "user" endpoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[notifications] Subscription management API

2 participants