Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacper-RF committed Sep 27, 2023
2 parents 61a9437 + ee4fae8 commit 9ce135e
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 586 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

* Map messages sent before changing username

* Update registrar service to match new registration flow.

* Running Chromatic tests for forked PRs

[2.0.0-alpha.11]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { jest } from '@jest/globals'
import { LazyModuleLoader } from '@nestjs/core'
import { Test, TestingModule } from '@nestjs/testing'
import { getFactory, prepareStore, type Store, type communities, type identity } from '@quiet/state-manager'
import { type Community, type Identity, type InitCommunityPayload, type LaunchRegistrarPayload } from '@quiet/types'
import { type Community, type Identity, type InitCommunityPayload } from '@quiet/types'
import { type FactoryGirl } from 'factory-girl'
import PeerId from 'peer-id'
import { TestModule } from '../common/test.module'
Expand Down Expand Up @@ -108,10 +108,8 @@ describe('ConnectionsManagerService', () => {
await connectionsManagerService.closeAllServices()

const launchCommunitySpy = jest.spyOn(connectionsManagerService, 'launchCommunity').mockResolvedValue()
const launchRegistrarSpy = jest.spyOn(registrationService, 'launchRegistrar').mockResolvedValue()

await connectionsManagerService.init()
expect(launchRegistrarSpy).not.toHaveBeenCalled()
expect(launchCommunitySpy).toHaveBeenCalledWith(launchCommunityPayload)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ import {
NetworkStats,
PushNotificationPayload,
RegisterOwnerCertificatePayload,
RegisterUserCertificatePayload,
RemoveDownloadStatus,
ResponseCreateNetworkPayload,
SaveCertificatePayload,
SaveOwnerCertificatePayload,
SendCertificatesResponse,
SendMessagePayload,
SetChannelSubscribedPayload,
Expand All @@ -43,7 +40,6 @@ import {
UploadFilePayload,
PeerId as PeerIdType,
SaveCSRPayload,
SendUserCertificatePayload,
CommunityMetadata,
CommunityMetadataPayload,
} from '@quiet/types'
Expand Down Expand Up @@ -178,10 +174,6 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
if (this.tor && !options.saveTor) {
await this.tor.kill()
}
if (this.registrationService) {
this.logger('Stopping registration service')
await this.registrationService.stop()
}
if (this.storageService) {
this.logger('Stopping orbitdb')
await this.storageService?.stopOrbitDb()
Expand Down Expand Up @@ -395,22 +387,17 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
this.socketService.on(SocketActionTypes.CONNECTION_PROCESS_INFO, data => {
this.serverIoProvider.io.emit(SocketActionTypes.CONNECTION_PROCESS_INFO, data)
})

this.registrationService.on(SocketActionTypes.CONNECTION_PROCESS_INFO, data => {
this.serverIoProvider.io.emit(SocketActionTypes.CONNECTION_PROCESS_INFO, data)
})
}
private attachRegistrationListeners() {
this.registrationService.on(RegistrationEvents.REGISTRAR_STATE, (payload: ServiceState) => {
this.registrarState = payload
})
this.registrationService.on(SocketActionTypes.SAVED_OWNER_CERTIFICATE, payload => {
this.serverIoProvider.io.emit(SocketActionTypes.SAVED_OWNER_CERTIFICATE, payload)
})
// Not used atm
this.registrationService.on(RegistrationEvents.ERROR, payload => {
emitError(this.serverIoProvider.io, payload)
})
this.registrationService.on(RegistrationEvents.NEW_USER, async payload => {
console.log('conncetions manager payload ', payload)
await this.storageService?.saveCertificate(payload)
})
}
Expand Down Expand Up @@ -520,7 +507,6 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
})
this.storageService.on(StorageEvents.LOAD_CERTIFICATES, (payload: SendCertificatesResponse) => {
this.serverIoProvider.io.emit(SocketActionTypes.RESPONSE_GET_CERTIFICATES, payload)
this.registrationService.emit(RegistrationEvents.SET_CERTIFICATES, payload.certificates)
})
this.storageService.on(StorageEvents.LOAD_PUBLIC_CHANNELS, (payload: ChannelsReplicatedPayload) => {
this.serverIoProvider.io.emit(SocketActionTypes.CHANNELS_REPLICATED, payload)
Expand Down Expand Up @@ -575,11 +561,14 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
console.log('emitting deleted channel event back to state manager')
this.serverIoProvider.io.emit(SocketActionTypes.CHANNEL_DELETION_RESPONSE, payload)
})
this.storageService.on(StorageEvents.REPLICATED_CSR, async (payload: string[]) => {
console.log(`On ${StorageEvents.REPLICATED_CSR}`)
this.serverIoProvider.io.emit(SocketActionTypes.RESPONSE_GET_CSRS, { csrs: payload })
payload.forEach(csr => this.registrationService.emit(RegistrationEvents.REGISTER_USER_CERTIFICATE, csr))
})
this.storageService.on(
StorageEvents.REPLICATED_CSR,
async (payload: { csrs: string[]; certificates: string[] }) => {
console.log(`On ${StorageEvents.REPLICATED_CSR}`)
this.serverIoProvider.io.emit(SocketActionTypes.RESPONSE_GET_CSRS, { csrs: payload.csrs })
this.registrationService.emit(RegistrationEvents.REGISTER_USER_CERTIFICATE, payload)
}
)
this.storageService.on(StorageEvents.REPLICATED_COMMUNITY_METADATA, (payload: CommunityMetadata) => {
console.log(`On ${StorageEvents.REPLICATED_COMMUNITY_METADATA}: ${payload}`)
const communityMetadataPayload: CommunityMetadataPayload = {
Expand Down
Loading

0 comments on commit 9ce135e

Please sign in to comment.