Add assert to messages endpoint
This commit is contained in:
parent
4a402126b4
commit
0acefaa656
1 changed files with 11 additions and 1 deletions
|
@ -29,7 +29,7 @@ import { v4 as getGuid } from 'uuid';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import Long from 'long';
|
import Long from 'long';
|
||||||
|
|
||||||
import { assert } from '../util/assert';
|
import { assert, strictAssert } from '../util/assert';
|
||||||
import { getUserAgent } from '../util/getUserAgent';
|
import { getUserAgent } from '../util/getUserAgent';
|
||||||
import { toWebSafeBase64 } from '../util/webSafeBase64';
|
import { toWebSafeBase64 } from '../util/webSafeBase64';
|
||||||
import { SocketStatus } from '../types/SocketStatus';
|
import { SocketStatus } from '../types/SocketStatus';
|
||||||
|
@ -1707,6 +1707,12 @@ export function initialize({
|
||||||
}).then(handleKeys);
|
}).then(handleKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validateMessages(messages: Array<unknown>): void {
|
||||||
|
for (const message of messages) {
|
||||||
|
strictAssert(message !== null, 'Attempting to send `null` message');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function sendMessagesUnauth(
|
async function sendMessagesUnauth(
|
||||||
destination: string,
|
destination: string,
|
||||||
messageArray: Array<MessageType>,
|
messageArray: Array<MessageType>,
|
||||||
|
@ -1720,6 +1726,8 @@ export function initialize({
|
||||||
jsonData.online = true;
|
jsonData.online = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateMessages(messageArray);
|
||||||
|
|
||||||
return _ajax({
|
return _ajax({
|
||||||
call: 'messages',
|
call: 'messages',
|
||||||
httpType: 'PUT',
|
httpType: 'PUT',
|
||||||
|
@ -1743,6 +1751,8 @@ export function initialize({
|
||||||
jsonData.online = true;
|
jsonData.online = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateMessages(messageArray);
|
||||||
|
|
||||||
return _ajax({
|
return _ajax({
|
||||||
call: 'messages',
|
call: 'messages',
|
||||||
httpType: 'PUT',
|
httpType: 'PUT',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue