From 57eed10a389cc487fb9066b1f78b00b5cfdc0dbd Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Tue, 20 Dec 2022 12:29:17 -0800 Subject: [PATCH] Add "pni" capability in staging --- ts/background.ts | 2 ++ ts/textsecure/WebAPI.ts | 6 ++++++ ts/util/isPnpEnabled.ts | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 ts/util/isPnpEnabled.ts diff --git a/ts/background.ts b/ts/background.ts index 88ab29c0c..725bf726f 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -40,6 +40,7 @@ import { assertDev, strictAssert } from './util/assert'; import { normalizeUuid } from './util/normalizeUuid'; import { filter } from './util/iterables'; import { isNotNil } from './util/isNotNil'; +import { isPnpEnabled } from './util/isPnpEnabled'; import { setAppLoadingScreenMessage } from './setAppLoadingScreenMessage'; import { IdleDetector } from './IdleDetector'; import { expiringMessagesDeletionService } from './services/expiringMessagesDeletion'; @@ -2302,6 +2303,7 @@ export async function startApp(): Promise { senderKey: true, changeNumber: true, stories: true, + pni: isPnpEnabled(), }), updateOurUsernameAndPni(), ]); diff --git a/ts/textsecure/WebAPI.ts b/ts/textsecure/WebAPI.ts index a69e18407..dca72790d 100644 --- a/ts/textsecure/WebAPI.ts +++ b/ts/textsecure/WebAPI.ts @@ -27,6 +27,7 @@ import { getStreamWithTimeout } from '../util/getStreamWithTimeout'; import { formatAcceptLanguageHeader } from '../util/userLanguages'; import { toWebSafeBase64 } from '../util/webSafeBase64'; import { getBasicAuth } from '../util/getBasicAuth'; +import { isPnpEnabled } from '../util/isPnpEnabled'; import type { SocketStatus } from '../types/SocketStatus'; import { toLogFormat } from '../types/errors'; import { isPackIdValid, redactPackId } from '../types/Stickers'; @@ -612,6 +613,7 @@ export type CapabilitiesType = { senderKey: boolean; changeNumber: boolean; stories: boolean; + pni: boolean; }; export type CapabilitiesUploadType = { announcementGroup: true; @@ -620,6 +622,9 @@ export type CapabilitiesUploadType = { senderKey: true; changeNumber: true; stories: true; + + // true in staging, false in production + pni: boolean; }; type StickerPackManifestType = Uint8Array; @@ -1857,6 +1862,7 @@ export function initialize({ senderKey: true, changeNumber: true, stories: true, + pni: isPnpEnabled(), }; const jsonData = { diff --git a/ts/util/isPnpEnabled.ts b/ts/util/isPnpEnabled.ts new file mode 100644 index 000000000..e79569a52 --- /dev/null +++ b/ts/util/isPnpEnabled.ts @@ -0,0 +1,8 @@ +// Copyright 2022 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +import { isStaging } from './version'; + +export function isPnpEnabled(version = window.getVersion()): boolean { + return isStaging(version); +}