Is it possibile create a topic in the future?


  • GNU/Linux

    Is it possibile create a topic automatically in the future with a timestamp ? Anyone can help me?


  • Admin

    Yes, you can pass a timestamp in the future to the topics.post method.


  • GNU/Linux

    @baris I suppose that I'm wroing something because the topic is not created in the future. In my plugin.json I use this hook:

    { "hook": "action:topic.save", "method": "modificaPost" }

    In my library.js I do this:

    converter.modificaPost = function(data, callback) {
    	console.log("DATA " + JSON.stringify(data));
    	//I Take the timestamp from database and you can suppose that it is correct because I check ten times.
    	async.waterfall([
    		function(next) {
    //take the timestamp relative to user
    		db.getObject(hash + ":uid:" + data.uid, next);
    		},
    		function(timestamp, next) {
    		var timestamp_nuovo = timestamp.timestamp;
    			data.timestamp = timestamp.timestamp;
    			Topics.post(data, next);
    		}
    	], function(err) {
    		if (err) {
    			//return callback(err);
    		}
    
    	console.log("DATA NUOVA " + JSON.stringify(data));
    		return callback(null, data);
    	});
    
    }; 
    

    Anyone can help me?


  • Plugin & Theme Dev

    @Doppy action:topic.save is triggered after the topic is created. You will want to listen to filter:topic.create and change the timestamp in the data passed to the hook.


Log in to reply
 


Star

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