-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(settings): add battle notifier settings #616
base: dev
Are you sure you want to change the base?
Conversation
Must be addressed
|
731dafd
to
c7c4b13
Compare
|
8741085
to
0b51378
Compare
Got migration SQL script from |
0b51378
to
6d523d9
Compare
src/data/models/BnKuskiRule.js
Outdated
allowNull: false, | ||
defaultValue: 0, | ||
}, | ||
CreatedAt: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these for now
src/api/player.js
Outdated
return get; | ||
}; | ||
|
||
const ChangeBnEnabledSettings = async data => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to singular
src/api/player.js
Outdated
const rules = await BnKuskiRule.findAll({ | ||
where: { KuskiIndex: setting.KuskiIndex }, | ||
}); | ||
const isFirstTimeSetup = !rules.length && data.BnKuskiRules.length > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened in "Any by any" rule? Is rule being created as empty? Is it considered first setup here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked and notify "Any" battle creates an empty rule (no designers, no battle types, etc...) which is expected behaviour with current bot logic. Found a bug that made every update turn BnEnabled off. Fix: only update BnEnabled in first time setup. Otherwise only update BnEnabled via toggle endpoint.
src/api/player.js
Outdated
{ where: { KuskiIndex: setting.KuskiIndex } }, | ||
); | ||
|
||
// delete all BnKuskiRules from this user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can try Ismo suggestions https://discord.com/channels/207629806513160192/220952076266635264/1123624752364396626
can be followup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to simplify this a little bit with better methods from sequelize but could not use those recommended magic methods. This is where I miss TypeScript most times, while using libraries without much API help at code level.
@@ -0,0 +1,6 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the reason for adding this? it's already in .eslintrc.json
jwtSecret: | ||
'eAwI4zcTDd4Pvc8QtN9z57Fqsr4ENNcTpK1x4A1dCLj0Y44OravXZDzNbA-4VEwAIh1Hw3vn1nhB9ygWLqAGE4GiX6hjjLsJi8IJ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it has eslint ignore above, something about your settings or the new .prettierrc.json forcing it anyway?
Battle Notifier migration discussion here.
What changes are proposed in this pull request?
Add new
bn_kuski_rule
table and updatesetting
table to store notification settings.GET api/bn/:DiscordId
- get user settings ifDiscordId
exists in DB.SET api/bn/:DiscordId
- override user notification rulesBnEnabled
should be set to true.GET api/bn
- gets all "active" settings withBnEnabled
and at least oneBnKuskiRule
SET api/bn/:DiscordId/toggle/:BnEnabled
- turn notifications on/off (BnEnabled
)GET api/bn/:DiscordId/linked
- doesDiscordId
exist in DB