git ssb

7+

dinoworm 🐛 / patchcore



Commit 302cd5ef2e91d726742057adbd1508b6281aa4f2

add message.sync.root

Matt McKegg committed on 6/20/2017, 4:08:53 PM
Parent: 3e28c72ecb926bf17caaaf4e0034198e847faab7

Files changed

message/sync/root.jsadded
message/sync/root.jsView
@@ -1,0 +1,21 @@
1 +var ref = require('ssb-ref')
2 +var nest = require('depnest')
3 +
4 +exports.gives = nest('message.sync.root', true)
5 +
6 +exports.create = function (api) {
7 + return nest('message.sync.root', function (msg) {
8 + if (msg && msg.value && msg.value.content) {
9 + var type = msg.value.content.type
10 + var root = msg.value.content.root
11 +
12 + if (type === 'vote') {
13 + root = msg.value.content.vote && msg.value.content.vote.link
14 + } else if (type === 'about') {
15 + root = msg.value.content.about
16 + }
17 +
18 + if (ref.isMsg(root)) return root
19 + }
20 + })
21 +}

Built with git-ssb-web