diff --git a/ts/node/sql.ts b/ts/node/sql.ts index 9db6cde5f..7eaf91e25 100644 --- a/ts/node/sql.ts +++ b/ts/node/sql.ts @@ -1979,6 +1979,7 @@ function getConversationCount() { } // tslint:disable-next-line: max-func-body-length +// tslint:disable-next-line: cyclomatic-complexity function saveConversation(data: ConversationAttributes, instance?: BetterSqlite3.Database) { const formatted = assertValidConversationAttributes(data); @@ -2107,9 +2108,9 @@ function saveConversation(data: ConversationAttributes, instance?: BetterSqlite3 groupAdmins: groupAdmins && groupAdmins.length ? arrayStrToJson(groupAdmins) : '[]', isKickedFromGroup: toSqliteBoolean(isKickedFromGroup), subscriberCount, - readCapability, - writeCapability, - uploadCapability, + readCapability: toSqliteBoolean(readCapability), + writeCapability: toSqliteBoolean(writeCapability), + uploadCapability: toSqliteBoolean(uploadCapability), is_medium_group: toSqliteBoolean(is_medium_group), avatarPointer, diff --git a/ts/session/apis/open_group_api/opengroupV2/OpenGroupServerPoller.ts b/ts/session/apis/open_group_api/opengroupV2/OpenGroupServerPoller.ts index caf66b7e9..b0ab20786 100644 --- a/ts/session/apis/open_group_api/opengroupV2/OpenGroupServerPoller.ts +++ b/ts/session/apis/open_group_api/opengroupV2/OpenGroupServerPoller.ts @@ -34,6 +34,9 @@ export type OpenGroupMessageV4 = { const pollForEverythingInterval = DURATION.SECONDS * 10; +export const invalidAuthRequiresBlinding = + 'Invalid authentication: this server requires the use of blinded ids'; + /** * An OpenGroupServerPollerV2 polls for everything for a particular server. We should * have only have one OpenGroupServerPollerV2 per opengroup polling. @@ -295,9 +298,7 @@ export class OpenGroupServerPoller { ) { const bodyPlainText = (batchPollResults.body as any).plainText; // this is temporary (as of 27/06/2022) as we want to not support unblinded sogs after some time - if ( - bodyPlainText === 'Invalid authentication: this server requires the use of blinded ids' - ) { + if (bodyPlainText === invalidAuthRequiresBlinding) { await fetchCapabilitiesAndUpdateRelatedRoomsOfServerUrl(this.serverUrl); throw new Error('batchPollResults just detected switch to blinded enforced.'); } diff --git a/ts/session/onions/onionSend.ts b/ts/session/onions/onionSend.ts index 4914296f1..88925dc93 100644 --- a/ts/session/onions/onionSend.ts +++ b/ts/session/onions/onionSend.ts @@ -21,6 +21,7 @@ import { import { AbortSignal } from 'abort-controller'; import { pnServerPubkeyHex, pnServerUrl } from '../apis/push_notification_api/PnServer'; import { fileServerPubKey, fileServerURL } from '../apis/file_server_api/FileServerApi'; +import { invalidAuthRequiresBlinding } from '../apis/open_group_api/opengroupV2/OpenGroupServerPoller'; export type OnionFetchOptions = { method: string; @@ -162,6 +163,18 @@ const sendViaOnionV4ToNonSnodeWithRetries = async ( // the pn server replies with the decodedV4?.metadata as any)?.code syntax too since onion v4 const foundStatusCode = decodedV4?.metadata?.code || STATUS_NO_STATUS; if (foundStatusCode < 200 || foundStatusCode > 299) { + // this is temporary (as of 27/06/2022) as we want to not support unblinded sogs after some time + + if ( + foundStatusCode === 400 && + (decodedV4?.body as any).plainText === invalidAuthRequiresBlinding + ) { + return { + status_code: foundStatusCode, + body: decodedV4?.body || null, + bodyBinary: decodedV4?.bodyBinary || null, + }; + } // we consider those cases as an error, and trigger a retry (if possible), by throwing a non-abortable error throw new Error( `sendViaOnionV4ToNonSnodeWithRetries failed with status code: ${foundStatusCode}. Retrying...`