git ssb

30+

cel / git-ssb-web



Commit 30e265bd0b3178ded7a1519cc74f8c532f06ecf1

Set mentions on issue and issue comment messages

Close %u+NEFC3ETRtRWCNQM2AK6MjNVTo+OA4AgHJoTF1MaC0=.sha256
Charles Lehner committed on 3/30/2016, 2:29:18 AM
Parent: e74b81378ce5a4bf1fa65fc010edd987f4ff79e6

Files changed

index.jschanged
package.jsonchanged
index.jsView
@@ -17,8 +17,9 @@
1717 var schemas = require('ssb-msg-schemas')
1818 var Issues = require('ssb-issues')
1919 var paramap = require('pull-paramap')
2020 var gitPack = require('pull-git-pack')
21+var Mentions = require('ssb-mentions')
2122
2223 // render links to git objects and ssb objects
2324 var blockRenderer = new marked.Renderer()
2425 blockRenderer.urltransform = function (url) {
@@ -455,27 +456,29 @@
455456 case 'comment':
456457 if (!data.id)
457458 return cb(null, serveError(new Error('Missing id'), 400))
458459
459- // TODO: add ref mentions
460460 var msg = schemas.post(data.text, data.id, data.branch || data.id)
461461 if (data.open != null)
462462 Issues.schemas.opens(msg, data.id)
463463 if (data.close != null)
464464 Issues.schemas.closes(msg, data.id)
465+ var mentions = Mentions(data.text)
466+ if (mentions.length)
467+ msg.mentions = mentions
465468 return ssb.publish(msg, function (err) {
466469 if (err) return cb(null, serveError(err))
467470 cb(null, serveRedirect(req.url))
468471 })
469472
470473 case 'new-issue':
471- return issues.new({
472- project: dir,
473- title: data.title,
474- text: data.text
475- }, function (err, issue) {
474+ var msg = Issues.schemas.new(dir, data.title, data.text)
475+ var mentions = Mentions(data.text)
476+ if (mentions.length)
477+ msg.mentions = mentions
478+ return ssb.publish(msg, function (err, msg) {
476479 if (err) return cb(null, serveError(err))
477- cb(null, serveRedirect(encodeLink(issue.id)))
480+ cb(null, serveRedirect(encodeLink(msg.key)))
478481 })
479482
480483 case 'markdown':
481484 return cb(null, serveMarkdown(data.text, {id: data.repo}))
package.jsonView
@@ -15,8 +15,9 @@
1515 "ssb-config": "^1.1.0",
1616 "ssb-git-repo": "^1.4.0",
1717 "ssb-keys": "^5.0.0",
1818 "ssb-marked": "^0.5.4",
19+ "ssb-mentions": "^0.0.1",
1920 "ssb-msg-schemas": "^6.1.0",
2021 "ssb-ref": "^2.2.2",
2122 "ssb-reconnect": "^0.1.0",
2223 "ssb-issues": "^0.0.5",

Built with git-ssb-web