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

Add cronjob to notify admin about missing solvers (#314) #563

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

Conversation

doitwithnotepad
Copy link

  • Schedule a daily job at midnight to check for solvers using node-schedule.

  • Implement checkSolvers(bot) to send a message to the community admin if no solvers are found.

  • Increment the count of messages sent to the admin in the database.

  • Add logic to disable the community if no solvers are added after a specified number of notifications.

Fixes #314

- Schedule a daily job at midnight to check for solvers using `node-schedule`.

- Implement `checkSolvers(bot)` to send a message to the community admin if no solvers are found.

- Increment the count of messages sent to the admin in the database.

- Add logic to disable the community if no solvers are added after a specified number of notifications.

Fixes lnp2pBot#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.

Hi @doitwithnotepad when it has to check if there are solvers it shows this in the logs :
error: Unhandled Rejection: TypeError: checkSolvers is not a function

jobs/check_solvers.ts Outdated Show resolved Hide resolved
jobs/check_solvers.ts Outdated Show resolved Hide resolved
@doitwithnotepad
Copy link
Author

Hi @doitwithnotepad when it has to check if there are solvers it shows this in the logs : error: Unhandled Rejection: TypeError: checkSolvers is not a function

It should now, 28360d2.

jobs/check_solvers.ts Outdated Show resolved Hide resolved
@@ -7,6 +7,7 @@ const deleteOrders = require('./delete_published_orders');
const calculateEarnings = require('./calculate_community_earnings');
const deleteCommunity = require('./communities');
const nodeInfo = require('./node_info');
const checkSolvers = require('./check_solvers');
Copy link
Member

Choose a reason for hiding this comment

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

Hi @doitwithnotepad please test the code before push a commit, that way you'll see if it works or not

we are getting the same error

error: Unhandled Rejection: TypeError: checkSolvers is not a function

this is because the function checkSolvers() is not well imported, please replace with:

const { checkSolvers } = require('./check_solvers');

logger.info(`Community ${community._id} has been disabled due to lack of solvers.`);
} else {
await community.save();
const admin = await User.findOne({ tg_id: community.creator_id, admin: true });
Copy link
Member

Choose a reason for hiding this comment

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

user.admin is only used for global admin, not community admins, we don't need to add it on this findOne() request

@grunch
Copy link
Member

grunch commented Aug 29, 2024

Hi @doitwithnotepad which is the status of this PR? are you able to finish it?

@Catrya
Copy link
Member

Catrya commented Oct 22, 2024

Hi @doitwithnotepad, are you able to finish this PR? The issue #314 is on the reward board , if you don't finish it, we should allow another dev to do it, and move it to status: looking for dev, what do you think?

@doitwithnotepad
Copy link
Author

I can't do it right now, maybe later, sorry for the delay in answering.

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
3 participants