git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

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 PM
Parent: e6815c959880f64278c238552b23f16dba1ca857

Files changed

render.jschanged
views.jschanged
render.jsView
@@ -10,8 +10,11 @@
1010 var id = require('./keys').id
1111 var avatar = require('./avatar')
1212 var ssbAvatar = require('ssb-avatar')
1313
14+var ssbKeys = require('ssb-keys')
15+var keys = require('./keys')
16+
1417 var diff = require('diff')
1518
1619 function hash () {
1720 return window.location.hash.substring(1)
@@ -335,11 +338,18 @@
335338 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)))
336339 message.appendChild(tools.mini(msg, link))
337340 return message
338341 } 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+ }
342352 } else {
343353
344354 //FULL FALLBACK
345355 message.appendChild(tools.header(msg))
views.jsView
@@ -36,16 +36,60 @@
3636 screen.appendChild(hyperscroll(content))
3737 }
3838
3939 var privateStream = function () {
40+ var screen = document.getElementById('screen')
4041 var content = h('div.content')
41- var screen = document.getElementById('screen')
42+
4243 screen.appendChild(hyperscroll(content))
4344
4445 function createStream (opts) {
4546 return pull(
4647 Next(sbot.query, opts, ['value', 'timestamp']),
48+ pull.filter(function (msg) {
49+ return ((msg.value.private == true) || ('string' == typeof msg.value.content))
50+ }),
4751 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) {
4892 if (msg.value) {
4993 if (msg.value.timestamp > Date.now()) {
5094 return h('div.future')
5195 } else {
@@ -73,9 +117,9 @@
73117 live: true,
74118 query: [{$filter: { value: { private: true, timestamp: { $gt: 0 }}}}]
75119 }),
76120 stream.top(content)
77- )
121+ )*/
78122
79123
80124 /*function createStream (opts) {
81125 return pull(
@@ -88,8 +132,10 @@
88132 if (unboxed) {
89133 msg.value.content = unboxed
90134 msg.value.private = true
91135 return msg
136+ } else {
137+ return msg
92138 }
93139 }),
94140 pull.map(function (msg) {
95141 return render(msg)
@@ -550,11 +596,8 @@
550596 query: [{$filter: { value: { timestamp: { $gt: 0 }}}}]
551597 }),
552598 stream.top(content)
553599 )
554-
555-
556-
557600 }
558601
559602
560603

Built with git-ssb-web