git ssb

30+

cel / git-ssb-web



Commit d4cca13f95088bd91dadba50a4709570eb3a6f9f

Decrypt private messages in PR/Issue activity view

Fix %2dGuCh4GmrBZlL5JvzwNEX6B79K2CbMy3I0bwEN2u+A=.sha256
cel committed on 10/23/2016, 12:54:17 AM
Parent: c5a3938d98acd7e766a37898d88fb471be5f1de2

Files changed

lib/repos/issues.jschanged
lib/repos/pulls.jschanged
lib/util.jschanged
lib/repos/issues.jsView
@@ -125,8 +125,9 @@
125125 dest: issue.id,
126126 values: true
127127 }),
128128 pull.unique('key'),
129 + u.decryptMessages(self.web.ssb),
129130 self.web.addAuthorName(),
130131 u.sortMsgs(),
131132 pull.through(function (msg) {
132133 // the newest message in the issue thread
lib/repos/pulls.jsView
@@ -160,10 +160,11 @@
160160 && ('refs/heads/' + pr.headBranch) in link.value.content.refs
161161 })
162162 )
163163 ]),
164 + pull.unique('key'),
165 + u.decryptMessages(self.web.ssb),
164166 self.web.addAuthorName(),
165- pull.unique('key'),
166167 pull.through(function (msg) {
167168 if (msg.value
168169 && msg.value.timestamp > newestMsg.value.timestamp
169170 && msg.value.content.root === pr.id)
lib/util.jsView
@@ -1,5 +1,7 @@
11 var pull = require('pull-stream')
2 +var catMap = require('pull-cat-map')
3 +var paramap = require('pull-paramap')
24 var Highlight = require('highlight.js')
35 var u = exports
46
57 u.imgMimes = {
@@ -165,4 +167,29 @@
165167 if (!ifModSince) return false
166168 var d = new Date(ifModSince)
167169 return d && Math.floor(d/1000) >= Math.floor(lastMod/1000)
168170 }
171 +
172 +u.decryptMessages = function (sbot) {
173 + return paramap(function (msg, cb) {
174 + var c = msg && msg.value && msg.value.content
175 + if (c && typeof c === 'string' && c.slice(-4) === '.box') {
176 + sbot.private.unbox(msg.value.content, function (err, content) {
177 + if (err) return cb(null, msg) // leave message encrypted
178 + var msg1 = {}
179 + for (var k in msg) msg1[k] = msg[k]
180 + msg1.value = {}
181 + for (var j in msg.value) msg1.value[j] = msg.value[j]
182 + msg1.value.private = true
183 + msg1.value.content = content
184 + if (!content.recps) {
185 + sbot.whoami(function (err, feed) {
186 + if (err) return cb(err)
187 + content.recps = [msg1.value.author]
188 + if (feed.id !== msg1.value.author) content.recps.push(feed.id)
189 + cb(null, msg1)
190 + })
191 + } else cb(null, msg1)
192 + })
193 + } else cb(null, msg)
194 + }, 4)
195 +}

Built with git-ssb-web