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

View File

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