Merge pull request #5488 from matrix-org/travis/chat-effects-widgets

Run chat effects on events sent by widgets too
pull/21833/head
Travis Ralston 2020-12-11 21:52:24 -07:00 committed by GitHub
commit b870de14ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -40,6 +40,9 @@ import { WidgetPermissionCustomisations } from "../../customisations/WidgetPermi
import { OIDCState, WidgetPermissionStore } from "./WidgetPermissionStore"; import { OIDCState, WidgetPermissionStore } from "./WidgetPermissionStore";
import { WidgetType } from "../../widgets/WidgetType"; import { WidgetType } from "../../widgets/WidgetType";
import { EventType } from "matrix-js-sdk/src/@types/event"; import { EventType } from "matrix-js-sdk/src/@types/event";
import { CHAT_EFFECTS } from "../../effects";
import { containsEmoji } from "../../effects/utils";
import dis from "../../dispatcher/dispatcher";
// TODO: Purge this from the universe // TODO: Purge this from the universe
@ -123,6 +126,14 @@ export class StopGapWidgetDriver extends WidgetDriver {
} else { } else {
// message event // message event
r = await client.sendEvent(roomId, eventType, content); r = await client.sendEvent(roomId, eventType, content);
if (eventType === EventType.RoomMessage) {
CHAT_EFFECTS.forEach((effect) => {
if (containsEmoji(content, effect.emojis)) {
dis.dispatch({action: `effects.${effect.command}`});
}
});
}
} }
return {roomId, eventId: r.event_id}; return {roomId, eventId: r.event_id};