diff --git a/ts/textsecure/WebAPI.ts b/ts/textsecure/WebAPI.ts index c4a913f93..2a93aef2c 100644 --- a/ts/textsecure/WebAPI.ts +++ b/ts/textsecure/WebAPI.ts @@ -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): void { + for (const message of messages) { + strictAssert(message !== null, 'Attempting to send `null` message'); + } + } + async function sendMessagesUnauth( destination: string, messageArray: Array, @@ -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',