Skip to content

Commit

Permalink
Merge pull request #1843 from TryQuiet/feature/1697
Browse files Browse the repository at this point in the history
feature/Users who request already-taken usernames should be invited to request a new username
  • Loading branch information
Kacper-RF authored Oct 9, 2023
2 parents 520fc30 + 9702f94 commit d3f835b
Show file tree
Hide file tree
Showing 65 changed files with 1,392 additions and 738 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@

[unreleased]

* UI layer for taken usernames for desktop and mobile

* Change nickname for taken username

* Map messages sent before changing username

* Update registrar service to match new registration flow.

* Add possible impersonation attack UI for desktop and mobile

* Fix truncated long messages in channelInput component
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 @@ -394,26 +386,11 @@ 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)
})
this.registrationService.on(RegistrationEvents.SPAWN_HS_FOR_REGISTRAR, async payload => {
const onionAddress = await this.tor.spawnHiddenService({
targetPort: payload.port,
privKey: payload.privateKey,
virtPort: payload.targetPort,
})
this.registrationService.onionAddress = onionAddress
})
this.registrationService.on(RegistrationEvents.ERROR, payload => {
emitError(this.serverIoProvider.io, payload)
})
Expand Down Expand Up @@ -527,7 +504,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 @@ -582,11 +558,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 d3f835b

Please sign in to comment.