Accessing nodeBB functions via Cron Jobs



  • Hey,

    How can I access nodeBB's functions via crond? I'd like to automatically sync the nodebb database against another database (primarily users and groups) every 5 minutes or so. This would require me to access core functions like "User.getUidByUsername()" or "User.create()" from inside the cronjob. Is there any plugin that does this already?

    Thanks for your help!


  • Admin

    I don't think so... your best bet is to code a NodeBB plugin that pings the second service when a new user is created.



  • I already have my own plugin that does synchronize every time a user logs in. But, this means that logged in users won't be up to date as long as their session still exists ("stay logged in"). This can be annoying for changes of group memberships, but it can also be a security issue for changes in the ban status of an existing user.

    If I understood you right the service to service ping that happens if a new user is created wouldn't help the issue either.

    Any chance for an API that allows CRUD operations on users, settings and groups?


  • Admin

    @alexschomb Something like this? 😄



  • Yes. That's great, thank you!

    I read through the documentation of the API and found out that I need to provide _uid for usage with a master token. Is there any way to find out about the UID of a certain username via the API? (similar to User.getUidByUsername())

    The API allows us to request membership to private groups. Is there an API call to accept this membership request with the _uid of an admin user? Or is it even possible to add/remove a certain user (different to the _uid) to a certain group using an admin _uid?


  • Plugin & Theme Dev



  • Thanks, that should do the trick! :)

    Gonna post my cronjob as soon as it's ready. Can take a few days, because of christmas.


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.