Commit 30e265bd0b3178ded7a1519cc74f8c532f06ecf1
Set mentions on issue and issue comment messages
Close %u+NEFC3ETRtRWCNQM2AK6MjNVTo+OA4AgHJoTF1MaC0=.sha256Charles Lehner committed on 3/30/2016, 2:29:18 AM
Parent: e74b81378ce5a4bf1fa65fc010edd987f4ff79e6
Files changed
index.js | changed |
package.json | changed |
index.js | ||
---|---|---|
@@ -17,8 +17,9 @@ | ||
17 | 17 | var schemas = require('ssb-msg-schemas') |
18 | 18 | var Issues = require('ssb-issues') |
19 | 19 | var paramap = require('pull-paramap') |
20 | 20 | var gitPack = require('pull-git-pack') |
21 | +var Mentions = require('ssb-mentions') | |
21 | 22 | |
22 | 23 | // render links to git objects and ssb objects |
23 | 24 | var blockRenderer = new marked.Renderer() |
24 | 25 | blockRenderer.urltransform = function (url) { |
@@ -455,27 +456,29 @@ | ||
455 | 456 | case 'comment': |
456 | 457 | if (!data.id) |
457 | 458 | return cb(null, serveError(new Error('Missing id'), 400)) |
458 | 459 | |
459 | - // TODO: add ref mentions | |
460 | 460 | var msg = schemas.post(data.text, data.id, data.branch || data.id) |
461 | 461 | if (data.open != null) |
462 | 462 | Issues.schemas.opens(msg, data.id) |
463 | 463 | if (data.close != null) |
464 | 464 | Issues.schemas.closes(msg, data.id) |
465 | + var mentions = Mentions(data.text) | |
466 | + if (mentions.length) | |
467 | + msg.mentions = mentions | |
465 | 468 | return ssb.publish(msg, function (err) { |
466 | 469 | if (err) return cb(null, serveError(err)) |
467 | 470 | cb(null, serveRedirect(req.url)) |
468 | 471 | }) |
469 | 472 | |
470 | 473 | 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) { | |
476 | 479 | if (err) return cb(null, serveError(err)) |
477 | - cb(null, serveRedirect(encodeLink(issue.id))) | |
480 | + cb(null, serveRedirect(encodeLink(msg.key))) | |
478 | 481 | }) |
479 | 482 | |
480 | 483 | case 'markdown': |
481 | 484 | return cb(null, serveMarkdown(data.text, {id: data.repo})) |
Built with git-ssb-web