git ssb

1+

Dominic / ssb-private-groups



Commit 6c83ee92da37bbfea7f2b10e9bcca736b1447248

hook sbot.box method

Dominic Tarr committed on 3/17/2019, 10:20:33 PM
Parent: e39f1662dc45833d09248b820abe6f694160a37a

Files changed

index.jschanged
index.jsView
@@ -37,8 +37,31 @@
3737 if(ready) fn()
3838 else waiting.push(fn)
3939 }
4040
41 + //no, pass in from id too.
42 + sbot.box.hook(function (fn, args) {
43 + var content = args[0]
44 + var state = args[1]
45 + var recps = content.recps
46 + //check if this is something we can't handle as box2
47 + if(!recps.every(function (id) {
48 + return ref.isFeed(id) ? state[id] : keyState.groupKeys[id]
49 + }))
50 + return fn.apply(this, args) //fallback
51 +
52 + var prev = u.id2Buffer(state.id)
53 +
54 + return group_box(
55 + Buffer.from(JSON.stringify(content), 'base64'),
56 + prev,
57 + recps.map(function (id) {
58 + return id //???
59 + })
60 + )
61 +
62 + }
63 +
4164 //state:
4265 /*
4366 {
4467 <author>: [{
@@ -130,9 +153,8 @@
130153 }
131154 })
132155
133156 return {
134- get: remoteKeys.get,
135157 addGroupKey: function (group, cb) {
136158 console.log(group, u.isUnboxKey(group.unbox))
137159 if(!ref.isMsg(group.id)) return cb(new Error('id must be a message id'))
138160 if(!u.isUnboxKey(group.unbox)) return cb(new Error('id must be a 32 byte base64 value'))
@@ -167,4 +189,6 @@
167189 }
168190 }
169191
170192
193 +
194 +

Built with git-ssb-web