Commit 06f2cf64aba94839fa02b58ea578954fba561c5d
use ssb-ref to check ids for "about" and "contact" obs
Matt McKegg committed on 3/17/2017, 3:02:20 AMParent: cbcb461f9a6f0ce3cee6926edccae1ffa8bf3e32
Files changed
about/obs.js | changed |
contact/obs.js | changed |
about/obs.js | ||
---|---|---|
@@ -2,8 +2,9 @@ | ||
2 | 2 … | var pullPause = require('pull-pause') |
3 | 3 … | var pull = require('pull-stream') |
4 | 4 … | var msgs = require('ssb-msgs') |
5 | 5 … | var nest = require('depnest') |
6 … | +var ref = require('ssb-ref') | |
6 | 7 … | var colorHash = new (require('color-hash'))() |
7 | 8 … | |
8 | 9 … | exports.needs = nest({ |
9 | 10 … | 'sbot.pull.query': 'first', |
@@ -103,9 +104,9 @@ | ||
103 | 104 … | } |
104 | 105 … | } |
105 | 106 … | |
106 | 107 … | function About (api, id, sync) { |
107 | - if (!id) throw new Error('About requires an id!') | |
108 … | + if (!ref.isLink(id)) throw new Error('About requires an id!') | |
108 | 109 … | |
109 | 110 … | var pauser = pullPause((paused) => {}) |
110 | 111 … | |
111 | 112 … | // transparent image |
contact/obs.js | ||
---|---|---|
@@ -1,6 +1,7 @@ | ||
1 | 1 … | var nest = require('depnest') |
2 | 2 … | var MutantPullReduce = require('mutant-pull-reduce') |
3 … | +var ref = require('ssb-ref') | |
3 | 4 … | |
4 | 5 … | exports.needs = nest({ |
5 | 6 … | 'sbot.pull.query': 'first', |
6 | 7 … | 'keys.sync.id': 'first' |
@@ -67,13 +68,14 @@ | ||
67 | 68 … | |
68 | 69 … | function reduce (stream) { |
69 | 70 … | var newestValues = {} |
70 | 71 … | return MutantPullReduce(stream, (result, item) => { |
72 … | + if (!ref.isFeed(item.id)) return | |
71 | 73 … | newestValues[item.id] = newestValues[item.id] || 0 |
72 | 74 … | if (newestValues[item.id] < item.timestamp) { |
73 | 75 … | newestValues[item.id] = item.timestamp |
74 | 76 … | if (item.value != null) { |
75 | - if (item.value && item.id) { | |
77 … | + if (item.value) { | |
76 | 78 … | result.add(item.id) |
77 | 79 … | } else { |
78 | 80 … | result.delete(item.id) |
79 | 81 … | } |
Built with git-ssb-web