Skip to content

Commit

Permalink
Remove SET_COMMUNITY_CA_DATA
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Leblow committed Apr 4, 2024
1 parent 3c08bcc commit 003cfa1
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,15 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
// service for now. Both object construction and object
// initialization need to happen in order based on dependencies.
await this.registrationService.init(this.storageService)
this.logger('storage initialized')

if (community.CA) {
this.registrationService.setPermsData({
certificate: community.CA.rootCertString,
privKey: community.CA.rootKeyString,
})
}

this.logger('Storage initialized')

this.serverIoProvider.io.emit(
SocketActionTypes.CONNECTION_PROCESS_INFO,
Expand All @@ -570,7 +578,6 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
this.socketService.on(SocketActionTypes.CONNECTION, async () => {
// Update Frontend with Initialized Communities
if (this.communityId) {
console.log('Hunting for heisenbug: Backend initialized community and sent event to state manager')
this.serverIoProvider.io.emit(SocketActionTypes.COMMUNITY_LAUNCHED, { id: this.communityId })
console.log('this.libp2pService.connectedPeers', this.libp2pService.connectedPeers)
console.log('this.libp2pservice', this.libp2pService)
Expand Down Expand Up @@ -615,13 +622,6 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
this.logger(`socketService - ${SocketActionTypes.ADD_CSR}`)
await this.storageService?.saveCSR(payload)
})
// TODO: With the Community model on the backend, there is no need to call
// SET_COMMUNITY_CA_DATA anymore. We can call setPermsData when
// creating the community.
this.socketService.on(SocketActionTypes.SET_COMMUNITY_CA_DATA, async (payload: PermsData) => {
this.logger(`socketService - ${SocketActionTypes.SET_COMMUNITY_CA_DATA}`)
this.registrationService.setPermsData(payload)
})

// Public Channels
this.socketService.on(
Expand Down
4 changes: 0 additions & 4 deletions packages/backend/src/nest/socket/socket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ export class SocketService extends EventEmitter implements OnModuleInit {
this.emit(SocketActionTypes.LIBP2P_PSK_STORED, payload)
})

socket.on(SocketActionTypes.SET_COMMUNITY_CA_DATA, (payload: PermsData) => {
this.emit(SocketActionTypes.SET_COMMUNITY_CA_DATA, payload)
})

// ====== Users ======

socket.on(SocketActionTypes.SET_USER_PROFILE, (profile: UserProfile) => {
Expand Down
1 change: 0 additions & 1 deletion packages/desktop/src/rtl-tests/community.create.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ describe('User', () => {
"Modals/openModal",
"Identity/registerCertificate",
"Communities/createCommunity",
"Communities/sendCommunityCaData",
"Files/checkForMissingFiles",
"Network/addInitializedCommunity",
"Communities/clearInvitationCodes",
Expand Down
1 change: 0 additions & 1 deletion packages/desktop/src/rtl-tests/community.join.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ describe('User', () => {
"Modals/openModal",
"Identity/registerCertificate",
"Communities/launchCommunity",
"Communities/sendCommunityCaData",
"Files/checkForMissingFiles",
"Network/addInitializedCommunity",
"Communities/clearInvitationCodes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import { connectionActions } from '../appConnection/connection.slice'
import { createCommunitySaga } from './createCommunity/createCommunity.saga'
import { initCommunities, launchCommunitySaga } from './launchCommunity/launchCommunity.saga'
import { createNetworkSaga } from './createNetwork/createNetwork.saga'
import { sendCommunityCaDataSaga } from './sendCommunityCaData/sendCommunityCaData.saga'

export function* communitiesMasterSaga(socket: Socket): Generator {
yield all([
takeEvery(communitiesActions.createNetwork.type, createNetworkSaga, socket),
takeEvery(connectionActions.torBootstrapped.type, initCommunities),
takeEvery(communitiesActions.createCommunity.type, createCommunitySaga, socket),
takeEvery(communitiesActions.launchCommunity.type, launchCommunitySaga, socket),
takeEvery(communitiesActions.sendCommunityCaData.type, sendCommunityCaDataSaga, socket),
])
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const communitiesSlice = createSlice({
},
})
},
sendCommunityCaData: state => state,
createNetwork: (state, _action: PayloadAction<CreateNetworkPayload>) => state,
resetApp: (state, _action) => state,
createCommunity: (state, _action: PayloadAction<string>) => state,
Expand Down

This file was deleted.

5 changes: 0 additions & 5 deletions packages/state-manager/src/sagas/identity/identity.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ export interface RegisterUserCertificatePayload {
serviceAddress: string
}

export interface PermsData {
certificate: string
privKey: string
}

export interface RegisterOwnerCertificatePayload {
communityId: string
userCsr: UserCsr
Expand Down
1 change: 0 additions & 1 deletion packages/state-manager/src/sagas/network/network.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const networkSlice = createSlice({
name: StoreKeys.Network,
reducers: {
addInitializedCommunity: (state, action: PayloadAction<CommunityId>) => {
console.log('Hunting for heisenbug: adding initialized community ', action.payload)
state.initializedCommunities = {
...state.initializedCommunities,
[action.payload]: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export function subscribe(socket: Socket) {
| ReturnType<typeof communitiesActions.clearInvitationCodes>
| ReturnType<typeof identityActions.saveUserCsr>
| ReturnType<typeof connectionActions.setTorInitialized>
| ReturnType<typeof communitiesActions.sendCommunityCaData>
| ReturnType<typeof usersActions.setUserProfiles>
| ReturnType<typeof appActions.loadMigrationData>
>(emit => {
Expand Down Expand Up @@ -139,10 +138,6 @@ export function subscribe(socket: Socket) {
// Community

socket.on(SocketActionTypes.COMMUNITY_LAUNCHED, (payload: ResponseLaunchCommunityPayload) => {
console.log('Hunting for heisenbug: Community event received in state-manager')
// TODO: We can send this once when creating the community and
// store it in the backend.
emit(communitiesActions.sendCommunityCaData())
emit(filesActions.checkForMissingFiles(payload.id))
emit(networkActions.addInitializedCommunity(payload.id))
emit(communitiesActions.clearInvitationCodes())
Expand Down
1 change: 0 additions & 1 deletion packages/state-manager/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export interface EmitEvents {
[SocketActionTypes.LEAVE_COMMUNITY]: () => void
[SocketActionTypes.CREATE_NETWORK]: EmitEvent<string, (response: NetworkInfo | undefined) => void>
[SocketActionTypes.ADD_CSR]: EmitEvent<SaveCSRPayload>
[SocketActionTypes.SET_COMMUNITY_CA_DATA]: EmitEvent<PermsData>
[SocketActionTypes.SET_USER_PROFILE]: EmitEvent<UserProfile>
[SocketActionTypes.LOAD_MIGRATION_DATA]: EmitEvent<Record<string, any>>
}
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export enum SocketActionTypes {
CREATE_COMMUNITY = 'createCommunity',
LAUNCH_COMMUNITY = 'launchCommunity',
LEAVE_COMMUNITY = 'leaveCommunity',
SET_COMMUNITY_CA_DATA = 'setCommunityCaData',

// ====== Channels ======

Expand Down

0 comments on commit 003cfa1

Please sign in to comment.