-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setting to enable/disable bot notifications
when sending praise.
- Loading branch information
1 parent
f302161
commit 850014e
Showing
2 changed files
with
60 additions
and
17 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...s/api/src/database/migrations/42_settings_add_discord_bot_praise_notifications_enabled.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,36 @@ | ||
import { SettingGroup } from '../../settings/enums/setting-group.enum'; | ||
import { SettingModel } from '../schemas/settings/23_settings.schema'; | ||
|
||
const settings = [ | ||
{ | ||
key: 'DISCORD_BOT_PRAISE_NOTIFICATIONS_ENABLED', | ||
value: true, | ||
defaultValue: true, | ||
type: 'Boolean', | ||
periodOverridable: false, | ||
label: 'Praise notifications enabled', | ||
description: | ||
'Unchecking this will disable all bot notifications from the Discord bot to individual users when praising.', | ||
group: SettingGroup.DISCORD, | ||
subgroup: 1, | ||
}, | ||
]; | ||
|
||
const up = async (): Promise<void> => { | ||
const settingUpdates = settings.map((s) => ({ | ||
updateOne: { | ||
filter: { key: s.key }, | ||
update: { $setOnInsert: { ...s } }, // Insert setting if not found, otherwise continue | ||
upsert: true, | ||
}, | ||
})) as any; | ||
|
||
await SettingModel.bulkWrite(settingUpdates); | ||
}; | ||
|
||
const down = async (): Promise<void> => { | ||
const allKeys = settings.map((s) => s.key); | ||
await SettingModel.deleteMany({ key: { $in: allKeys } }); | ||
}; | ||
|
||
export { up, down }; |
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