1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-25 14:54:19 +01:00

wip aggregation implementation

This commit is contained in:
Enrico Fasoli 2015-12-02 19:02:09 +01:00
parent fe7ea88d6a
commit d8f744301f

View File

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