Commit 61db966221bf13191537478ad3f67a1e81ddfa81
implement private message decryption
Ev Bogue committed on 9/26/2018, 4:14:25 PMParent: 2536dec31ad49889ae8b471204a9c2a54e23ecd9
Files changed
render.js | changed |
scuttlebot.js | changed |
views.js | changed |
render.js | ||
---|---|---|
@@ -18,9 +18,8 @@ | ||
18 | 18 | |
19 | 19 | module.exports = function (msg) { |
20 | 20 | var message = h('div.message#' + msg.key.substring(0, 44)) |
21 | 21 | |
22 | - | |
23 | 22 | if (!localStorage[msg.value.author]) |
24 | 23 | var cache = {mute: false} |
25 | 24 | else |
26 | 25 | var cache = JSON.parse(localStorage[msg.value.author]) |
@@ -70,9 +69,12 @@ | ||
70 | 69 | message.appendChild(tools.mini(msg, ' ' + msg.value.content.text)) |
71 | 70 | return message |
72 | 71 | } |
73 | 72 | else if (msg.value.content.type == 'contact') { |
74 | - var contact = h('a', {href: '#' + msg.value.content.contact}, avatar.name(msg.value.content.contact)) | |
73 | + if (msg.value.content.contact) { | |
74 | + var contact = h('a', {href: '#' + msg.value.content.contact}, avatar.name(msg.value.content.contact)) | |
75 | + } else { var contact = h('p', 'no contact named')} | |
76 | + | |
75 | 77 | if (msg.value.content.following == true) { |
76 | 78 | var following = h('span', ' follows ', contact) |
77 | 79 | message.appendChild(tools.mini(msg, following)) |
78 | 80 | } |
@@ -87,9 +89,10 @@ | ||
87 | 89 | if (msg.value.content.blocking == false) { |
88 | 90 | var unblocking = h('span', ' unblocks ', contact) |
89 | 91 | message.appendChild(tools.mini(msg, unblocking)) |
90 | 92 | } |
91 | - return message | |
93 | + return message | |
94 | + | |
92 | 95 | } |
93 | 96 | |
94 | 97 | else if (msg.value.content.type == 'git-update') { |
95 | 98 |
scuttlebot.js | ||
---|---|---|
@@ -71,10 +71,10 @@ | ||
71 | 71 | query: rec.source(function (query) { |
72 | 72 | return sbot.query.read(query) |
73 | 73 | }), |
74 | 74 | get: rec.async(function (key, cb) { |
75 | - if('function' !== typeof cb) | |
76 | - throw new Error('cb must be function') | |
75 | + //if('function' !== typeof cb) | |
76 | + //throw new Error('cb must be function') | |
77 | 77 | if(CACHE[key]) cb(null, CACHE[key]) |
78 | 78 | else sbot.get(key, function (err, value) { |
79 | 79 | if(err) return cb(err) |
80 | 80 | cb(null, CACHE[key] = value) |
views.js | ||
---|---|---|
@@ -298,8 +298,29 @@ | ||
298 | 298 | |
299 | 299 | |
300 | 300 | } |
301 | 301 | |
302 | +var privateMsg = function (src) { | |
303 | + var content = h('div.content') | |
304 | + var screen = document.getElementById('screen') | |
305 | + screen.appendChild(hyperscroll(content)) | |
306 | + | |
307 | + sbot.get(src, function (err, data) { | |
308 | + if (err) { | |
309 | + var message = h('div.message', 'Missing message!') | |
310 | + content.appendChild(message) | |
311 | + } | |
312 | + if (data) { | |
313 | + console.log(data) | |
314 | + data.value = data | |
315 | + data.key = src | |
316 | + | |
317 | + content.appendChild(render(data)) | |
318 | + } | |
319 | + | |
320 | + }) | |
321 | +} | |
322 | + | |
302 | 323 | var msgThread = function (src) { |
303 | 324 | |
304 | 325 | var content = h('div.content') |
305 | 326 | var screen = document.getElementById('screen') |
@@ -514,9 +535,14 @@ | ||
514 | 535 | |
515 | 536 | module.exports = function () { |
516 | 537 | var src = hash() |
517 | 538 | console.log(src) |
518 | - if (ref.isFeed(src)) { | |
539 | + | |
540 | + if (src.substring(52, 59) == '?unbox=') { | |
541 | + //var msgId = src.substring(0, 52) | |
542 | + //var unbox = src.substring(59) | |
543 | + privateMsg(src) | |
544 | + } else if (ref.isFeed(src)) { | |
519 | 545 | userStream(src) |
520 | 546 | } else if (ref.isMsg(src)) { |
521 | 547 | msgThread(src) |
522 | 548 | } else if (src == 'mentions') { |
Built with git-ssb-web