How schedule topic in future with node-cron?

NodeBB Development
  • I want schedule topic in the future with node-cron module. In details I want delay the topic creation at some timestamp. So in my plugin.jso I put this hook:

    "hook": "filter:topic.create", "method": "editTopic"

    and in my library.js I do:

    converter.editTopic = function(data, callback) {
    	var task = cron.schedule('* * * * *', function() {
    		return callback(null, data);
    	}, false);

    If I execute my code, the topic creation is schedule after a minute but in this minute the composer to write topics and posts is blocked. After that node-cron executes its task the composer become unblocked.

    I don't know if I can schedule topic in the future with node-cron, Anyone can help me to understand or I can do that?

  • @Doppy The reason why the composer is blocked here is because you call callback within the callback for the cron task. So it will not be called until the cronjob is executed.

    I don't think the hook you used it correct... under what conditions did you want the delayed posting done?

  • @julian I have a timestamp and I need to schedule the topic at this timestamp. So suppose that I want schedule topic at 01/12/2017(only) how can I modify the code to schedule the topic at these date?

Suggested Topics

| | | |