Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IrcBridge.memberListSyncers: Object -> Map #1610

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1610.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IrcBridge.memberListSyncers: Object -> Map.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be much more descriptive :). Needs to identify the change from the end user perspective.

23 changes: 11 additions & 12 deletions src/bridge/IrcBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class IrcBridge {
public readonly matrixBanSyncer?: MatrixBanSync;
private clientPool!: ClientPool; // This gets defined in the `run` function
private ircServers: IrcServer[] = [];
private memberListSyncers: {[domain: string]: MemberListSyncer} = {};
private memberListSyncers: Map<string, MemberListSyncer> = new Map();
private joinedRoomList: string[] = [];
private dataStore!: DataStore;
private bridgeState: "not-started"|"running"|"killed" = "not-started";
Expand Down Expand Up @@ -482,16 +482,16 @@ export class IrcBridge {
});
}

Object.keys(this.memberListSyncers).forEach((server) => {
for (const [server, memberListSyncer] of this.memberListSyncers) {
memberListLeaveQueue.set(
{server},
this.memberListSyncers[server].getUsersWaitingToLeave()
memberListSyncer.getUsersWaitingToLeave()
);
memberListJoinQueue.set(
{server},
this.memberListSyncers[server].getUsersWaitingToJoin()
memberListSyncer.getUsersWaitingToJoin()
);
});
}
ircBlockedRooms.set(this.privacyProtection.blockedRoomCount);
const ircMetrics = this.ircHandler.getMetrics();
Object.entries(ircMetrics).forEach((kv) => {
Expand Down Expand Up @@ -744,7 +744,7 @@ export class IrcBridge {

// TODO reduce deps required to make MemberListSyncers.
// TODO Remove injectJoinFn bodge
this.memberListSyncers[server.domain] = new MemberListSyncer(
const memberListSyncer = new MemberListSyncer(
this, this.membershipQueue, this.bridge.getBot(), server, this.appServiceUserId,
(roomId: string, joiningUserId: string, displayName: string, isFrontier: boolean) => {
const req = new BridgeRequest(
Expand All @@ -767,9 +767,8 @@ export class IrcBridge {
}, target);
}
);
memberlistPromises.push(
this.memberListSyncers[server.domain].sync()
);
this.memberListSyncers.set(server.domain, memberListSyncer);
memberlistPromises.push(memberListSyncer.sync());
});

const provisioningEnabled = this.config.ircService.provisioning.enabled;
Expand Down Expand Up @@ -1304,8 +1303,8 @@ export class IrcBridge {
return this.ircServers || [];
}

public getMemberListSyncer(server: IrcServer) {
return this.memberListSyncers[server.domain];
public getMemberListSyncer(server: IrcServer): MemberListSyncer | undefined {
return this.memberListSyncers.get(server.domain);
}

// TODO: Check how many of the below functions need to reside on IrcBridge still.
Expand Down Expand Up @@ -1477,7 +1476,7 @@ export class IrcBridge {
log.info(
`Leaving ${roomInfo.remoteJoinedUsers.length} users from old room ${oldRoomId}.`
);
this.memberListSyncers[room.getServer().domain].addToLeavePool(
this.memberListSyncers.get(room.getServer().domain).addToLeavePool(
roomInfo.remoteJoinedUsers,
oldRoomId,
);
Expand Down