Commit 86ead1fef00900a6c2c146204116783ab4b69ce9
render all private messages in private tab, attempt to decrypt all private messages with browser key on render
Ev Bogue committed on 2/4/2019, 11:32:19 PMParent: e6815c959880f64278c238552b23f16dba1ca857
Files changed
render.js | changed |
views.js | changed |
render.js | ||
---|---|---|
@@ -10,8 +10,11 @@ | ||
10 | 10 | var id = require('./keys').id |
11 | 11 | var avatar = require('./avatar') |
12 | 12 | var ssbAvatar = require('ssb-avatar') |
13 | 13 | |
14 | +var ssbKeys = require('ssb-keys') | |
15 | +var keys = require('./keys') | |
16 | + | |
14 | 17 | var diff = require('diff') |
15 | 18 | |
16 | 19 | function hash () { |
17 | 20 | return window.location.hash.substring(1) |
@@ -335,11 +338,18 @@ | ||
335 | 338 | var link = h('span', ' ', h('img.emoji', {src: config.emojiUrl + 'stars.png'}), ' ', h('a', {href: '#' + msg.value.content.vote.link}, tools.messageLink(msg.value.content.vote.link))) |
336 | 339 | message.appendChild(tools.mini(msg, link)) |
337 | 340 | return message |
338 | 341 | } else if (typeof msg.value.content === 'string') { |
339 | - var privateMsg = h('span', ' sent a private message.') | |
340 | - message.appendChild(tools.mini(msg, privateMsg)) | |
341 | - return message | |
342 | + var unboxed = ssbKeys.unbox(msg.value.content, keys) | |
343 | + if (unboxed) { | |
344 | + msg.value.content = unboxed | |
345 | + msg.value.private = true | |
346 | + return module.exports(msg) | |
347 | + } else { | |
348 | + var privateMsg = h('span', ' sent a private message.') | |
349 | + message.appendChild(tools.mini(msg, privateMsg)) | |
350 | + return message | |
351 | + } | |
342 | 352 | } else { |
343 | 353 | |
344 | 354 | //FULL FALLBACK |
345 | 355 | message.appendChild(tools.header(msg)) |
views.js | ||
---|---|---|
@@ -36,16 +36,60 @@ | ||
36 | 36 | screen.appendChild(hyperscroll(content)) |
37 | 37 | } |
38 | 38 | |
39 | 39 | var privateStream = function () { |
40 | + var screen = document.getElementById('screen') | |
40 | 41 | var content = h('div.content') |
41 | - var screen = document.getElementById('screen') | |
42 | + | |
42 | 43 | screen.appendChild(hyperscroll(content)) |
43 | 44 | |
44 | 45 | function createStream (opts) { |
45 | 46 | return pull( |
46 | 47 | Next(sbot.query, opts, ['value', 'timestamp']), |
48 | + pull.filter(function (msg) { | |
49 | + return ((msg.value.private == true) || ('string' == typeof msg.value.content)) | |
50 | + }), | |
47 | 51 | pull.map(function (msg) { |
52 | + /*if (msg.value.private != true) { | |
53 | + var unboxed = ssbKeys.unbox(msg.value.content, keys) | |
54 | + if (unboxed) { | |
55 | + msg.value.content = unboxed | |
56 | + msg.value.private = true | |
57 | + return render(msg) | |
58 | + } else { | |
59 | + return render(msg) | |
60 | + } | |
61 | + } else {return render(msg)}*/ | |
62 | + return render(msg) | |
63 | + }) | |
64 | + ) | |
65 | + } | |
66 | + | |
67 | + pull( | |
68 | + createStream({ | |
69 | + limit: 100, | |
70 | + reverse: true, | |
71 | + live: false, | |
72 | + query: [{$filter: { value: { timestamp: { $gt: 0 }}}}] | |
73 | + }), | |
74 | + stream.bottom(content) | |
75 | + ) | |
76 | + | |
77 | + pull( | |
78 | + createStream({ | |
79 | + limit: 100, | |
80 | + old: false, | |
81 | + live: true, | |
82 | + query: [{$filter: { value: { timestamp: { $gt: 0 }}}}] | |
83 | + }), | |
84 | + stream.top(content) | |
85 | + ) | |
86 | + | |
87 | + | |
88 | + /*function createStream (opts) { | |
89 | + return pull( | |
90 | + Next(sbot.query, opts, ['value', 'timestamp']), | |
91 | + pull.map(function (msg) { | |
48 | 92 | if (msg.value) { |
49 | 93 | if (msg.value.timestamp > Date.now()) { |
50 | 94 | return h('div.future') |
51 | 95 | } else { |
@@ -73,9 +117,9 @@ | ||
73 | 117 | live: true, |
74 | 118 | query: [{$filter: { value: { private: true, timestamp: { $gt: 0 }}}}] |
75 | 119 | }), |
76 | 120 | stream.top(content) |
77 | - ) | |
121 | + )*/ | |
78 | 122 | |
79 | 123 | |
80 | 124 | /*function createStream (opts) { |
81 | 125 | return pull( |
@@ -88,8 +132,10 @@ | ||
88 | 132 | if (unboxed) { |
89 | 133 | msg.value.content = unboxed |
90 | 134 | msg.value.private = true |
91 | 135 | return msg |
136 | + } else { | |
137 | + return msg | |
92 | 138 | } |
93 | 139 | }), |
94 | 140 | pull.map(function (msg) { |
95 | 141 | return render(msg) |
@@ -550,11 +596,8 @@ | ||
550 | 596 | query: [{$filter: { value: { timestamp: { $gt: 0 }}}}] |
551 | 597 | }), |
552 | 598 | stream.top(content) |
553 | 599 | ) |
554 | - | |
555 | - | |
556 | - | |
557 | 600 | } |
558 | 601 | |
559 | 602 | |
560 | 603 |
Built with git-ssb-web