Skip to content

Commit

Permalink
feat: debug util to update migration feature team settings config
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrykBuniX committed Jun 16, 2023
1 parent 15be1dc commit c232748
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
13 changes: 1 addition & 12 deletions src/script/mls/MLSMigration/MLSMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,7 @@ const checkMigrationConfig = async (
}
//at this point we know that MLS is supported by environment, we can check MLS migration config
//fetch current mls migration feature config from memory
let mlsMigrationFeature = teamState.teamFeatures().mlsMigration;

//FIXME: remove this when we have a proper config from the backend
mlsMigrationFeature = {
config: {
clientsThreshold: 100,
usersThreshold: 100,
finaliseRegardlessAfter: '2025-05-16T09:25:27.123Z',
startTime: '2023-05-16T13:17:32.739Z',
},
status: FeatureStatus.ENABLED,
};
const mlsMigrationFeature = teamState.teamFeatures().mlsMigration;

if (!mlsMigrationFeature || mlsMigrationFeature.status === FeatureStatus.DISABLED) {
mlsMigrationLogger.info('MLS migration feature is disabled, will retry in 24 hours or on next app reload.');
Expand Down
26 changes: 26 additions & 0 deletions src/script/util/DebugUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
USER_EVENT,
} from '@wireapp/api-client/lib/event/';
import type {Notification} from '@wireapp/api-client/lib/notification/';
import {FeatureStatus} from '@wireapp/api-client/lib/team/feature/';
import type {QualifiedId} from '@wireapp/api-client/lib/user';
import {DatabaseKeys} from '@wireapp/core/lib/notification/NotificationDatabaseRepository';
import Dexie from 'dexie';
Expand All @@ -35,6 +36,7 @@ import {container} from 'tsyringe';

import {getLogger, Logger} from 'Util/Logger';

import {TIME_IN_MILLIS} from './TimeUtil';
import {createUuid} from './uuid';

import {CallingRepository} from '../calling/CallingRepository';
Expand All @@ -49,6 +51,7 @@ import {Conversation} from '../entity/Conversation';
import {User} from '../entity/User';
import {EventRepository} from '../event/EventRepository';
import {checkVersion} from '../lifecycle/newVersionHandler';
import {APIClient} from '../service/APIClientSingleton';
import {Core} from '../service/CoreSingleton';
import {EventRecord, StorageRepository, StorageSchemata} from '../storage';
import {UserRepository} from '../user/UserRepository';
Expand Down Expand Up @@ -78,6 +81,7 @@ export class DebugUtil {
private readonly conversationState = container.resolve(ConversationState),
private readonly callState = container.resolve(CallState),
private readonly core = container.resolve(Core),
private readonly apiClient = container.resolve(APIClient),
) {
this.$ = $;
this.Dexie = Dexie;
Expand Down Expand Up @@ -151,6 +155,28 @@ export class DebugUtil {
await proteusService['cryptoClient'].debugBreakSession(sessionId);
}

/** Used by QA test automation. */
async setMLSMigrationConfig(
isEnabled = true,
config = {
startTime: new Date().toISOString(),
finaliseRegardlessAfter: new Date(Date.now() + TIME_IN_MILLIS.YEAR).toISOString(),
},
) {
const {teamId} = await this.userRepository.getSelf();

if (!teamId) {
throw new Error('teamId of self user is undefined');
}

const response = await this.apiClient.api.teams.feature.putMLSMigrationFeature(teamId, {
config,
status: isEnabled ? FeatureStatus.ENABLED : FeatureStatus.DISABLED,
});

return response;
}

/** Used by QA test automation. */
triggerVersionCheck(baseVersion: string): Promise<string | void> {
return checkVersion(baseVersion);
Expand Down

0 comments on commit c232748

Please sign in to comment.