diff options
author | Ev Bogue <ev@evbogue.com> | 2019-11-17 12:23:05 -0600 |
---|---|---|
committer | Ev Bogue <ev@evbogue.com> | 2019-11-17 12:23:05 -0600 |
commit | a83eb1a62d8c928414edaff6a4ef3a383b677bd3 (patch) | |
tree | 098bee89096d2a70676d78100ab24a54f1a3192a /server.js | |
parent | 8e4ebcffefb4c5b27020699418391572126c96a0 (diff) |
remove unused code
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 65 |
1 files changed, 1 insertions, 64 deletions
@@ -36,72 +36,9 @@ bog.keys().then(key => { var req = JSON.parse(message) if (req.sendpub) { ws.send(key.publicKey) - } - else { + } else { bog.unbox(req.box, req.requester, key).then(unboxed => { var unboxedreq = JSON.parse(nacl.util.encodeUTF8(unboxed)) - //console.log(unboxedreq) - /*if (unboxedreq.blobFile) { - var openedimg = nacl.sign.open(nacl.util.decodeBase64(unboxedreq.blobFile), nacl.util.decodeBase64(unboxedreq.author.substring(1))) - if (openedimg) { - //console.log(openedimg) - fs.writeFileSync(blobdir + '/' + sanitize(unboxedreq.blob), unboxedreq.blobFile, 'UTF-8') - console.log('received blob ' + unboxedreq.blob + ' from ' + req.requester + ' and saved to blobs folder') - } - } - if (unboxedreq.blob) { - console.log(req.requester + ' has requested the blob ' + unboxedreq.blob) - var blobExists = fs.existsSync(blobdir + '/' + sanitize(unboxedreq.blob)) - if (unboxedreq.needs) { - console.log(req.requester + ' needs ' + unboxedreq.blob + ' do we have it?') - if (blobExists) { - console.log('We have it, so send it to the client') - var blobToSend = fs.readFileSync(blobdir + '/' + sanitize(unboxedreq.blob), 'UTF-8') - var sendblob = { - blob: unboxedreq.blob, - blobFile: blobToSend - } - console.log(sendblob) - bog.box(JSON.stringify(sendblob), req.requester, key).then(boxed => { - var obj = { - requester: key.publicKey, - box: boxed - } - ws.send(JSON.stringify(obj)) - }) - } - } else { - console.log(req.requester + ' has ' + unboxedreq.blob + ' do we need it?') - if (!blobExists) { - console.log('We need it, so request it from the client') - var blobreq = { blob: unboxedreq.blob, needs: true } - bog.box(JSON.stringify(blobreq), req.requester, key).then(boxed => { - var obj = { - requester: key.publicKey, - box: boxed - } - ws.send(JSON.stringify(obj)) - }) - } - } - }*/ - if (unboxedreq.seq === 0) { - console.log(req.requester + ' asked the full log of ' + unboxedreq.author) - fs.readFile(bogdir + unboxedreq.author, 'UTF-8', function (err, data) { - if (data) { - //var feed = JSON.stringify(data) - var feed = data - bog.box(feed, req.requester, key).then(boxed => { - var obj = { - requester: key.publicKey, - box: boxed - } - ws.send(JSON.stringify(obj)) - console.log('Sent full log of ' + unboxedreq.author + ' to ' + req.requester) - }) - } - }) - } if (unboxedreq.seq) { console.log(req.requester + ' asked for feed ' + unboxedreq.author + ' after sequence ' + unboxedreq.seq) // check to see if we have the feed on disk |