Guidance on creating a topic approval by category plugin



  • Hey, all. I'm trying to get into plugin development to customize my nodeBB site but I'm finding the documentation a little lacking and my search attempts haven't been too fruitful, so my apologies if I'm asking silly/repeated questions.

    So, my end goal is that I'd like one specific topic category to require approval on all topic creations to ensure quality in that category (in my case, how-to instructions/guides). So, basically I'd like to utilize the post queue but instead of by new member, by category instead.

    First off, how could I best store this data? I'll probably make a basic ACP page to read and allow selection of categories admins would desire requiring approval in. But then, what calls would I need to make to store this data in the DB? Should it be attached to the category data? Is there a more appropriate place to put it?

    Second I assume I'll be using the filter:post.shouldQueue hook? How would I ultimately figure out if they're posting in a category requiring approval/access the data from the first question?

    Thanks in advance!


  • Admin

    Well, that filter looks to be right (at least, by name). On the receiving end, once you've registered a hook listener to that hook, the method you register will be called with a single data object and a callback.

    That data object contains shouldQueue, a Boolean (change this if you want the post to be queued), uid, the uid creating the post, and data, a catch-all that contains the post data, likely.

    Check for the cid in there, and if not present, the tid is probably going to be there. You can then call getTopicField(theTid, 'cid', function (err, cid) { ... }); to get the cid.

    Determine whether the cid is the one you want to queue replies, and adjust shouldQueue boolean as appropriate 👍

    Then call the callback with the same arguments: callback(null, data);



  • Awesome, thanks! Here's hoping.


Log in to reply
 

Suggested Topics

| |