Fix not logging connection created messages

This commit is contained in:
Half-Shot 2022-02-17 13:17:26 +00:00
parent fd21998486
commit 1795b86e7b
2 changed files with 5 additions and 13 deletions

View File

@ -517,18 +517,12 @@ export class Bridge {
await Promise.all(joinedRooms.map(async (roomId) => {
log.debug("Fetching state for " + roomId);
let connections: IConnection[];
try {
connections = await connManager.createConnectionsForRoomId(roomId);
await connManager.createConnectionsForRoomId(roomId);
} catch (ex) {
log.error(`Unable to create connection for ${roomId}`, ex);
return;
}
if (connections.length) {
log.info(`Room ${roomId} is connected to: ${connections.join(',')}`);
connManager.push(...connections);
return;
}
// TODO: Refactor this to be a connection
try {
@ -720,8 +714,7 @@ export class Bridge {
// Only fetch rooms we have no connections in yet.
if (!this.connectionManager.isRoomConnected(roomId)) {
const connections = await this.connectionManager.createConnectionsForRoomId(roomId);
this.connectionManager.push(...connections);
await this.connectionManager.createConnectionsForRoomId(roomId);
}
}

View File

@ -260,18 +260,17 @@ export class ConnectionManager {
return;
}
public async createConnectionsForRoomId(roomId: string): Promise<IConnection[]> {
public async createConnectionsForRoomId(roomId: string) {
const state = await this.as.botClient.getRoomState(roomId);
const connections: IConnection[] = [];
for (const event of state) {
try {
const conn = await this.createConnectionForState(roomId, new StateEvent(event));
if (conn) { this.push(conn); }
log.info(`Room ${roomId} is connected to: ${conn}`);
if (conn) { this.push(conn); }
} catch (ex) {
log.warn(`Failed to create connection for ${roomId}:`, ex);
}
}
return connections;
}
public getConnectionsForGithubIssue(org: string, repo: string, issueNumber: number): (GitHubIssueConnection|GitHubRepoConnection)[] {