How schedule topic in future with node-cron?


  • GNU/Linux

    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);
    
    	task.start();
    };
    

    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?


  • Admin

    @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?


  • GNU/Linux

    @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?


Log in to reply
 


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