git ssb

0+

Kira / %V53yIAO6ZNGv1Lx9tCP…



forked from cel / ssb-issues

Tree: a0483ad8b20f23f98c06be12f3b1829615063fe2

Files: a0483ad8b20f23f98c06be12f3b1829615063fe2 / lib / schemas.js

936 bytesRaw
1var ssbRef = require('ssb-ref')
2var mlib = require('ssb-msgs')
3
4exports.new = function (project, title, text) {
5 if (!ssbRef.isLink(project))
6 throw new Error('invalid project id')
7 var msg = { type: 'issue', project: project }
8 if (title) {
9 if (typeof title === 'string')
10 msg.title = title
11 else
12 throw new Error('invalid issue title')
13 }
14 if (text) {
15 if (typeof text === 'string')
16 msg.text = text
17 else
18 throw new Error('invalid issue text')
19 }
20 return msg
21}
22
23exports.edit = function (id, opts) {
24 if (!ssbRef.isMsg(id))
25 throw new Error('invalid issue id')
26 var msg = {
27 type: 'issue-edit',
28 issue: id
29 }
30 if (opts.open != null)
31 msg.open = opts.open
32 if (opts.title != null)
33 msg.title = opts.title
34 return msg
35}
36
37exports.close = function (id) {
38 return exports.edit(id, {open: false})
39}
40
41exports.reopen = function (id) {
42 return exports.edit(id, {open: true})
43}
44

Built with git-ssb-web