Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add v2 notifications routes #1787

Merged
merged 53 commits into from
Aug 7, 2024
Merged

Add v2 notifications routes #1787

merged 53 commits into from
Aug 7, 2024

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Jul 25, 2024

Summary

This adds SiWe-guard routes for upserting push notification subscriptions/getting preferences, as well as deletion routes for Safe/device subscriptions.

POST /v2/register/notifications (guarded)

The cloudMessagingToken is the Firebase Cloud Messaging token for the device being registered. A UUID can be provided for this device, or one will be returned.

Subscriptions are provided per chain-specific Safe, alongside the preferences of which notification types should be subscribed-to.

Note: the given preferences overwrites existing ones if upserting a subscription.

enum NotificationType {
  CONFIRMATION_REQUEST = 'CONFIRMATION_REQUEST',
  DELETED_MULTISIG_TRANSACTION = 'DELETED_MULTISIG_TRANSACTION',
  EXECUTED_MULTISIG_TRANSACTION = 'EXECUTED_MULTISIG_TRANSACTION',
  INCOMING_ETHER = 'INCOMING_ETHER',
  INCOMING_TOKEN = 'INCOMING_TOKEN',
  MESSAGE_CONFIRMATION_REQUEST = 'MESSAGE_CONFIRMATION_REQUEST',
  MODULE_TRANSACTION = 'MODULE_TRANSACTION',
}

type Request = {
  cloudMessagingToken: string;
  safes: Array<{
    chainId: string;
    address: `0x${string}`;
    notificationTypes: Array<NotificationType>;
  }>
  deviceType: 'ANDROID' | 'IOS' | 'WEB';
  deviceUuid?: `${string}-${string}-${string}-${string}-${string}`;
}

type Response = {
  deviceUuid: `${string}-${string}-${string}-${string}-${string}`;
}

GET /v2/chains/:chainId/notifications/devices/:deviceUuid/safes/:safeAddress (guarded)

This returns an array of NotificationTypes for the respective Safe.

type Response = Array<NotificationType>

DELETE /v2/chains/:chainId/notifications/devices/:deviceUuid/safes/:safeAddress

This deletes the device-specific subscription for the given Safe.

DELETE /v2/chains/:chainId/notifications/devices/:deviceUuid

This deleted the device, and therefore all subscriptions associated with it.

Changes

  • Create above routes in a new NotificationsModuleV2 with associated service and controller, tweaking the respective repository/datasource in accordance.
  • Add relative validation for entities:
    • Create UpsertSubscriptionsDto, located on the route level and infer the type from it.
    • Create UuidSchema.
  • Remove Uuid entity in place of crypto.UUID.
  • Add appropriate tests.

@iamacook iamacook self-assigned this Jul 25, 2024
@iamacook iamacook requested a review from a team as a code owner July 25, 2024 15:12
@iamacook iamacook changed the title Add /v1/accounts/:address/notifications/devices routes Add v2 notifications routes Jul 31, 2024
@hectorgomezv hectorgomezv self-requested a review August 5, 2024 21:05
hectorgomezv
hectorgomezv previously approved these changes Aug 5, 2024
Base automatically changed from notifications-domain to main August 6, 2024 09:59
@iamacook iamacook dismissed hectorgomezv’s stale review August 6, 2024 09:59

The base branch was changed.

@hectorgomezv hectorgomezv self-requested a review August 6, 2024 15:33
@iamacook iamacook merged commit ee04156 into main Aug 7, 2024
16 checks passed
@iamacook iamacook deleted the notifications-routes branch August 7, 2024 06:53
DenSmolonski pushed a commit to Zilliqa/safe-client-gateway that referenced this pull request Oct 24, 2024
Adds v2 notifications routes for upserting push notification subscriptions/getting preferences, as well as deletion routes for Safe/device subscriptions:

- `POST` `/v2/register/notifications` (guarded)
- `GET` `/v2/chains/:chainId/notifications/devices/:deviceUuid/safes/:safeAddress` (guarded)
- `DELETE` `/v2/chains/:chainId/notifications/devices/:deviceUuid/safes/:safeAddress`
- `DELETE` `/v2/chains/:chainId/notifications/devices/:deviceUuid`

- Create above routes in a new `NotificationsModuleV2` with associated service and controller, tweaking the respective repository/datasource in accordance.
- Add relative validation for entities:
  - Create `UpsertSubscriptionsDto`, located on the route level and infer the type from it.
  - Create `UuidSchema`.
- Remove `Uuid` entity in place of `crypto.UUID`.
- Add appropriate tests.
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.

3 participants