mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00
Improve deduplication script
This commit is contained in:
parent
b6e37947bd
commit
23e00319ff
@ -44,7 +44,7 @@ export class ConnectionManager {
|
||||
public push(...connections: IConnection[]) {
|
||||
// NOTE: Double loop
|
||||
for (const connection of connections) {
|
||||
if (!this.connections.find((c) => c === connection)) {
|
||||
if (!this.connections.find(c => c.connectionId === connection.connectionId)) {
|
||||
this.connections.push(connection);
|
||||
}
|
||||
}
|
||||
@ -204,7 +204,7 @@ export class ConnectionManager {
|
||||
const connections: IConnection[] = [];
|
||||
for (const event of state) {
|
||||
const conn = await this.createConnectionForState(roomId, new StateEvent(event));
|
||||
if (conn) { connections.push(conn); }
|
||||
if (conn) { this.push(conn); }
|
||||
}
|
||||
return connections;
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ export abstract class BaseConnection {
|
||||
}
|
||||
|
||||
public get connectionId(): string {
|
||||
return FormatUtil.hashId(`${this.canonicalStateType}/${this.stateKey}`);
|
||||
return FormatUtil.hashId(`${this.roomId}/${this.canonicalStateType}/${this.stateKey}`);
|
||||
}
|
||||
}
|
@ -3,8 +3,14 @@ import { IssuesOpenedEvent, IssuesEditedEvent } from "@octokit/webhooks-types";
|
||||
import { GetConnectionsResponseItem } from "../provisioning/api";
|
||||
|
||||
export interface IConnection {
|
||||
/**
|
||||
* The roomId that this connection serves.
|
||||
*/
|
||||
roomId: string;
|
||||
|
||||
/**
|
||||
* The unique connection ID. This is a opaque hash of the roomId, connection type and state key.
|
||||
*/
|
||||
get connectionId(): string;
|
||||
/**
|
||||
* When a room gets an update to it's state.
|
||||
|
Loading…
x
Reference in New Issue
Block a user