mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-03-11 21:38:38 +01:00
periodic user finder now works
This commit is contained in:
parent
49e8a75e3d
commit
1eb90a7653
@ -38,7 +38,16 @@ function replyAsObj(res,isJson,done){
|
||||
function BoardsAPI(ipfs){
|
||||
this.ipfs = ipfs
|
||||
this.version = 'dev'
|
||||
this.users = {}
|
||||
this.users = {} // userID : profileHash
|
||||
this.posts = {} // boardName : postsList
|
||||
this.comments = {} // objectID : comments
|
||||
}
|
||||
|
||||
BoardsAPI.prototype.downloadJSON = function(addr,done){
|
||||
this.ipfs.cat(addr,(err,res) => {
|
||||
if(err) return done(err)
|
||||
replyAsObj(res,true,done)
|
||||
})
|
||||
}
|
||||
|
||||
// This function works but needs a little rethinking.
|
||||
@ -92,6 +101,7 @@ BoardsAPI.prototype.searchUsers = function(){
|
||||
this.ipfs.swarm.peers((err,r) => {
|
||||
if(err) return console.log(err)
|
||||
replyAsObj(r,true,(e,reply) => {
|
||||
console.log('Checking',reply.Strings.length,'peers')
|
||||
reply.Strings.forEach(this.isUser.bind(this))
|
||||
})
|
||||
})
|
||||
@ -130,18 +140,35 @@ BoardsAPI.prototype.getBoardSettings = function(userID,board,done){
|
||||
})
|
||||
}
|
||||
|
||||
BoardsAPI.prototype.getBoardPosts = function(board,administratorID,done){
|
||||
// Returns a stream
|
||||
BoardsAPI.prototype.getBoardPostList = function(board,administratorID,done){
|
||||
this.getBoardSettings(administratorID,board,(err,res) => {
|
||||
// NEEDS: board settings structure definition
|
||||
})
|
||||
}
|
||||
|
||||
BoardsAPI.prototype.getUserPosts = function(user,board,done){
|
||||
// Returns a stream
|
||||
BoardsAPI.prototype.getUserPostList = function(user,board,done){
|
||||
this.resolveIPNS(user,(err,url) => {
|
||||
if(err){
|
||||
done(err)
|
||||
} else this.ipfs.ls(url+'/boards/'+board,(e,r) => {
|
||||
if(e){
|
||||
done(e)
|
||||
} else {
|
||||
var l = r.map(i => {
|
||||
return { date: i.Name, hash: i.Hash }
|
||||
})
|
||||
done(null,r)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
BoardsAPI.prototype.getComments = function(parent,board,done){
|
||||
// Returns a stream
|
||||
BoardsAPI.prototype.getCommentsFor = function(parent,done){
|
||||
|
||||
}
|
||||
|
||||
// Work only in writable mode:
|
||||
|
||||
BoardsAPI.prototype.createPost = function(post,board,done){
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,8 @@ app.get('/@:user/:board',(req,res) => {
|
||||
boards.getBoardSettings(req.params.user,req.params.board,apiToHandler(req,res))
|
||||
})
|
||||
|
||||
//boards.searchUsers()
|
||||
setInterval(boards.searchUsers.bind(boards),3 * 60 * 1000)
|
||||
boards.searchUsers()
|
||||
|
||||
// Start the web server
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user