fine grained validation
This commit is contained in:
parent
11fd373301
commit
d898506a28
1 changed files with 18 additions and 2 deletions
|
|
@ -150,13 +150,29 @@ const onIncoming = cb => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Schema.isOutgoing(data)) {
|
if (typeof data !== 'object') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof data.with !== 'string') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof data.messages !== 'object') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.messages === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const msgs = /** @type {[string, Schema.Message][]} */ (Object.entries(
|
||||||
|
data.messages
|
||||||
|
).filter(([_, msg]) => Schema.isMessage(msg)))
|
||||||
|
|
||||||
// eslint-disable-next-line require-atomic-updates
|
// eslint-disable-next-line require-atomic-updates
|
||||||
pubToIncoming[pub] = await Utils.asyncMap(
|
pubToIncoming[pub] = await Utils.asyncMap(
|
||||||
Object.entries(data.messages),
|
msgs,
|
||||||
async ([msgid, msg]) => {
|
async ([msgid, msg]) => {
|
||||||
let decryptedBody = ''
|
let decryptedBody = ''
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue