Fix replying using chat effect commands (#9101)

pull/28788/head^2
Michael Telatynski 2022-07-27 11:03:25 +01:00 committed by GitHub
parent c0d69e1d30
commit a2c5a59b22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 17 deletions

View File

@ -1305,19 +1305,17 @@ export const Commands = [
description: effect.description(), description: effect.description(),
args: '<message>', args: '<message>',
runFn: function(roomId, args) { runFn: function(roomId, args) {
return success((async () => { let content: IContent;
if (!args) { if (!args) {
args = effect.fallbackMessage(); content = ContentHelpers.makeEmoteMessage(effect.fallbackMessage());
MatrixClientPeg.get().sendEmoteMessage(roomId, args); } else {
} else { content = {
const content = { msgtype: effect.msgType,
msgtype: effect.msgType, body: args,
body: args, };
}; }
MatrixClientPeg.get().sendMessage(roomId, content); dis.dispatch({ action: `effects.${effect.command}` });
} return successSync(content);
dis.dispatch({ action: `effects.${effect.command}` });
})());
}, },
category: CommandCategories.effects, category: CommandCategories.effects,
renderingTypes: [TimelineRenderingType.Room], renderingTypes: [TimelineRenderingType.Room],

View File

@ -337,7 +337,7 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
return; // errored return; // errored
} }
if (cmd.category === CommandCategories.messages) { if (cmd.category === CommandCategories.messages || cmd.category === CommandCategories.effects) {
editContent["m.new_content"] = content; editContent["m.new_content"] = content;
} else { } else {
shouldSend = false; shouldSend = false;

View File

@ -358,12 +358,13 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
return; // errored return; // errored
} }
if (cmd.category === CommandCategories.messages) { if (cmd.category === CommandCategories.messages || cmd.category === CommandCategories.effects) {
attachRelation(content, this.props.relation); attachRelation(content, this.props.relation);
if (replyToEvent) { if (replyToEvent) {
addReplyToMessageContent(content, replyToEvent, { addReplyToMessageContent(content, replyToEvent, {
permalinkCreator: this.props.permalinkCreator, permalinkCreator: this.props.permalinkCreator,
includeLegacyFallback: true, // Exclude the legacy fallback for custom event types such as those used by /fireworks
includeLegacyFallback: content.msgtype?.startsWith("m.") ?? true,
}); });
} }
} else { } else {

View File

@ -65,7 +65,7 @@ export async function runSlashCommand(
let error = result.error; let error = result.error;
if (result.promise) { if (result.promise) {
try { try {
if (cmd.category === CommandCategories.messages) { if (cmd.category === CommandCategories.messages || cmd.category === CommandCategories.effects) {
messageContent = await result.promise; messageContent = await result.promise;
} else { } else {
await result.promise; await result.promise;