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` );