git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit f87cf52b80cde6f8bec32cfd25ce0f2fce489fcb

Show edits to user's issues in notifications

Charles Lehner committed on 8/3/2016, 10:54:28 PM
Parent: 70e41235e3a95b27386e99fd841687b2b5588964

Files changed

modules/notifications.jschanged
modules/notifications.jsView
@@ -28,8 +28,10 @@
2828 return link && link.link in ourIds
2929 }
3030
3131 function isOurMsg(id, cb) {
32+ if (!id) return cb(null, false)
33+ if (typeof id === 'object' && typeof id.link === 'string') id = id.link
3234 sbot_get(id, function (err, msg) {
3335 if (err && err.name == 'NotFoundError') cb(null, false)
3436 else if (err) cb(err)
3537 else if (msg.content.type === 'issue' || msg.content.type === 'project')
@@ -37,8 +39,19 @@
3739 else cb(err, msg.author in ourIds)
3840 })
3941 }
4042
43+ function isAnyOurMessage(msg, ids, cb) {
44+ cont.para(ids.map(function (id) {
45+ return function (cb) { isOurMsg(id, cb) }
46+ }))
47+ (function (err, results) {
48+ if (err) cb(err)
49+ else if (results.some(Boolean)) cb(null, msg)
50+ else cb()
51+ })
52+ }
53+
4154 return paramap(function (msg, cb) {
4255 var c = msg.value && msg.value.content
4356 if (!c || typeof c !== 'object') return cb()
4457 if (msg.value.author in ourIds) return cb()
@@ -51,16 +64,9 @@
5164
5265 switch (c.type) {
5366 case 'post':
5467 if (c.branch || c.root)
55- cont.para([].concat(c.branch, c.root).map(function (id) {
56- return function (cb) { isOurMsg(id, cb) }
57- }))
58- (function (err, results) {
59- if (err) cb(err)
60- else if (results.some(Boolean)) cb(null, msg)
61- else cb()
62- })
68+ return isAnyOurMessage(msg, [].concat(c.branch, c.root), cb)
6369 else return cb()
6470
6571 case 'contact':
6672 return cb(null, c.contact in ourIds ? msg : null)
@@ -77,8 +83,11 @@
7783 return isOurMsg(c.project || c.repo, function (err, isOurs) {
7884 cb(err, isOurs ? msg : null)
7985 })
8086
87+ case 'issue-edit':
88+ return isAnyOurMessage(msg, [c.issue].concat(c.issues), cb)
89+
8190 default:
8291 cb()
8392 }
8493 }, 4)

Built with git-ssb-web