git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit 61db966221bf13191537478ad3f67a1e81ddfa81

implement private message decryption

Ev Bogue committed on 9/26/2018, 4:14:25 PM
Parent: 2536dec31ad49889ae8b471204a9c2a54e23ecd9

Files changed

render.jschanged
scuttlebot.jschanged
views.jschanged
render.jsView
@@ -18,9 +18,8 @@
1818
1919 module.exports = function (msg) {
2020 var message = h('div.message#' + msg.key.substring(0, 44))
2121
22-
2322 if (!localStorage[msg.value.author])
2423 var cache = {mute: false}
2524 else
2625 var cache = JSON.parse(localStorage[msg.value.author])
@@ -70,9 +69,12 @@
7069 message.appendChild(tools.mini(msg, ' ' + msg.value.content.text))
7170 return message
7271 }
7372 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+
7577 if (msg.value.content.following == true) {
7678 var following = h('span', ' follows ', contact)
7779 message.appendChild(tools.mini(msg, following))
7880 }
@@ -87,9 +89,10 @@
8789 if (msg.value.content.blocking == false) {
8890 var unblocking = h('span', ' unblocks ', contact)
8991 message.appendChild(tools.mini(msg, unblocking))
9092 }
91- return message
93+ return message
94+
9295 }
9396
9497 else if (msg.value.content.type == 'git-update') {
9598
scuttlebot.jsView
@@ -71,10 +71,10 @@
7171 query: rec.source(function (query) {
7272 return sbot.query.read(query)
7373 }),
7474 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')
7777 if(CACHE[key]) cb(null, CACHE[key])
7878 else sbot.get(key, function (err, value) {
7979 if(err) return cb(err)
8080 cb(null, CACHE[key] = value)
views.jsView
@@ -298,8 +298,29 @@
298298
299299
300300 }
301301
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+
302323 var msgThread = function (src) {
303324
304325 var content = h('div.content')
305326 var screen = document.getElementById('screen')
@@ -514,9 +535,14 @@
514535
515536 module.exports = function () {
516537 var src = hash()
517538 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)) {
519545 userStream(src)
520546 } else if (ref.isMsg(src)) {
521547 msgThread(src)
522548 } else if (src == 'mentions') {

Built with git-ssb-web