1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Add thread relation in sendEvent if it's missing (#2149)

This commit is contained in:
Germain
2022-02-02 14:44:38 +00:00
committed by GitHub
parent 9c242a9ce6
commit 82122872bf

View File

@@ -3593,6 +3593,22 @@ export class MatrixClient extends EventEmitter {
eventType = threadId;
threadId = null;
}
if (threadId && content["m.relates_to"]?.rel_type !== RelationType.Thread) {
content["m.relates_to"] = {
...content["m.relates_to"],
"rel_type": RelationType.Thread,
"event_id": threadId,
};
const thread = this.getRoom(roomId)?.threads.get(threadId);
if (thread) {
content["m.relates_to"]["m.in_reply_to"] = {
"event_id": thread.replyToEvent.getId(),
};
}
}
return this.sendCompleteEvent(roomId, threadId, { type: eventType, content }, txnId as string, callback);
}
@@ -4213,17 +4229,6 @@ export class MatrixClient extends EventEmitter {
body: text,
};
const thread = this.getRoom(roomId)?.threads.get(threadId);
if (thread) {
content["m.relates_to"] = {
"rel_type": RelationType.Thread,
"event_id": threadId,
"m.in_reply_to": {
"event_id": thread.replyToEvent.getId(),
},
};
}
return this.sendEvent(roomId, threadId, EventType.Sticker, content, undefined, callback);
}