signal-desktop/ts/shims/textsecure.ts

44 lines
935 B
TypeScript
Raw Normal View History

2021-04-08 16:24:21 +00:00
// Copyright 2019-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2021-04-08 16:24:21 +00:00
export async function sendStickerPackSync(
packId: string,
packKey: string,
installed: boolean
2021-04-08 16:24:21 +00:00
): Promise<void> {
const { ConversationController, textsecure, log } = window;
const ourNumber = textsecure.storage.user.getNumber();
2021-04-08 16:24:21 +00:00
const { wrap, sendOptions } = await ConversationController.prepareForSend(
ourNumber,
2021-04-08 16:24:21 +00:00
{
syncMessage: true,
}
);
if (!textsecure.messaging) {
log.error(
'shim: Cannot call sendStickerPackSync, textsecure.messaging is falsey'
);
return;
}
wrap(
textsecure.messaging.sendStickerPackSync(
[
{
packId,
packKey,
installed,
},
],
sendOptions
)
).catch(error => {
log.error(
'shim: Error calling sendStickerPackSync:',
error && error.stack ? error.stack : error
);
});
}