feat: use multi value to know if disappear_v2 is live or nah

pull/2971/head
Audric Ackermann 2 years ago
parent 1a53f699b4
commit 45e118ae1b

@ -1,4 +1,5 @@
import AbortController from 'abort-controller'; import AbortController from 'abort-controller';
import { getConversationController } from '../../../conversations';
import { OpenGroupRequestCommonType } from '../opengroupV2/ApiUtil'; import { OpenGroupRequestCommonType } from '../opengroupV2/ApiUtil';
import { getOpenGroupV2ConversationId } from '../utils/OpenGroupUtils'; import { getOpenGroupV2ConversationId } from '../utils/OpenGroupUtils';
import { import {
@ -7,7 +8,6 @@ import {
OpenGroupBatchRow, OpenGroupBatchRow,
sogsBatchSend, sogsBatchSend,
} from './sogsV3BatchPoll'; } from './sogsV3BatchPoll';
import { getConversationController } from '../../../conversations';
type OpenGroupClearInboxResponse = { type OpenGroupClearInboxResponse = {
deleted: number; deleted: number;
@ -21,42 +21,40 @@ export const clearInbox = async (roomInfos: OpenGroupRequestCommonType): Promise
if (!conversation) { if (!conversation) {
throw new Error(`clearInbox Matching conversation not found in db ${conversationId}`); throw new Error(`clearInbox Matching conversation not found in db ${conversationId}`);
} else { }
const options: Array<OpenGroupBatchRow> = [ const options: Array<OpenGroupBatchRow> = [
{ {
type: 'inbox', type: 'inbox',
inbox: { inbox: {
type: 'delete', type: 'delete',
},
}, },
]; },
];
const result = await sogsBatchSend( const result = await sogsBatchSend(
roomInfos.serverUrl, roomInfos.serverUrl,
new Set([roomInfos.roomId]), new Set([roomInfos.roomId]),
new AbortController().signal, new AbortController().signal,
options, options,
'batch' 'batch'
); );
if (!result) { if (!result) {
throw new Error(`Could not clearInbox, res is invalid for ${conversationId}`); throw new Error(`Could not clearInbox, res is invalid for ${conversationId}`);
} }
const rawMessage = const rawMessage = (result.body && (result.body[0].body as OpenGroupClearInboxResponse)) || null;
(result.body && (result.body[0].body as OpenGroupClearInboxResponse)) || null; if (!rawMessage) {
if (!rawMessage) { throw new Error(`clearInbox parsing failed for ${conversationId}`);
throw new Error(`clearInbox parsing failed for ${conversationId}`); }
}
try { try {
if (batchGlobalIsSuccess(result) && batchFirstSubIsSuccess(result)) { if (batchGlobalIsSuccess(result) && batchFirstSubIsSuccess(result)) {
success = true; success = true;
window.log.info(`clearInbox ${rawMessage.deleted} messages deleted for ${conversationId} `); window.log.info(`clearInbox ${rawMessage.deleted} messages deleted for ${conversationId} `);
}
} catch (e) {
window?.log?.error(`clearInbox Can't decode JSON body for ${conversationId}`);
} }
} catch (e) {
window?.log?.error(`clearInbox Can't decode JSON body for ${conversationId}`);
} }
if (!success) { if (!success) {

@ -1,4 +1,3 @@
import { isEmpty } from 'lodash';
import { GetNetworkTime } from '../session/apis/snode_api/getNetworkTime'; import { GetNetworkTime } from '../session/apis/snode_api/getNetworkTime';
import { FEATURE_RELEASE_TIMESTAMPS } from '../session/constants'; import { FEATURE_RELEASE_TIMESTAMPS } from '../session/constants';
import { ConfigurationSync } from '../session/utils/job_runners/jobs/ConfigurationSyncJob'; import { ConfigurationSync } from '../session/utils/job_runners/jobs/ConfigurationSyncJob';
@ -103,7 +102,7 @@ async function checkIsUserConfigFeatureReleased() {
async function checkIsDisappearMessageV2FeatureReleased() { async function checkIsDisappearMessageV2FeatureReleased() {
return ( return (
(await checkIsFeatureReleased('disappearing_messages')) || (await checkIsFeatureReleased('disappearing_messages')) ||
!isEmpty(process.env.SESSION_FORCE_DISAPPEAR_V2_ENABLED) // FIXME to remove after QA !!process.env.MULTI?.toLocaleLowerCase().includes('disappear_v2') // FIXME to remove after QA
); );
} }
@ -115,7 +114,7 @@ function isUserConfigFeatureReleasedCached(): boolean {
function isDisappearMessageV2FeatureReleasedCached(): boolean { function isDisappearMessageV2FeatureReleasedCached(): boolean {
return ( return (
!!isDisappearingMessageFeatureReleased || !!isDisappearingMessageFeatureReleased ||
!isEmpty(process.env.SESSION_FORCE_DISAPPEAR_V2_ENABLED) // FIXME to remove after QA !!process.env.MULTI?.toLocaleLowerCase().includes('disappear_v2') // FIXME to remove after QA
); );
} }

Loading…
Cancel
Save