mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00

* Fix generic webhook 'user is already in the room error' * Add changelog * Cleanup to support usecases without slamming the homeserver. * Fix fallthrough * Add some tests * Add tests for intentutils * Refactor the rest of the app Co-authored-by: Half-Shot <will@half-shot.uk>
30 lines
820 B
TypeScript
30 lines
820 B
TypeScript
import { IntentMock } from "./IntentMock";
|
|
|
|
export class AppserviceMock {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
public readonly intentMap = new Map<string, any>();
|
|
public readonly botIntent = IntentMock.create(`@bot:example.com`);
|
|
static create(){
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
return new this() as any;
|
|
}
|
|
|
|
get botUserId() {
|
|
return this.botIntent.userId;
|
|
}
|
|
|
|
get botClient() {
|
|
return this.botIntent.underlyingClient;
|
|
}
|
|
|
|
public getIntentForUserId(userId: string) {
|
|
let intent = this.intentMap.get(userId);
|
|
if (intent) {
|
|
return intent;
|
|
}
|
|
intent = IntentMock.create(userId);
|
|
this.intentMap.set(userId, intent);
|
|
return intent;
|
|
}
|
|
}
|