var ssbRef = require('ssb-ref') var mlib = require('ssb-msgs') exports.new = function (project, title, text) { if (!ssbRef.isLink(project)) throw new Error('invalid project id') var msg = { type: 'issue', project: project } if (title) { if (typeof title === 'string') msg.title = title else throw new Error('invalid issue title') } if (text) { if (typeof text === 'string') msg.text = text else throw new Error('invalid issue text') } return msg } exports.edit = function (id, opts) { if (!ssbRef.isMsg(id)) throw new Error('invalid issue id') var msg = { type: 'issue-edit', issue: id } if (opts.open != null) msg.open = opts.open if (opts.title != null) msg.title = opts.title return msg } exports.close = function (id) { return exports.edit(id, {open: false}) } exports.reopen = function (id) { return exports.edit(id, {open: true}) }