git ssb

0+

Dominic / ssb-peer-invites



Commit c76f58e8d7c5335c6e7c7f0d9b9c697687c91e59

validate types while building model

Dominic Tarr committed on 12/15/2018, 11:22:30 PM
Parent: efc1d2b9aecc8c0e48e3cd406f2c03038046a33c

Files changed

index.jschanged
index.jsView
@@ -4,8 +4,9 @@
44 var deepEquals = require('deep-equals')
55 var crypto = require('crypto')
66 var ssbKeys = require('ssb-keys')
77 var ssbClient = require('ssb-client')
8 +var types = require('./types')
89
910 function code(err, c) {
1011 err.code = 'user-invites:'+c
1112 return err
@@ -51,18 +52,18 @@
5152 function reduce (acc, data, _seq) {
5253 if(!acc) acc = {invited: {}, invites:{}, accepts: {}, hosts: {}}
5354 var msg = data.value
5455 var invite, accept
55- if(msg.content.type === 'user-invite') {
56 + if(types.isInvite(msg)) {
5657 //TODO: validate that this is a msg we understand!
5758 invite = msg
5859 accept = acc.accepts[data.key]
5960 }
60- else if(msg.content.type === 'user-invite/accept') {
61 + else if(types.isAccept(msg)) {
6162 accept = msg
6263 invite = acc.invites[accept.content.receipt]
6364 }
64- else if(msg.content.type === 'user-invite/confirm') {
65 + else if(types.isConfirm(msg)) {
6566 //TODO: just for when we are the guest, but we need to make sure at least one confirm exists.
6667 accept = msg.content.embed
6768 invite = acc.invites[accept.content.receipt]
6869 }

Built with git-ssb-web