2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-01-29 22:16:48 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-12-22 03:07:45 +00:00
|
|
|
import { render, unmountComponentAtNode } from 'react-dom';
|
|
|
|
|
|
|
|
import type { ConversationAttributesType } from '../model-types.d';
|
|
|
|
import type { ConversationModel } from '../models/conversations';
|
|
|
|
import type { PreJoinConversationType } from '../state/ducks/conversations';
|
|
|
|
|
|
|
|
import * as Bytes from '../Bytes';
|
|
|
|
import * as Errors from '../types/errors';
|
|
|
|
import * as log from '../logging/log';
|
|
|
|
import { HTTPError } from '../textsecure/Errors';
|
|
|
|
import { SignalService as Proto } from '../protobuf';
|
|
|
|
import { ToastType } from '../types/Toast';
|
2021-01-29 22:16:48 +00:00
|
|
|
import {
|
|
|
|
applyNewAvatar,
|
2021-06-02 00:24:28 +00:00
|
|
|
decryptGroupDescription,
|
2021-01-29 22:16:48 +00:00
|
|
|
decryptGroupTitle,
|
|
|
|
deriveGroupFields,
|
|
|
|
getPreJoinGroupInfo,
|
|
|
|
idForLogging,
|
|
|
|
LINK_VERSION_ERROR,
|
|
|
|
parseGroupLink,
|
|
|
|
} from '../groups';
|
2022-12-22 03:07:45 +00:00
|
|
|
import { createGroupV2JoinModal } from '../state/roots/createGroupV2JoinModal';
|
2021-07-28 21:37:09 +00:00
|
|
|
import { explodePromise } from '../util/explodePromise';
|
2022-03-15 01:32:07 +00:00
|
|
|
import { isAccessControlEnabled } from './util';
|
2022-12-22 03:07:45 +00:00
|
|
|
import { isGroupV1 } from '../util/whatTypeOfConversation';
|
|
|
|
import { longRunningTaskWrapper } from '../util/longRunningTaskWrapper';
|
2022-05-16 14:53:54 +00:00
|
|
|
import { sleep } from '../util/sleep';
|
2023-11-07 21:31:59 +00:00
|
|
|
import { dropNull } from '../util/dropNull';
|
2024-07-11 19:44:09 +00:00
|
|
|
import { getLocalAttachmentUrl } from '../util/getLocalAttachmentUrl';
|
2021-01-29 22:16:48 +00:00
|
|
|
|
2023-11-02 19:42:31 +00:00
|
|
|
export async function joinViaLink(value: string): Promise<void> {
|
2021-01-29 22:16:48 +00:00
|
|
|
let inviteLinkPassword: string;
|
|
|
|
let masterKey: string;
|
|
|
|
try {
|
2023-11-02 19:42:31 +00:00
|
|
|
({ inviteLinkPassword, masterKey } = parseGroupLink(value));
|
2022-03-15 01:32:07 +00:00
|
|
|
} catch (error: unknown) {
|
|
|
|
const errorString = Errors.toLogFormat(error);
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error(`joinViaLink: Failed to parse group link ${errorString}`);
|
2022-03-15 01:32:07 +00:00
|
|
|
|
|
|
|
if (error instanceof Error && error.name === LINK_VERSION_ERROR) {
|
2022-12-22 03:07:45 +00:00
|
|
|
window.reduxActions.globalModals.showErrorModal({
|
2023-03-30 00:03:25 +00:00
|
|
|
description: window.i18n('icu:GroupV2--join--unknown-link-version'),
|
|
|
|
title: window.i18n('icu:GroupV2--join--unknown-link-version--title'),
|
2022-12-22 03:07:45 +00:00
|
|
|
});
|
2021-01-29 22:16:48 +00:00
|
|
|
} else {
|
2022-12-22 03:07:45 +00:00
|
|
|
window.reduxActions.globalModals.showErrorModal({
|
2023-03-30 00:03:25 +00:00
|
|
|
description: window.i18n('icu:GroupV2--join--invalid-link'),
|
|
|
|
title: window.i18n('icu:GroupV2--join--invalid-link--title'),
|
2022-12-22 03:07:45 +00:00
|
|
|
});
|
2021-01-29 22:16:48 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-22 14:46:42 +00:00
|
|
|
const data = deriveGroupFields(Bytes.fromBase64(masterKey));
|
|
|
|
const id = Bytes.toBase64(data.id);
|
2021-01-29 22:16:48 +00:00
|
|
|
const logId = `groupv2(${id})`;
|
2021-06-22 14:46:42 +00:00
|
|
|
const secretParams = Bytes.toBase64(data.secretParams);
|
|
|
|
const publicParams = Bytes.toBase64(data.publicParams);
|
2021-01-29 22:16:48 +00:00
|
|
|
|
|
|
|
const existingConversation =
|
|
|
|
window.ConversationController.get(id) ||
|
|
|
|
window.ConversationController.getByDerivedGroupV2Id(id);
|
2023-08-10 16:43:33 +00:00
|
|
|
const ourAci = window.textsecure.storage.user.getCheckedAci();
|
2021-01-29 22:16:48 +00:00
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
if (existingConversation && existingConversation.hasMember(ourAci)) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn(
|
2021-01-29 22:16:48 +00:00
|
|
|
`joinViaLink/${logId}: Already a member of group, opening conversation`
|
|
|
|
);
|
2022-06-16 19:12:50 +00:00
|
|
|
window.reduxActions.conversations.showConversation({
|
2021-02-23 20:34:28 +00:00
|
|
|
conversationId: existingConversation.id,
|
|
|
|
});
|
2023-04-10 21:38:34 +00:00
|
|
|
window.reduxActions.toast.showToast({
|
|
|
|
toastType: ToastType.AlreadyGroupMember,
|
|
|
|
});
|
2021-01-29 22:16:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-22 14:46:42 +00:00
|
|
|
let result: Proto.GroupJoinInfo;
|
2021-01-29 22:16:48 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
result = await longRunningTaskWrapper({
|
|
|
|
name: 'getPreJoinGroupInfo',
|
|
|
|
idForLogging: idForLogging(id),
|
|
|
|
// If an error happens here, we won't show a dialog. We'll rely on the catch a few
|
|
|
|
// lines below.
|
|
|
|
suppressErrorDialog: true,
|
|
|
|
task: () => getPreJoinGroupInfo(inviteLinkPassword, masterKey),
|
|
|
|
});
|
2022-03-15 01:32:07 +00:00
|
|
|
} catch (error: unknown) {
|
|
|
|
const errorString = Errors.toLogFormat(error);
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error(
|
2021-01-29 22:16:48 +00:00
|
|
|
`joinViaLink/${logId}: Failed to fetch group info - ${errorString}`
|
|
|
|
);
|
|
|
|
|
2022-03-15 01:32:07 +00:00
|
|
|
if (
|
|
|
|
error instanceof HTTPError &&
|
|
|
|
error.responseHeaders['x-signal-forbidden-reason']
|
|
|
|
) {
|
2022-12-22 03:07:45 +00:00
|
|
|
window.reduxActions.globalModals.showErrorModal({
|
2023-03-30 00:03:25 +00:00
|
|
|
description: window.i18n('icu:GroupV2--join--link-forbidden'),
|
|
|
|
title: window.i18n('icu:GroupV2--join--link-forbidden--title'),
|
2022-12-22 03:07:45 +00:00
|
|
|
});
|
2022-03-15 01:32:07 +00:00
|
|
|
} else if (error instanceof HTTPError && error.code === 403) {
|
2022-12-22 03:07:45 +00:00
|
|
|
window.reduxActions.globalModals.showErrorModal({
|
2023-03-30 00:03:25 +00:00
|
|
|
description: window.i18n('icu:GroupV2--join--link-revoked'),
|
|
|
|
title: window.i18n('icu:GroupV2--join--link-revoked--title'),
|
2022-12-22 03:07:45 +00:00
|
|
|
});
|
2022-03-15 01:32:07 +00:00
|
|
|
} else {
|
2022-12-22 03:07:45 +00:00
|
|
|
window.reduxActions.globalModals.showErrorModal({
|
2023-03-30 00:03:25 +00:00
|
|
|
description: window.i18n('icu:GroupV2--join--general-join-failure'),
|
|
|
|
title: window.i18n('icu:GroupV2--join--general-join-failure--title'),
|
2022-12-22 03:07:45 +00:00
|
|
|
});
|
2022-03-15 01:32:07 +00:00
|
|
|
}
|
2021-01-29 22:16:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-11-07 21:31:59 +00:00
|
|
|
if (!isAccessControlEnabled(dropNull(result.addFromInviteLink))) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error(
|
2021-01-29 22:16:48 +00:00
|
|
|
`joinViaLink/${logId}: addFromInviteLink value of ${result.addFromInviteLink} is invalid`
|
|
|
|
);
|
2022-12-22 03:07:45 +00:00
|
|
|
window.reduxActions.globalModals.showErrorModal({
|
2023-03-30 00:03:25 +00:00
|
|
|
description: window.i18n('icu:GroupV2--join--link-revoked'),
|
|
|
|
title: window.i18n('icu:GroupV2--join--link-revoked--title'),
|
2022-12-22 03:07:45 +00:00
|
|
|
});
|
2021-01-29 22:16:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let localAvatar:
|
|
|
|
| {
|
|
|
|
loading?: boolean;
|
|
|
|
path?: string;
|
|
|
|
}
|
|
|
|
| undefined = result.avatar ? { loading: true } : undefined;
|
|
|
|
const memberCount = result.memberCount || 1;
|
|
|
|
const approvalRequired =
|
2022-03-15 01:32:07 +00:00
|
|
|
result.addFromInviteLink ===
|
|
|
|
Proto.AccessControl.AccessRequired.ADMINISTRATOR;
|
2021-01-29 22:16:48 +00:00
|
|
|
const title =
|
2023-11-07 21:31:59 +00:00
|
|
|
decryptGroupTitle(dropNull(result.title), secretParams) ||
|
2023-03-30 00:03:25 +00:00
|
|
|
window.i18n('icu:unknownGroup');
|
2021-06-02 00:24:28 +00:00
|
|
|
const groupDescription = decryptGroupDescription(
|
2023-11-07 21:31:59 +00:00
|
|
|
dropNull(result.descriptionBytes),
|
2021-06-02 00:24:28 +00:00
|
|
|
secretParams
|
|
|
|
);
|
2021-01-29 22:16:48 +00:00
|
|
|
|
|
|
|
if (
|
|
|
|
approvalRequired &&
|
|
|
|
existingConversation &&
|
2023-08-10 16:43:33 +00:00
|
|
|
existingConversation.isMemberAwaitingApproval(ourAci)
|
2021-01-29 22:16:48 +00:00
|
|
|
) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn(
|
2021-01-29 22:16:48 +00:00
|
|
|
`joinViaLink/${logId}: Already awaiting approval, opening conversation`
|
|
|
|
);
|
2022-05-16 14:53:54 +00:00
|
|
|
const timestamp = existingConversation.get('timestamp') || Date.now();
|
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
const active_at = existingConversation.get('active_at') || Date.now();
|
2022-11-18 00:45:19 +00:00
|
|
|
// eslint-disable-next-line camelcase
|
2022-05-16 14:53:54 +00:00
|
|
|
existingConversation.set({ active_at, timestamp });
|
|
|
|
window.Signal.Data.updateConversation(existingConversation.attributes);
|
|
|
|
|
|
|
|
// We're waiting for the left pane to re-sort before we navigate to that conversation
|
|
|
|
await sleep(200);
|
|
|
|
|
2022-06-16 19:12:50 +00:00
|
|
|
window.reduxActions.conversations.showConversation({
|
2021-02-23 20:34:28 +00:00
|
|
|
conversationId: existingConversation.id,
|
|
|
|
});
|
2021-01-29 22:16:48 +00:00
|
|
|
|
2023-04-10 21:38:34 +00:00
|
|
|
window.reduxActions.toast.showToast({
|
|
|
|
toastType: ToastType.AlreadyRequestedToJoin,
|
|
|
|
});
|
2021-01-29 22:16:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const getPreJoinConversation = (): PreJoinConversationType => {
|
|
|
|
let avatar;
|
|
|
|
if (!localAvatar) {
|
|
|
|
avatar = undefined;
|
|
|
|
} else if (localAvatar && localAvatar.loading) {
|
|
|
|
avatar = {
|
|
|
|
loading: true,
|
|
|
|
};
|
|
|
|
} else if (localAvatar && localAvatar.path) {
|
|
|
|
avatar = {
|
2024-07-11 19:44:09 +00:00
|
|
|
url: getLocalAttachmentUrl(localAvatar),
|
2021-01-29 22:16:48 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
approvalRequired,
|
|
|
|
avatar,
|
2021-06-02 00:24:28 +00:00
|
|
|
groupDescription,
|
2021-01-29 22:16:48 +00:00
|
|
|
memberCount,
|
|
|
|
title,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Explode a promise so we know when this whole join process is complete
|
2021-07-28 21:37:09 +00:00
|
|
|
const { promise, resolve, reject } = explodePromise<void>();
|
2021-01-29 22:16:48 +00:00
|
|
|
|
|
|
|
const closeDialog = async () => {
|
|
|
|
try {
|
2022-12-22 03:07:45 +00:00
|
|
|
if (groupV2InfoNode) {
|
|
|
|
unmountComponentAtNode(groupV2InfoNode);
|
|
|
|
groupV2InfoNode = undefined;
|
2021-01-29 22:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
window.reduxActions.conversations.setPreJoinConversation(undefined);
|
|
|
|
|
|
|
|
if (localAvatar && localAvatar.path) {
|
|
|
|
await window.Signal.Migrations.deleteAttachmentData(localAvatar.path);
|
|
|
|
}
|
|
|
|
resolve();
|
|
|
|
} catch (error) {
|
|
|
|
reject(error);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const join = async () => {
|
|
|
|
try {
|
2022-12-22 03:07:45 +00:00
|
|
|
if (groupV2InfoNode) {
|
|
|
|
unmountComponentAtNode(groupV2InfoNode);
|
|
|
|
groupV2InfoNode = undefined;
|
2021-01-29 22:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
window.reduxActions.conversations.setPreJoinConversation(undefined);
|
|
|
|
|
|
|
|
await longRunningTaskWrapper({
|
|
|
|
name: 'joinViaLink',
|
|
|
|
idForLogging: idForLogging(id),
|
|
|
|
// If an error happens here, we won't show a dialog. We'll rely on a top-level
|
|
|
|
// error dialog provided by the caller of this function.
|
|
|
|
suppressErrorDialog: true,
|
|
|
|
task: async () => {
|
|
|
|
let targetConversation =
|
|
|
|
existingConversation ||
|
|
|
|
window.ConversationController.get(id) ||
|
|
|
|
window.ConversationController.getByDerivedGroupV2Id(id);
|
|
|
|
let tempConversation: ConversationModel | undefined;
|
|
|
|
|
|
|
|
// Check again to ensure that we haven't already joined or requested to join
|
|
|
|
// via some other process. If so, just open that conversation.
|
|
|
|
if (
|
|
|
|
targetConversation &&
|
2023-08-10 16:43:33 +00:00
|
|
|
(targetConversation.hasMember(ourAci) ||
|
2021-01-29 22:16:48 +00:00
|
|
|
(approvalRequired &&
|
2023-08-10 16:43:33 +00:00
|
|
|
targetConversation.isMemberAwaitingApproval(ourAci)))
|
2021-01-29 22:16:48 +00:00
|
|
|
) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn(
|
2021-01-29 22:16:48 +00:00
|
|
|
`joinViaLink/${logId}: User is part of group on second check, opening conversation`
|
|
|
|
);
|
2022-06-16 19:12:50 +00:00
|
|
|
window.reduxActions.conversations.showConversation({
|
2021-02-23 20:34:28 +00:00
|
|
|
conversationId: targetConversation.id,
|
|
|
|
});
|
2021-01-29 22:16:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (!targetConversation) {
|
|
|
|
// Note: we save this temp conversation in the database, so we'll need to
|
|
|
|
// clean it up if something goes wrong
|
|
|
|
tempConversation = window.ConversationController.getOrCreate(
|
|
|
|
id,
|
|
|
|
'group',
|
|
|
|
{
|
|
|
|
// This will cause this conversation to be deleted at next startup
|
|
|
|
isTemporary: true,
|
|
|
|
|
2022-05-16 14:53:54 +00:00
|
|
|
active_at: Date.now(),
|
|
|
|
timestamp: Date.now(),
|
|
|
|
|
2021-01-29 22:16:48 +00:00
|
|
|
groupVersion: 2,
|
|
|
|
masterKey,
|
|
|
|
secretParams,
|
|
|
|
publicParams,
|
|
|
|
|
|
|
|
left: true,
|
|
|
|
revision: result.version,
|
|
|
|
|
|
|
|
avatar:
|
|
|
|
localAvatar && localAvatar.path && result.avatar
|
|
|
|
? {
|
|
|
|
url: result.avatar,
|
|
|
|
path: localAvatar.path,
|
|
|
|
}
|
|
|
|
: undefined,
|
2022-05-16 14:53:54 +00:00
|
|
|
description: groupDescription,
|
2021-01-29 22:16:48 +00:00
|
|
|
groupInviteLinkPassword: inviteLinkPassword,
|
|
|
|
name: title,
|
|
|
|
temporaryMemberCount: memberCount,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
targetConversation = tempConversation;
|
|
|
|
} else {
|
|
|
|
// Ensure the group maintains the title and avatar you saw when attempting
|
|
|
|
// to join it.
|
2022-05-16 14:53:54 +00:00
|
|
|
const timestamp =
|
|
|
|
targetConversation.get('timestamp') || Date.now();
|
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
const active_at =
|
|
|
|
targetConversation.get('active_at') || Date.now();
|
2021-01-29 22:16:48 +00:00
|
|
|
targetConversation.set({
|
2022-11-18 00:45:19 +00:00
|
|
|
// eslint-disable-next-line camelcase
|
2022-05-16 14:53:54 +00:00
|
|
|
active_at,
|
2021-01-29 22:16:48 +00:00
|
|
|
avatar:
|
|
|
|
localAvatar && localAvatar.path && result.avatar
|
|
|
|
? {
|
|
|
|
url: result.avatar,
|
|
|
|
path: localAvatar.path,
|
|
|
|
}
|
|
|
|
: undefined,
|
2022-05-16 14:53:54 +00:00
|
|
|
description: groupDescription,
|
2021-01-29 22:16:48 +00:00
|
|
|
groupInviteLinkPassword: inviteLinkPassword,
|
2023-03-01 23:48:23 +00:00
|
|
|
left: true,
|
2021-01-29 22:16:48 +00:00
|
|
|
name: title,
|
2023-11-07 21:31:59 +00:00
|
|
|
revision: dropNull(result.version),
|
2021-01-29 22:16:48 +00:00
|
|
|
temporaryMemberCount: memberCount,
|
2022-05-16 14:53:54 +00:00
|
|
|
timestamp,
|
2021-01-29 22:16:48 +00:00
|
|
|
});
|
|
|
|
window.Signal.Data.updateConversation(
|
|
|
|
targetConversation.attributes
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-06-07 16:39:13 +00:00
|
|
|
if (isGroupV1(targetConversation.attributes)) {
|
2021-01-29 22:16:48 +00:00
|
|
|
await targetConversation.joinGroupV2ViaLinkAndMigrate({
|
|
|
|
approvalRequired,
|
|
|
|
inviteLinkPassword,
|
|
|
|
revision: result.version || 0,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
await targetConversation.joinGroupV2ViaLink({
|
|
|
|
inviteLinkPassword,
|
|
|
|
approvalRequired,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tempConversation) {
|
|
|
|
tempConversation.set({
|
|
|
|
// We want to keep this conversation around, since the join succeeded
|
|
|
|
isTemporary: undefined,
|
|
|
|
});
|
|
|
|
window.Signal.Data.updateConversation(
|
|
|
|
tempConversation.attributes
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-06-16 19:12:50 +00:00
|
|
|
window.reduxActions.conversations.showConversation({
|
2021-02-23 20:34:28 +00:00
|
|
|
conversationId: targetConversation.id,
|
|
|
|
});
|
2021-01-29 22:16:48 +00:00
|
|
|
} catch (error) {
|
|
|
|
// Delete newly-created conversation if we encountered any errors
|
|
|
|
if (tempConversation) {
|
|
|
|
window.ConversationController.dangerouslyRemoveById(
|
|
|
|
tempConversation.id
|
|
|
|
);
|
2021-12-10 22:51:54 +00:00
|
|
|
await window.Signal.Data.removeConversation(tempConversation.id);
|
2021-01-29 22:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
resolve();
|
|
|
|
} catch (error) {
|
|
|
|
reject(error);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Initial add to redux, with basic group information
|
|
|
|
window.reduxActions.conversations.setPreJoinConversation(
|
|
|
|
getPreJoinConversation()
|
|
|
|
);
|
|
|
|
|
2021-09-17 18:27:53 +00:00
|
|
|
log.info(`joinViaLink/${logId}: Showing modal`);
|
2021-01-29 22:16:48 +00:00
|
|
|
|
2022-12-22 03:07:45 +00:00
|
|
|
let groupV2InfoNode: HTMLDivElement | undefined =
|
|
|
|
document.createElement('div');
|
|
|
|
|
|
|
|
render(
|
|
|
|
createGroupV2JoinModal(window.reduxStore, { join, onClose: closeDialog }),
|
|
|
|
groupV2InfoNode
|
|
|
|
);
|
2021-01-29 22:16:48 +00:00
|
|
|
|
|
|
|
// We declare a new function here so we can await but not block
|
|
|
|
const fetchAvatar = async () => {
|
|
|
|
if (result.avatar) {
|
|
|
|
localAvatar = {
|
|
|
|
loading: true,
|
|
|
|
};
|
|
|
|
|
2024-06-24 18:38:59 +00:00
|
|
|
let attributes: Pick<
|
2021-01-29 22:16:48 +00:00
|
|
|
ConversationAttributesType,
|
|
|
|
'avatar' | 'secretParams'
|
|
|
|
> = {
|
|
|
|
avatar: null,
|
|
|
|
secretParams,
|
|
|
|
};
|
2024-06-24 18:38:59 +00:00
|
|
|
const patch = await applyNewAvatar(result.avatar, attributes, logId);
|
|
|
|
attributes = { ...attributes, ...patch };
|
2021-01-29 22:16:48 +00:00
|
|
|
|
|
|
|
if (attributes.avatar && attributes.avatar.path) {
|
|
|
|
localAvatar = {
|
2024-07-11 19:44:09 +00:00
|
|
|
...attributes.avatar,
|
2021-01-29 22:16:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Dialog has been dismissed; we'll delete the unneeeded avatar
|
2022-12-22 03:07:45 +00:00
|
|
|
if (!groupV2InfoNode) {
|
2021-01-29 22:16:48 +00:00
|
|
|
await window.Signal.Migrations.deleteAttachmentData(
|
|
|
|
attributes.avatar.path
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
localAvatar = undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update join dialog with newly-downloaded avatar
|
|
|
|
window.reduxActions.conversations.setPreJoinConversation(
|
|
|
|
getPreJoinConversation()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-12-21 18:41:48 +00:00
|
|
|
void fetchAvatar();
|
2021-01-29 22:16:48 +00:00
|
|
|
|
|
|
|
await promise;
|
|
|
|
}
|