diff --git a/lib/boards-api.js b/lib/boards-api.js index 574b624..4af76e8 100644 --- a/lib/boards-api.js +++ b/lib/boards-api.js @@ -309,16 +309,13 @@ BoardsAPI.prototype.retrieveListOfApproved = function(what,addr,adminID,board){ BoardsAPI.prototype.getAllowedContentProducers = function(adminID,board,options){ if(!options) return - this.ee.on('settings for'+board+'@'+adminID,function(settings,addr){ + this.ee.on('settings for '+board+'@'+adminID,function(settings,addr){ // Get stuff based on settings if(settings.approval_required == true){ // Get approved posts list if(options.posts) this.retrieveListOfApproved('posts',addr,adminID,board) // Get approved comments list if(options.comments) this.retrieveListOfApproved('comments',addr,adminID,board) - if(settings.whitelist == true){ - // TODO: emit all whitelisted users - } } else if(settings.whitelist_only == true){ // TODO: emit all whitelisted users } else if(settings.blacklist == true){ @@ -335,13 +332,22 @@ BoardsAPI.prototype.getPostsInBoard = function(adminID,board){ // Automatically download approved posts ret.forEach(item => this.downloadPost(item.hash,adminID,board)) }) + this.ee.on('whitelist for '+board+'@'+adminID, whitelist => { + // download posts for each user in whitelist + whitelist.forEach(item => { + this.getUserPostListInBoard(item,board,(err,postList) => { + postList.forEach( i => this.downloadPost(i,adminID,board)) + }) + }) + }) + // Get allowed content and content producers + this.getAllowedContentProducers(adminID,board,{ posts: true }) // Get the admin's posts this.getUserPostListInBoard(adminID,board,(err,res) => { if(err){ console.log(err) } else res.forEach(item => this.downloadPost(item.hash,adminID,board,adminID)) }) - this.getAllowedContentProducers(adminID,board,{ posts: true }) } else { // TODO: Download all posts in board from everyone // Download my posts