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-07-15 23:48:09 +00:00
|
|
|
import { handleMessageSend } from '../util/handleMessageSend';
|
|
|
|
import { getSendOptions } from '../util/getSendOptions';
|
|
|
|
|
2021-04-08 16:24:21 +00:00
|
|
|
export async function sendStickerPackSync(
|
2019-05-16 22:32:11 +00:00
|
|
|
packId: string,
|
|
|
|
packKey: string,
|
|
|
|
installed: boolean
|
2021-04-08 16:24:21 +00:00
|
|
|
): Promise<void> {
|
2020-03-31 20:03:38 +00:00
|
|
|
const { ConversationController, textsecure, log } = window;
|
2021-07-15 23:48:09 +00:00
|
|
|
const ourConversation = ConversationController.getOurConversationOrThrow();
|
|
|
|
const sendOptions = await getSendOptions(ourConversation.attributes, {
|
|
|
|
syncMessage: true,
|
|
|
|
});
|
2019-05-16 22:32:11 +00:00
|
|
|
|
|
|
|
if (!textsecure.messaging) {
|
|
|
|
log.error(
|
|
|
|
'shim: Cannot call sendStickerPackSync, textsecure.messaging is falsey'
|
|
|
|
);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-15 23:48:09 +00:00
|
|
|
if (window.ConversationController.areWePrimaryDevice()) {
|
|
|
|
window.log.warn(
|
|
|
|
'shims/sendStickerPackSync: We are primary device; not sending sync'
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
handleMessageSend(
|
2019-05-16 22:32:11 +00:00
|
|
|
textsecure.messaging.sendStickerPackSync(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
packId,
|
|
|
|
packKey,
|
|
|
|
installed,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
sendOptions
|
2021-07-15 23:48:09 +00:00
|
|
|
),
|
|
|
|
{ messageIds: [], sendType: 'otherSync' }
|
2019-05-16 22:32:11 +00:00
|
|
|
).catch(error => {
|
|
|
|
log.error(
|
|
|
|
'shim: Error calling sendStickerPackSync:',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|