fix: unrevoke on resend invite

pull/3052/head
Audric Ackermann 1 year ago
parent c2e5c358f1
commit 038e08ed3d
No known key found for this signature in database

@ -24,6 +24,15 @@ import {
SessionButtonType,
} from './basic/SessionButton';
import { SessionRadio } from './basic/SessionRadio';
import { GroupSync } from '../session/utils/job_runners/jobs/GroupSyncJob';
import { RunJobResult } from '../session/utils/job_runners/PersistedJob';
import { SubaccountUnrevokeSubRequest } from '../session/apis/snode_api/SnodeRequestTypes';
import { NetworkTime } from '../util/NetworkTime';
import {
MetaGroupWrapperActions,
UserGroupsWrapperActions,
} from '../webworker/workers/browser/libsession_worker_interface';
import { isEmpty } from 'lodash';
const AvatarContainer = styled.div`
position: relative;
@ -223,11 +232,35 @@ const ResendInviteButton = ({
buttonShape={SessionButtonShape.Square}
buttonType={SessionButtonType.Solid}
text={window.i18n('resend')}
onClick={() => {
void GroupInvite.addJob({
onClick={async () => {
const group = await UserGroupsWrapperActions.getGroup(groupPk);
const member = await MetaGroupWrapperActions.memberGet(groupPk, pubkey);
if (!group || !group.secretKey || isEmpty(group.secretKey) || !member) {
window.log.warn('tried to resend invite but we do not have correct details');
return;
}
const unrevokeSubRequest = new SubaccountUnrevokeSubRequest({
groupPk,
revokeTokenHex: [pubkey],
timestamp: NetworkTime.now(),
secretKey: group.secretKey,
});
const sequenceResult = await GroupSync.pushChangesToGroupSwarmIfNeeded({
groupPk,
unrevokeSubRequest,
extraStoreRequests: [],
});
if (sequenceResult !== RunJobResult.Success) {
throw new Error('resend invite: pushChangesToGroupSwarmIfNeeded did not return success');
}
// if we tried to invite that member as admin right away, let's retry it as such.
const inviteAsAdmin =
member.promotionNotSent || member.promotionFailed || member.promotionPending;
await GroupInvite.addJob({
groupPk,
member: pubkey,
inviteAsAdmin: window.sessionFeatureFlags.useGroupV2InviteAsAdmin,
inviteAsAdmin,
});
}}
/>
@ -250,7 +283,7 @@ const ResendPromoteButton = ({
buttonShape={SessionButtonShape.Square}
buttonType={SessionButtonType.Solid}
buttonColor={SessionButtonColor.Danger}
text="PrOmOtE" // TODO DO NOT MERGE Remove after QA
text={window.i18n('promote')} // TODO DO NOT MERGE Remove after QA
onClick={() => {
void promoteUsersInGroup({
groupPk,

@ -8,6 +8,7 @@ import { ConvoHub } from '../session/conversations';
import { Quote } from './types';
import { MessageDirection } from '../models/messageType';
import { ConversationTypeEnum } from '../models/types';
import { SignalService } from '../protobuf';
import { DisappearingMessages } from '../session/disappearing_messages';
import { ProfileManager } from '../session/profile_manager/ProfileManager';
@ -24,7 +25,6 @@ import { getHideMessageRequestBannerOutsideRedux } from '../state/selectors/user
import { GoogleChrome } from '../util';
import { LinkPreviews } from '../util/linkPreviews';
import { GroupV2Receiver } from './groupv2/handleGroupV2Message';
import { ConversationTypeEnum } from '../models/types';
function contentTypeSupported(type: string): boolean {
const Chrome = GoogleChrome;
@ -422,6 +422,7 @@ export async function handleMessageJob(
source,
ConversationTypeEnum.PRIVATE
);
try {
messageModel.set({ flags: regularDataMessage.flags });

@ -9,7 +9,7 @@ import {
WithGroupPubkey,
WithPubkey,
} from 'libsession_util_nodejs';
import { intersection, isEmpty, uniq } from 'lodash';
import { concat, intersection, isEmpty, uniq } from 'lodash';
import { from_hex } from 'libsodium-wrappers-sumo';
import { ConfigDumpData } from '../../data/configDump/configDump';
import { HexString } from '../../node/hexStrings';
@ -1426,12 +1426,9 @@ async function scheduleGroupInviteJobs(
withoutHistory: Array<PubkeyType>,
inviteAsAdmin: boolean
) {
for (let index = 0; index < withoutHistory.length; index++) {
const member = withoutHistory[index];
await GroupInvite.addJob({ groupPk, member, inviteAsAdmin });
}
for (let index = 0; index < withHistory.length; index++) {
const member = withHistory[index];
const merged = uniq(concat(withHistory, withoutHistory));
for (let index = 0; index < merged.length; index++) {
const member = merged[index];
await GroupInvite.addJob({ groupPk, member, inviteAsAdmin });
}
}

Loading…
Cancel
Save