-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add push notification filtering settings (#3207)
- add admin mutation for filtered push notifications - add mutations for changing notification settings - filter various push notifications from payments
- Loading branch information
1 parent
28c220a
commit 79bf33b
Showing
58 changed files
with
1,395 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
checkedToNotificationCategory, | ||
disableNotificationCategory as domainDisableNotificationCategory, | ||
} from "@domain/notifications" | ||
import { AccountsRepository } from "@services/mongoose" | ||
|
||
export const disableNotificationCategory = async ({ | ||
accountId, | ||
notificationChannel, | ||
notificationCategory, | ||
}: { | ||
accountId: AccountId | ||
notificationChannel?: NotificationChannel | ||
notificationCategory: string | ||
}): Promise<Account | ApplicationError> => { | ||
const checkedNotificationCategory = checkedToNotificationCategory(notificationCategory) | ||
if (checkedNotificationCategory instanceof Error) return checkedNotificationCategory | ||
|
||
const account = await AccountsRepository().findById(accountId) | ||
if (account instanceof Error) return account | ||
|
||
const newNotificationSettings = domainDisableNotificationCategory({ | ||
notificationSettings: account.notificationSettings, | ||
notificationChannel, | ||
notificationCategory: checkedNotificationCategory, | ||
}) | ||
|
||
account.notificationSettings = newNotificationSettings | ||
|
||
return AccountsRepository().update(account) | ||
} |
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,22 @@ | ||
import { disableNotificationChannel as domainDisableNotificationChannel } from "@domain/notifications" | ||
import { AccountsRepository } from "@services/mongoose" | ||
|
||
export const disableNotificationChannel = async ({ | ||
accountId, | ||
notificationChannel, | ||
}: { | ||
accountId: AccountId | ||
notificationChannel: NotificationChannel | ||
}): Promise<Account | ApplicationError> => { | ||
const account = await AccountsRepository().findById(accountId) | ||
if (account instanceof Error) return account | ||
|
||
const newNotificationSettings = domainDisableNotificationChannel({ | ||
notificationSettings: account.notificationSettings, | ||
notificationChannel, | ||
}) | ||
|
||
account.notificationSettings = newNotificationSettings | ||
|
||
return AccountsRepository().update(account) | ||
} |
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,31 @@ | ||
import { | ||
checkedToNotificationCategory, | ||
enableNotificationCategory as domainEnableNotificationCategory, | ||
} from "@domain/notifications" | ||
import { AccountsRepository } from "@services/mongoose" | ||
|
||
export const enableNotificationCategory = async ({ | ||
accountId, | ||
notificationChannel, | ||
notificationCategory, | ||
}: { | ||
accountId: AccountId | ||
notificationChannel?: NotificationChannel | ||
notificationCategory: string | ||
}): Promise<Account | ApplicationError> => { | ||
const checkedNotificationCategory = checkedToNotificationCategory(notificationCategory) | ||
if (checkedNotificationCategory instanceof Error) return checkedNotificationCategory | ||
|
||
const account = await AccountsRepository().findById(accountId) | ||
if (account instanceof Error) return account | ||
|
||
const newNotificationSettings = domainEnableNotificationCategory({ | ||
notificationSettings: account.notificationSettings, | ||
notificationChannel, | ||
notificationCategory: checkedNotificationCategory, | ||
}) | ||
|
||
account.notificationSettings = newNotificationSettings | ||
|
||
return AccountsRepository().update(account) | ||
} |
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,22 @@ | ||
import { enableNotificationChannel as domainEnableNotificationChannel } from "@domain/notifications" | ||
import { AccountsRepository } from "@services/mongoose" | ||
|
||
export const enableNotificationChannel = async ({ | ||
accountId, | ||
notificationChannel, | ||
}: { | ||
accountId: AccountId | ||
notificationChannel: NotificationChannel | ||
}): Promise<Account | ApplicationError> => { | ||
const account = await AccountsRepository().findById(accountId) | ||
if (account instanceof Error) return account | ||
|
||
const newNotificationSettings = domainEnableNotificationChannel({ | ||
notificationSettings: account.notificationSettings, | ||
notificationChannel, | ||
}) | ||
|
||
account.notificationSettings = newNotificationSettings | ||
|
||
return AccountsRepository().update(account) | ||
} |
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
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
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
Oops, something went wrong.