-
Notifications
You must be signed in to change notification settings - Fork 115
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: notify admin to update solvers in the community #618
base: main
Are you sure you want to change the base?
Conversation
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.
Hello, did you tested it locally? It's not working properly:
- This message is not being displayed:
Your community ${community.name} doesn't have any solvers. Please add at least one solver to avoid being disabled.
- Even though the logs say:
Community: ${community.name} has been disabled due to lack of solvers.
the community is not being disabled. You can continue using it normally. - I recommend putting the warning messages to the administrators in the language they have the bot set in, in the yaml of ./locales. You can see as an example at Add cronjob to notify admin about missing solvers (#314) #563
Thank you for the review. I'll work on these feedbacks. |
…sages are localized
Hi @Catrya, I've addressed all the feedbacks here. Please have a look and let me know if there're other changes.
|
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.
Hi @Anyitechs , much better, it already sends messages to the admins and disables the community. However, I think the message for the admins could be improved so that they know how much time they have to put a new admin.
I think it could be something like this:
Your community ${communityName} does not have any solvers. Please add at least one within X days to prevent the community from being disabled.
Actually the number of notifications that the solver receives before disabling the community is MAX_MESSAGES -1 because it disables it in MAX_MESSAGES, I suggest that it shows that number of notifications before disabling it
I will continue testing and I will tell you if I find any bug, good job!
Thank you for the feedback @Catrya. I just pushed a new commit with the changes requested here. Please take a look and let me know your thoughts. Thank you. |
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.
ACK. Thanks @Anyitechs !
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.
Hi @Anyitechs, sorry but I remembered that when a community is disabled it should also be deleted from the database, see deleteCommunity
This PR does not delete the community from the database, and I think that is necessary.
Anyway, let's see what @grunch thinks, sorry
Thank you @Catrya. I was thinking we needed a soft delete and that was why I added the Any thoughts? @grunch |
Hi @Anyitechs , I don't mean to disable it first and then delete it, but to delete it. |
That makes sense. Thank you for the clarification. I'll work on that and update the branch. |
eb20c72
to
bf0258f
Compare
@Catrya I just pushed an update to the branch now. Please do take a look and let me know your thoughts. Thank you. |
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.
thanks @Anyitechs I already tested it and it works well to me! Let's see @grunch review
Thank you @Catrya. @grunch let me know if there're any changes. Thank you. |
bot/modules/community/commands.js
Outdated
@@ -143,7 +143,7 @@ exports.updateCommunity = async (ctx, id, field, bot) => { | |||
if (!(await validateObjectId(ctx, id))) return; | |||
const community = await Community.findOne({ | |||
_id: id, | |||
creator_id: user._id, |
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.
as you can read in our contribution section, we are using the airbnb javascript guide style, please don't remove the comma
https://github.com/airbnb/javascript?tab=readme-ov-file#commas--dangling
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.
Adding them back now.
bot/modules/community/commands.js
Outdated
@@ -211,7 +211,7 @@ exports.deleteCommunity = async ctx => { | |||
if (!(await validateObjectId(ctx, id))) return; | |||
const community = await Community.findOne({ | |||
_id: id, | |||
creator_id: ctx.user._id, | |||
creator_id: ctx.user._id |
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.
bot/modules/community/commands.js
Outdated
@@ -233,7 +233,7 @@ exports.changeVisibility = async ctx => { | |||
if (!(await validateObjectId(ctx, id))) return; | |||
const community = await Community.findOne({ | |||
_id: id, | |||
creator_id: ctx.user._id, | |||
creator_id: ctx.user._id |
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.
jobs/check_solvers.ts
Outdated
|
||
await bot.telegram.sendMessage( | ||
admin.tg_id, | ||
message |
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.
How about moving to a style that can be checked at CI time? e.g. with prettier |
@webwarrior-ws hey, please check CI, it is red. |
Oops wrong contributor! |
yes I have it locally but we need it at CI level |
bf0258f
to
1772689
Compare
Thank you for the review @grunch. I just addressed the feedbacks, rebased and updated the branch. |
This PR schedules a daily job at midnight to notify the admin of a community that there are no solvers in the community. The maximum number of notification messages right now is set to 5, afterwards the community is disabled.
Fixes #314