git ssb

7+

dinoworm 🐛 / patchcore



Commit 06f2cf64aba94839fa02b58ea578954fba561c5d

use ssb-ref to check ids for "about" and "contact" obs

Matt McKegg committed on 3/17/2017, 3:02:20 AM
Parent: cbcb461f9a6f0ce3cee6926edccae1ffa8bf3e32

Files changed

about/obs.jschanged
contact/obs.jschanged
about/obs.jsView
@@ -2,8 +2,9 @@
22 var pullPause = require('pull-pause')
33 var pull = require('pull-stream')
44 var msgs = require('ssb-msgs')
55 var nest = require('depnest')
6 +var ref = require('ssb-ref')
67 var colorHash = new (require('color-hash'))()
78
89 exports.needs = nest({
910 'sbot.pull.query': 'first',
@@ -103,9 +104,9 @@
103104 }
104105 }
105106
106107 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!')
108109
109110 var pauser = pullPause((paused) => {})
110111
111112 // transparent image
contact/obs.jsView
@@ -1,6 +1,7 @@
11 var nest = require('depnest')
22 var MutantPullReduce = require('mutant-pull-reduce')
3 +var ref = require('ssb-ref')
34
45 exports.needs = nest({
56 'sbot.pull.query': 'first',
67 'keys.sync.id': 'first'
@@ -67,13 +68,14 @@
6768
6869 function reduce (stream) {
6970 var newestValues = {}
7071 return MutantPullReduce(stream, (result, item) => {
72 + if (!ref.isFeed(item.id)) return
7173 newestValues[item.id] = newestValues[item.id] || 0
7274 if (newestValues[item.id] < item.timestamp) {
7375 newestValues[item.id] = item.timestamp
7476 if (item.value != null) {
75- if (item.value && item.id) {
77 + if (item.value) {
7678 result.add(item.id)
7779 } else {
7880 result.delete(item.id)
7981 }

Built with git-ssb-web