diff options
author | Ev Bogue <ev@evbogue.com> | 2020-01-03 15:57:10 -0600 |
---|---|---|
committer | Ev Bogue <ev@evbogue.com> | 2020-01-03 15:57:10 -0600 |
commit | 508e4c53a93cfa443dd590dd52f8fc22471d9e7c (patch) | |
tree | 3a4bf1018aae26ec7a98731c39a72ab35afab9f1 /server.js | |
parent | 8da504b074b76d0a811f388181d55b0ed3ce3294 (diff) |
rip out beacons
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 80 |
1 files changed, 0 insertions, 80 deletions
@@ -3,7 +3,6 @@ var homedir = require('os').homedir() var path = homedir + '/.bogbook/' var bogdir = path + 'bogs/' -var addir = path + 'ads/' var confpath = path + 'config.json' if (!fs.existsSync(homedir + '/.bogbook/')) {fs.mkdirSync(homedir + '/.bogbook/')} @@ -120,33 +119,6 @@ bog.keys().then(key => { bog.unbox(req.box, req.requester, key).then(unboxed => { var unboxedreq = JSON.parse(unboxed) //console.log(unboxedreq) - if (unboxedreq.type == 'beacon') { - if (unboxedreq.box) { - var hex = Buffer.from(nacl.hash(nacl.util.decodeUTF8(unboxedreq.box))).toString('hex') - - var obj = { - hash: hex, - author: unboxedreq.author, - box: unboxedreq.box, - views: 0 - } - } - - if (unboxedreq.signature) { - var hex = Buffer.from(nacl.hash(nacl.util.decodeUTF8(unboxedreq.signature))).toString('hex') - var obj = { - hash: hex, - author: unboxedreq.author, - signature: unboxedreq.signature, - views: 0 - } - } - - fs.writeFile(addir + hex, JSON.stringify(obj), 'UTF-8', function () { - console.log('Saved as ' + hex) - }) - ws.close() - } if (unboxedreq.seq >= 0) { printAsk(req, unboxedreq) fs.readFile(bogdir + unboxedreq.author, 'UTF-8', function (err, data) { @@ -155,58 +127,6 @@ bog.keys().then(key => { bog.open(feed[0]).then(msg => { if (unboxedreq.seq === msg.seq) { printFeedIdentical(msg, req) - if (config.ads) { - if (Math.floor(Math.random() * 6) == 2) { - fs.readdir(addir, function (err, adfiles) { - if (adfiles) { - var num = Math.floor(Math.random() * (adfiles.length)) - fs.readFile(addir + adfiles[num], 'UTF-8', function (err, adFile) { - var obj = JSON.parse(adFile) - - if (obj.signature) { - var ad = { - author: obj.author, - hash: obj.hash, - name: config.fullurl, - pub: 'ws://' + config.url + ':' + config.wsport + '/~' + key.publicKey, - signature: obj.signature, - views: obj.views - } - } - - if (obj.box) { - var ad = { - author: obj.author, - hash: obj.hash, - name: config.fullurl, - pub: 'ws://' + config.url + ':' + config.wsport + '/~' + key.publicKey, - box: obj.box, - views: obj.views - } - } - - if ((obj.views > 100) && (obj.author != config.author)) { - fs.unlinkSync(addir + obj.hash) - //console.log('REMOVING AD') - } else { - obj.views++ - fs.writeFileSync(addir + obj.hash, JSON.stringify(obj), 'UTF-8') - } - printSendAd(ad, req) - //console.log('SENDING AD') - bog.box(JSON.stringify(ad), req.requester, key).then(boxed => { - sendobj = { - requester: key.publicKey, - box: boxed - } - ws.send(JSON.stringify(sendobj)) - ws.close() - }) - }) - } - }) - } - } } if (unboxedreq.seq > msg.seq) { printClientLonger(msg, req) |