How get all Users when the plugins is installed


  • GNU/Linux

    I need to get all users when that plugin is installed so I used this hook ( in my plugin.json):

    "hook": "action:plugin.activate", "method": "caricaVecchiBookmark"
    

    In my library.js

    
    converter.caricaVecchiBookmark = function(data, callback) {
    	console.log("ENTRARE QUI DENTRO");
    	async.waterfall([
    		function(next) {
    			
    			db.getSortedSetRangeWithScores('username:uid', start, stop, next);
    		}
    	], function(err, array_uid) {
    		if (err) {
    			return callback(err);
    		}
    		console.log("ARRAY UDI " + JSON.stringify(array_uid));
    		return callback(null,data);
    	});
    };
    

    The problem is that in the shell I can't read the console.log and I don't know why. When I click the activate button in my admin panel, I don't read the console.log. Anyone can help me?



  • @Doppy Ciao Doppy! 😄

    At first sight, you're trying to access to uid, that is not declared anywhere. So probably if you check in the log of nodebb, it says that cannot load the plugin (or that there were errors). Instead if it's loaded correctly, I don't know what's happening 😛 .

    Probably you should use data.uid?

    I don't really get what you want to do to be honest. Or probably I just don't know how the action:plugin.activate hooks works ^^'


  • GNU/Linux

    @Giggiux thanks for your suggest. I removed the wrong code line from the code but it doesn't work. This plugin has other functions and these functions work after that the plugin is loaded so I think this is not a load problem.


  • Global Moderator

    @Doppy make sure you're running with ./nodebb dev, so you get a realtime log.


  • Admin


  • GNU/Linux

    @baris I need to do some operation, one time after the plugin is installed. How can I do this if I can't use these hooks?


  • Admin

    Those hooks weren't working the way they were meant to, that's why they are deprecated. If you need to do a one time operation when the plugin is installed. Just set a flag in the database stating that the operation is done so it is not repeated on every restart of NodeBB.


Log in to reply
 


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