Add assert to messages endpoint
This commit is contained in:
@@ -29,7 +29,7 @@ import { v4 as getGuid } from 'uuid';
|
||||
import { z } from 'zod';
|
||||
import Long from 'long';
|
||||
|
||||
import { assert } from '../util/assert';
|
||||
import { assert, strictAssert } from '../util/assert';
|
||||
import { getUserAgent } from '../util/getUserAgent';
|
||||
import { toWebSafeBase64 } from '../util/webSafeBase64';
|
||||
import { SocketStatus } from '../types/SocketStatus';
|
||||
@@ -1707,6 +1707,12 @@ export function initialize({
|
||||
}).then(handleKeys);
|
||||
}
|
||||
|
||||
function validateMessages(messages: Array<unknown>): void {
|
||||
for (const message of messages) {
|
||||
strictAssert(message !== null, 'Attempting to send `null` message');
|
||||
}
|
||||
}
|
||||
|
||||
async function sendMessagesUnauth(
|
||||
destination: string,
|
||||
messageArray: Array<MessageType>,
|
||||
@@ -1720,6 +1726,8 @@ export function initialize({
|
||||
jsonData.online = true;
|
||||
}
|
||||
|
||||
validateMessages(messageArray);
|
||||
|
||||
return _ajax({
|
||||
call: 'messages',
|
||||
httpType: 'PUT',
|
||||
@@ -1743,6 +1751,8 @@ export function initialize({
|
||||
jsonData.online = true;
|
||||
}
|
||||
|
||||
validateMessages(messageArray);
|
||||
|
||||
return _ajax({
|
||||
call: 'messages',
|
||||
httpType: 'PUT',
|
||||
|
Reference in New Issue
Block a user