fix up some reply weirdness

This commit is contained in:
Ashley 2024-08-27 15:18:30 +00:00
parent 9291d930b4
commit 44aafaa0b7
2 changed files with 3 additions and 9 deletions

View file

@ -106,7 +106,7 @@ client.on(sdk.RoomEvent.Timeline, async function (event, room, toStartOfTimeline
var content = event.getContent();
if(content["m.relates_to"] != null)
if(content["m.relates_to"] !== undefined)
content.body = content.body.substring(content.body.indexOf("\n\n") + 2);
event.sender = client.getRoom(event.sender.roomId).getMember(event.getSender());

View file

@ -26,6 +26,8 @@ export default function(client) {
var content = event.getContent();
var mcontent = {
format: "org.matrix.custom.html",
formatted_body: "<mx-reply><blockquote><a href=\"https://m.posm.gay/#/" + event.event.room_id + "/" + event.event.event_id + "?via=possum.city\">In reply to</a> <a href=\"https://m.posm.gay/#/" + event.sender.userId + "\">" + event.sender.userId + "</a><br>" + (content.formatted_body ?? content.body) + "</blockquote></mx-reply>" + (html ?? text).trim(),
body: "> <" + event.sender.userId + "> " + content.body.split("\n")[0] + "\n\n" + text.trim(),
msgtype: "m.notice",
"m.relates_to": {
@ -35,14 +37,6 @@ export default function(client) {
}
};
if(html) {
mcontent = {
format: "org.matrix.custom.html",
formatted_body: "<mx-reply><blockquote><a href=\"https://m.posm.gay/#/" + event.event.room_id + "/" + event.event.event_id + "?via=possum.city\">In reply to</a> <a href=\"https://m.posm.gay/#/" + event.sender.userId + "\">" + event.sender.userId + "</a><br>" + encode(content.body.split("\n")[0]) + "</blockquote></mx-reply>" + html.trim(),
...mcontent
}
}
client.sendEvent(event.event.room_id, "m.room.message", mcontent, "", (err, res) => {
console.log(err);
});