|
|
@ -8,7 +8,6 @@ import { updateConfirmModal } from '../../state/ducks/modalDialog';
|
|
|
|
import { getSwarmPollingInstance } from '../apis/snode_api';
|
|
|
|
import { getSwarmPollingInstance } from '../apis/snode_api';
|
|
|
|
import { SnodeNamespaces } from '../apis/snode_api/namespaces';
|
|
|
|
import { SnodeNamespaces } from '../apis/snode_api/namespaces';
|
|
|
|
import { generateClosedGroupPublicKey, generateCurve25519KeyPairWithoutPrefix } from '../crypto';
|
|
|
|
import { generateClosedGroupPublicKey, generateCurve25519KeyPairWithoutPrefix } from '../crypto';
|
|
|
|
import { DisappearAfterSendOnly, DisappearingMessageType } from '../disappearing_messages/types';
|
|
|
|
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
ClosedGroupNewMessage,
|
|
|
|
ClosedGroupNewMessage,
|
|
|
|
ClosedGroupNewMessageParams,
|
|
|
|
ClosedGroupNewMessageParams,
|
|
|
@ -68,15 +67,14 @@ export async function createClosedGroup(groupName: string, members: Array<string
|
|
|
|
await convo.commit();
|
|
|
|
await convo.commit();
|
|
|
|
convo.updateLastMessage();
|
|
|
|
convo.updateLastMessage();
|
|
|
|
|
|
|
|
|
|
|
|
// Send a closed group update message to all members individually
|
|
|
|
// Send a closed group update message to all members individually.
|
|
|
|
|
|
|
|
// Note: we do not make those messages expire
|
|
|
|
const allInvitesSent = await sendToGroupMembers(
|
|
|
|
const allInvitesSent = await sendToGroupMembers(
|
|
|
|
listOfMembers,
|
|
|
|
listOfMembers,
|
|
|
|
groupPublicKey,
|
|
|
|
groupPublicKey,
|
|
|
|
groupName,
|
|
|
|
groupName,
|
|
|
|
admins,
|
|
|
|
admins,
|
|
|
|
encryptionKeyPair,
|
|
|
|
encryptionKeyPair
|
|
|
|
existingExpirationType,
|
|
|
|
|
|
|
|
existingExpireTimer
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (allInvitesSent) {
|
|
|
|
if (allInvitesSent) {
|
|
|
@ -103,8 +101,6 @@ async function sendToGroupMembers(
|
|
|
|
groupName: string,
|
|
|
|
groupName: string,
|
|
|
|
admins: Array<string>,
|
|
|
|
admins: Array<string>,
|
|
|
|
encryptionKeyPair: ECKeyPair,
|
|
|
|
encryptionKeyPair: ECKeyPair,
|
|
|
|
existingExpirationType: DisappearAfterSendOnly,
|
|
|
|
|
|
|
|
existingExpireTimer: number,
|
|
|
|
|
|
|
|
isRetry: boolean = false
|
|
|
|
isRetry: boolean = false
|
|
|
|
): Promise<any> {
|
|
|
|
): Promise<any> {
|
|
|
|
const promises = createInvitePromises(
|
|
|
|
const promises = createInvitePromises(
|
|
|
@ -112,9 +108,7 @@ async function sendToGroupMembers(
|
|
|
|
groupPublicKey,
|
|
|
|
groupPublicKey,
|
|
|
|
groupName,
|
|
|
|
groupName,
|
|
|
|
admins,
|
|
|
|
admins,
|
|
|
|
encryptionKeyPair,
|
|
|
|
encryptionKeyPair
|
|
|
|
existingExpirationType,
|
|
|
|
|
|
|
|
existingExpireTimer
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
window?.log?.info(`Sending invites for group ${groupPublicKey} to ${listOfMembers}`);
|
|
|
|
window?.log?.info(`Sending invites for group ${groupPublicKey} to ${listOfMembers}`);
|
|
|
|
// evaluating if all invites sent, if failed give the option to retry failed invites via modal dialog
|
|
|
|
// evaluating if all invites sent, if failed give the option to retry failed invites via modal dialog
|
|
|
@ -169,8 +163,6 @@ async function sendToGroupMembers(
|
|
|
|
groupName,
|
|
|
|
groupName,
|
|
|
|
admins,
|
|
|
|
admins,
|
|
|
|
encryptionKeyPair,
|
|
|
|
encryptionKeyPair,
|
|
|
|
existingExpirationType,
|
|
|
|
|
|
|
|
existingExpireTimer,
|
|
|
|
|
|
|
|
isRetrySend
|
|
|
|
isRetrySend
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -186,9 +178,7 @@ function createInvitePromises(
|
|
|
|
groupPublicKey: string,
|
|
|
|
groupPublicKey: string,
|
|
|
|
groupName: string,
|
|
|
|
groupName: string,
|
|
|
|
admins: Array<string>,
|
|
|
|
admins: Array<string>,
|
|
|
|
encryptionKeyPair: ECKeyPair,
|
|
|
|
encryptionKeyPair: ECKeyPair
|
|
|
|
existingExpirationType: DisappearingMessageType,
|
|
|
|
|
|
|
|
existingExpireTimer: number
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return listOfMembers.map(async m => {
|
|
|
|
return listOfMembers.map(async m => {
|
|
|
|
const messageParams: ClosedGroupNewMessageParams = {
|
|
|
|
const messageParams: ClosedGroupNewMessageParams = {
|
|
|
@ -198,8 +188,8 @@ function createInvitePromises(
|
|
|
|
admins,
|
|
|
|
admins,
|
|
|
|
keypair: encryptionKeyPair,
|
|
|
|
keypair: encryptionKeyPair,
|
|
|
|
timestamp: Date.now(),
|
|
|
|
timestamp: Date.now(),
|
|
|
|
expirationType: existingExpirationType,
|
|
|
|
expirationType: null, // Note: we do not make those messages expire as we want them available as much as possible on the swarm of the recipient
|
|
|
|
expireTimer: existingExpireTimer,
|
|
|
|
expireTimer: 0,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const message = new ClosedGroupNewMessage(messageParams);
|
|
|
|
const message = new ClosedGroupNewMessage(messageParams);
|
|
|
|
return getMessageQueue().sendToPubKeyNonDurably({
|
|
|
|
return getMessageQueue().sendToPubKeyNonDurably({
|
|
|
|