-
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.
- Loading branch information
1 parent
3a0d2d3
commit bba12c7
Showing
52 changed files
with
792 additions
and
371 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
31 changes: 31 additions & 0 deletions
31
src/app/accounts/disable-notification-category-for-channel.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,31 @@ | ||
import { | ||
checkedToNotificationCategory, | ||
disableNotificationCategoryForChannel as disableNotificationCategory, | ||
} from "@domain/notifications" | ||
import { AccountsRepository } from "@services/mongoose" | ||
|
||
export const disableNotificationCategoryForChannel = 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 = disableNotificationCategory({ | ||
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,23 @@ | ||
import { setNotificationChannelIsEnabled } 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 = setNotificationChannelIsEnabled({ | ||
notificationSettings: account.notificationSettings, | ||
notificationChannel, | ||
enabled: false, | ||
}) | ||
|
||
account.notificationSettings = newNotificationSettings | ||
|
||
return AccountsRepository().update(account) | ||
} |
31 changes: 31 additions & 0 deletions
31
src/app/accounts/enable-notification-category-for-channel.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,31 @@ | ||
import { | ||
checkedToNotificationCategory, | ||
enableNotificationCategoryForChannel as enableNotificationChannel, | ||
} from "@domain/notifications" | ||
import { AccountsRepository } from "@services/mongoose" | ||
|
||
export const enableNotificationCategoryForChannel = 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 = enableNotificationChannel({ | ||
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,23 @@ | ||
import { setNotificationChannelIsEnabled } 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 = setNotificationChannelIsEnabled({ | ||
notificationSettings: account.notificationSettings, | ||
notificationChannel, | ||
enabled: true, | ||
}) | ||
|
||
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 was deleted.
Oops, something went wrong.
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.