Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Anyitechs
Copy link

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

Copy link
Member

@Catrya Catrya left a 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

@Anyitechs
Copy link
Author

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.

@Anyitechs
Copy link
Author

Anyitechs commented Jan 3, 2025

Hi @Catrya, I've addressed all the feedbacks here. Please have a look and let me know if there're other changes.

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

Copy link
Member

@Catrya Catrya left a 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!

@Anyitechs
Copy link
Author

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.

Copy link
Member

@Catrya Catrya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. Thanks @Anyitechs !

Copy link
Member

@Catrya Catrya left a 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

@Anyitechs
Copy link
Author

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 is_disabled flag to the community model. But why do we need to disable a community first and also delete it from the database. Why don't we go ahead and delete the community rather than having to disable it first?

Any thoughts? @grunch

@Catrya
Copy link
Member

Catrya commented Jan 20, 2025

Thank you @Catrya. I was thinking we needed a soft delete and that was why I added the is_disabled flag to the community model. But why do we need to disable a community first and also delete it from the database. Why don't we go ahead and delete the community rather than having to disable it first?

Any thoughts? @grunch

Hi @Anyitechs , I don't mean to disable it first and then delete it, but to delete it.
Send messages to users as you already do, but if admin doesn't add a solver, just delete it from the database (we already called that disabling)

@Anyitechs
Copy link
Author

Thank you @Catrya. I was thinking we needed a soft delete and that was why I added the is_disabled flag to the community model. But why do we need to disable a community first and also delete it from the database. Why don't we go ahead and delete the community rather than having to disable it first?
Any thoughts? @grunch

Hi @Anyitechs , I don't mean to disable it first and then delete it, but to delete it. Send messages to users as you already do, but if admin doesn't add a solver, just delete it from the database (we already called that disabling)

That makes sense. Thank you for the clarification. I'll work on that and update the branch.

@Anyitechs
Copy link
Author

@Catrya I just pushed an update to the branch now. Please do take a look and let me know your thoughts. Thank you.

Copy link
Member

@Catrya Catrya left a 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

@Anyitechs
Copy link
Author

Anyitechs commented Jan 21, 2025

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.

@@ -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,
Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding them back now.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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
Copy link
Member

@grunch grunch Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


await bot.telegram.sendMessage(
admin.tg_id,
message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knocte
Copy link
Contributor

knocte commented Jan 23, 2025

as you can read in our contribution section, we are using the airbnb javascript guide style, please don't remove the comma

How about moving to a style that can be checked at CI time? e.g. with prettier

@knocte
Copy link
Contributor

knocte commented Jan 23, 2025

@webwarrior-ws hey, please check CI, it is red.

@knocte
Copy link
Contributor

knocte commented Jan 23, 2025

@webwarrior-ws hey, please check CI, it is red.

Oops wrong contributor!

@grunch
Copy link
Member

grunch commented Jan 23, 2025

as you can read in our contribution section, we are using the airbnb javascript guide style, please don't remove the comma

How about moving to a style that can be checked at CI time? e.g. with prettier

yes I have it locally but we need it at CI level

@Anyitechs
Copy link
Author

Thank you for the review @grunch. I just addressed the feedbacks, rebased and updated the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bot message to community admin to update solvers
4 participants