Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Discord to Matrix replies #878

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,21 @@ export class DiscordBot {
formatted_body: result.formattedBody,
msgtype: result.msgtype,
};
let relatesTo: any = null;
if (msg.reference) {
const storeEvent = await this.store.Get(DbEvent, {discord_id: msg.reference?.messageID})
if (storeEvent && storeEvent.Result)
{
while(storeEvent.Next())
{
relatesTo = {
"m.in_reply_to": {
event_id: storeEvent.MatrixId.split(";")[0]
}
};
}
}
}
if (editEventId) {
sendContent.body = `* ${result.body}`;
sendContent.formatted_body = `* ${result.formattedBody}`;
Expand All @@ -1116,12 +1131,13 @@ export class DiscordBot {
formatted_body: result.formattedBody,
msgtype: result.msgtype,
};
sendContent["m.relates_to"] = {
event_id: editEventId,
rel_type: "m.replace",
};
if (relatesTo === null) relatesTo = {}
relatesTo.event_id = editEventId;
relatesTo.rel_type = "m.replace";
}
const trySend = async () => intent.sendEvent(room, sendContent);
if (relatesTo !== null) sendContent["m.relates_to"] = relatesTo;

const trySend = async () => intent.sendEvent(room, sendContent);
const afterSend = async (eventId) => {
this.lastEventIds[room] = eventId;
const evt = new DbEvent();
Expand Down