From 07930d4e5e029b855e7faef647dad3e3463cfa77 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 23 Oct 2024 20:19:12 +1100 Subject: [PATCH] fix: mark promote accepted on invite via promote-> accept --- ts/interactions/conversationInteractions.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ts/interactions/conversationInteractions.ts b/ts/interactions/conversationInteractions.ts index ea741cdd6..2b069fc71 100644 --- a/ts/interactions/conversationInteractions.ts +++ b/ts/interactions/conversationInteractions.ts @@ -1,4 +1,4 @@ -import { isNil } from 'lodash'; +import { isEmpty, isNil } from 'lodash'; import { ConversationNotificationSettingType, READ_MESSAGE_STATE, @@ -47,12 +47,16 @@ import { urlToBlob } from '../types/attachments/VisualAttachment'; import { encryptProfile } from '../util/crypto/profileEncrypter'; import { ReleasedFeatures } from '../util/releaseFeature'; import { Storage, setLastProfileUpdateTimestamp } from '../util/storage'; -import { UserGroupsWrapperActions } from '../webworker/workers/browser/libsession_worker_interface'; +import { + MetaGroupWrapperActions, + UserGroupsWrapperActions, +} from '../webworker/workers/browser/libsession_worker_interface'; import { ConversationInteractionStatus, ConversationInteractionType } from './types'; import { BlockedNumberController } from '../util'; import { LocalizerComponentProps, LocalizerToken } from '../types/localizer'; import { sendInviteResponseToGroup } from '../session/sending/group/GroupInviteResponse'; import { NetworkTime } from '../util/NetworkTime'; +import { GroupSync } from '../session/utils/job_runners/jobs/GroupSyncJob'; export async function copyPublicKeyByConvoId(convoId: string) { if (OpenGroupUtils.isOpenGroupV2(convoId)) { @@ -132,6 +136,18 @@ export const handleAcceptConversationRequest = async ({ convoId }: { convoId: st if (!previousIsApproved) { await sendInviteResponseToGroup({ groupPk: convoId }); } + const refreshed = await UserGroupsWrapperActions.getGroup(convoId); + + // if we are admin, we also need to accept it and mark ourselves as such + const weAreAdmin = refreshed && !isEmpty(refreshed.secretKey); + if (weAreAdmin) { + await MetaGroupWrapperActions.memberSetPromotionAccepted( + convoId, + UserUtils.getOurPubKeyStrFromCache() + ); + await GroupSync.queueNewJobIfNeeded(convoId); + } + window.log.info( `handleAcceptConversationRequest: first poll for group ${ed25519Str(convoId)} happened, we should have encryption keys now` );