Commit f87cf52b80cde6f8bec32cfd25ce0f2fce489fcb
Show edits to user's issues in notifications
Charles Lehner committed on 8/3/2016, 10:54:28 PMParent: 70e41235e3a95b27386e99fd841687b2b5588964
Files changed
modules/notifications.js | changed |
modules/notifications.js | ||
---|---|---|
@@ -28,8 +28,10 @@ | ||
28 | 28 | return link && link.link in ourIds |
29 | 29 | } |
30 | 30 | |
31 | 31 | function isOurMsg(id, cb) { |
32 | + if (!id) return cb(null, false) | |
33 | + if (typeof id === 'object' && typeof id.link === 'string') id = id.link | |
32 | 34 | sbot_get(id, function (err, msg) { |
33 | 35 | if (err && err.name == 'NotFoundError') cb(null, false) |
34 | 36 | else if (err) cb(err) |
35 | 37 | else if (msg.content.type === 'issue' || msg.content.type === 'project') |
@@ -37,8 +39,19 @@ | ||
37 | 39 | else cb(err, msg.author in ourIds) |
38 | 40 | }) |
39 | 41 | } |
40 | 42 | |
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 | + | |
41 | 54 | return paramap(function (msg, cb) { |
42 | 55 | var c = msg.value && msg.value.content |
43 | 56 | if (!c || typeof c !== 'object') return cb() |
44 | 57 | if (msg.value.author in ourIds) return cb() |
@@ -51,16 +64,9 @@ | ||
51 | 64 | |
52 | 65 | switch (c.type) { |
53 | 66 | case 'post': |
54 | 67 | 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) | |
63 | 69 | else return cb() |
64 | 70 | |
65 | 71 | case 'contact': |
66 | 72 | return cb(null, c.contact in ourIds ? msg : null) |
@@ -77,8 +83,11 @@ | ||
77 | 83 | return isOurMsg(c.project || c.repo, function (err, isOurs) { |
78 | 84 | cb(err, isOurs ? msg : null) |
79 | 85 | }) |
80 | 86 | |
87 | + case 'issue-edit': | |
88 | + return isAnyOurMessage(msg, [c.issue].concat(c.issues), cb) | |
89 | + | |
81 | 90 | default: |
82 | 91 | cb() |
83 | 92 | } |
84 | 93 | }, 4) |
Built with git-ssb-web