Skip to content

Commit

Permalink
Backwards compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
islathehut committed Dec 5, 2024
1 parent 97e54d3 commit 936bd2a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getLibp2pAddressesFromCsrs, removeFilesFromDir } from '../common/utils'

import { LazyModuleLoader } from '@nestjs/core'
import { createLibp2pAddress, filterValidAddresses, isPSKcodeValid } from '@quiet/common'
import { CertFieldsTypes, createRootCA, getCertFieldValue, loadCertificate } from '@quiet/identity'
import { CertFieldsTypes, getCertFieldValue, loadCertificate } from '@quiet/identity'
import {
ChannelMessageIdsResponse,
ChannelSubscribedPayload,
Expand All @@ -28,8 +28,6 @@ import {
FileMetadata,
GetMessagesPayload,
InitCommunityPayload,
InvitationDataV2,
InvitationDataVersion,
MessagesLoadedPayload,
NetworkDataPayload,
NetworkInfo,
Expand Down Expand Up @@ -62,7 +60,6 @@ import { SocketService } from '../socket/socket.service'
import { StorageService } from '../storage/storage.service'
import { StorageEvents } from '../storage/storage.types'
import { StorageServiceClient } from '../storageServiceClient/storageServiceClient.service'
import { ServerStoredCommunityMetadata } from '../storageServiceClient/storageServiceClient.types'
import { Tor } from '../tor/tor.service'
import { ConfigOptions, GetPorts, ServerIoProviderTypes } from '../types'
import { ServiceState, TorInitState } from './connections-manager.types'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,18 @@ export function* customProtocolSaga(

let isJoiningAnotherCommunity = false

let storedPsk: string | undefined = undefined
let currentPsk: string | undefined = undefined
switch (data.version) {
case InvitationDataVersion.v1:
const storedPsk = yield* select(communities.selectors.psk)
const currentPsk = data.psk
storedPsk = yield* select(communities.selectors.psk)
currentPsk = data.psk
isJoiningAnotherCommunity = Boolean(storedPsk && storedPsk !== currentPsk)
break
case InvitationDataVersion.v2:
const inviteData = yield* select(communities.selectors.inviteData)
isJoiningAnotherCommunity = Boolean(inviteData && !_.isEqual(inviteData, data))
case InvitationDataVersion.v2: // Question: should we also check if the sig chain team name is different or something? is the psk enough?
storedPsk = yield* select(communities.selectors.psk)
currentPsk = data.psk
isJoiningAnotherCommunity = Boolean(storedPsk && storedPsk !== currentPsk)
break
}

Expand Down
13 changes: 8 additions & 5 deletions packages/mobile/src/store/init/deepLink/deepLink.saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,18 @@ export function* deepLinkSaga(action: PayloadAction<ReturnType<typeof initAction

let isJoiningAnotherCommunity = false

let storedPsk: string | undefined = undefined
let currentPsk: string | undefined = undefined
switch (data.version) {
case InvitationDataVersion.v1:
const storedPsk = yield* select(communities.selectors.psk)
const currentPsk = data.psk
storedPsk = yield* select(communities.selectors.psk)
currentPsk = data.psk
isJoiningAnotherCommunity = Boolean(storedPsk && storedPsk !== currentPsk)
break
case InvitationDataVersion.v2:
const inviteData = yield* select(communities.selectors.inviteData)
isJoiningAnotherCommunity = Boolean(inviteData && !_.isEqual(inviteData, data))
case InvitationDataVersion.v2: // Question: should we also check if the sig chain team name is different or something? is the psk enough?
storedPsk = yield* select(communities.selectors.psk)
currentPsk = data.psk
isJoiningAnotherCommunity = Boolean(storedPsk && storedPsk !== currentPsk)
break
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export function* createNetworkSaga(

if (payload.inviteData) {
switch (payload.inviteData.version) {
case InvitationDataVersion.v2: // TODO: update to have actual logic https://github.com/TryQuiet/quiet/issues/2628
case InvitationDataVersion.v1:
community.psk = payload.inviteData.psk
community.ownerOrbitDbIdentity = payload.inviteData.ownerOrbitDbIdentity
Expand Down

0 comments on commit 936bd2a

Please sign in to comment.