-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add domain logic for push notifications (#1778)
Leverages the `NotificationsDatasource` to `getSubscribersWithTokensBySafe` for the relative `TransactionEventType` and `enqueueNotification`s accordingly: - Add `INotificationsRepositoryV2` behind a feature flag: - `enqueueNotification` - `upsertSubscriptions` - `getSafeSubscription` - `getSubscribersWithTokensBySafe` - `deleteSubscription` - `deleteDevice` - Extend `HooksRepository` with `onEventEnqueueNotifications` with respective entities. - Add `transaction_hash` query to `getIncomingTransfers` and propagate changes/add tests. - Locate previously domain-relative logic for notifications in domain, e.g. entities and builders. - Add approriate test coverage.
- Loading branch information
Showing
38 changed files
with
3,463 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
23 changes: 23 additions & 0 deletions
23
src/datasources/notifications/__tests__/test.notifications.datasource.module.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { INotificationsDatasource } from '@/domain/interfaces/notifications.datasource.interface'; | ||
import { Module } from '@nestjs/common'; | ||
|
||
const accountsDatasource: INotificationsDatasource = { | ||
deleteDevice: jest.fn(), | ||
deleteSubscription: jest.fn(), | ||
getSafeSubscription: jest.fn(), | ||
getSubscribersBySafe: jest.fn(), | ||
upsertSubscriptions: jest.fn(), | ||
}; | ||
|
||
@Module({ | ||
providers: [ | ||
{ | ||
provide: INotificationsDatasource, | ||
useFactory: (): jest.MockedObjectDeep<INotificationsDatasource> => { | ||
return jest.mocked(accountsDatasource); | ||
}, | ||
}, | ||
], | ||
exports: [INotificationsDatasource], | ||
}) | ||
export class TestNotificationsDatasourceModule {} |
3 changes: 1 addition & 2 deletions
3
src/datasources/notifications/__tests__/upsert-subscriptions.dto.entity.builder.ts
This file contains 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
14 changes: 14 additions & 0 deletions
14
src/datasources/notifications/notifications.datasource.module.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { AccountsDatasourceModule } from '@/datasources/accounts/accounts.datasource.module'; | ||
import { NotificationsDatasource } from '@/datasources/notifications/notifications.datasource'; | ||
import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.module'; | ||
import { INotificationsDatasource } from '@/domain/interfaces/notifications.datasource.interface'; | ||
import { Module } from '@nestjs/common'; | ||
|
||
@Module({ | ||
imports: [PostgresDatabaseModule, AccountsDatasourceModule], | ||
providers: [ | ||
{ provide: INotificationsDatasource, useClass: NotificationsDatasource }, | ||
], | ||
exports: [INotificationsDatasource], | ||
}) | ||
export class NotificationsDatasourceModule {} |
This file contains 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
This file contains 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
20 changes: 20 additions & 0 deletions
20
src/datasources/push-notifications-api/__tests__/test.push-notifications-api.module.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Global, Module } from '@nestjs/common'; | ||
import { IPushNotificationsApi } from '@/domain/interfaces/push-notifications-api.interface'; | ||
|
||
const mockPushNotificationsApi: IPushNotificationsApi = { | ||
enqueueNotification: jest.fn(), | ||
}; | ||
|
||
@Global() | ||
@Module({ | ||
providers: [ | ||
{ | ||
provide: IPushNotificationsApi, | ||
useFactory: (): jest.MockedObjectDeep<IPushNotificationsApi> => { | ||
return jest.mocked(mockPushNotificationsApi); | ||
}, | ||
}, | ||
], | ||
exports: [IPushNotificationsApi], | ||
}) | ||
export class TestPushNotificationsApiModule {} |
This file contains 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
3 changes: 2 additions & 1 deletion
3
src/datasources/push-notifications-api/push-notifications-api.module.ts
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.