git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: cabc473e5efae9784e813e91373c35c0b8c5635f

Files: cabc473e5efae9784e813e91373c35c0b8c5635f / modules / page / html / render / private.js

925 bytesRaw
1var nest = require('depnest')
2var ref = require('ssb-ref')
3
4exports.needs = nest({
5 'feed.html.rollup': 'first',
6 'feed.pull.private': 'first',
7 'message.html.compose': 'first',
8 'keys.sync.id': 'first',
9 'intl.sync.i18n': 'first',
10})
11
12exports.gives = nest('page.html.render')
13
14exports.create = function (api) {
15 const i18n = api.intl.sync.i18n
16 return nest('page.html.render', function channel (path) {
17 if (path !== '/private') return
18
19 var id = api.keys.sync.id()
20 var prepend = [
21 api.message.html.compose({
22 meta: {type: 'post'},
23 prepublish: function (msg) {
24 msg.recps = [id].concat(msg.mentions).filter(function (e) {
25 return ref.isFeed(typeof e === 'string' ? e : e.link)
26 })
27 return msg
28 },
29 placeholder: i18n('Write a private message')
30 })
31 ]
32
33 return api.feed.html.rollup(api.feed.pull.private, { prepend })
34 })
35}
36

Built with git-ssb-web