fix up some reply weirdness
This commit is contained in:
parent
9291d930b4
commit
44aafaa0b7
2 changed files with 3 additions and 9 deletions
2
index.js
2
index.js
|
@ -106,7 +106,7 @@ client.on(sdk.RoomEvent.Timeline, async function (event, room, toStartOfTimeline
|
||||||
|
|
||||||
var content = event.getContent();
|
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);
|
content.body = content.body.substring(content.body.indexOf("\n\n") + 2);
|
||||||
|
|
||||||
event.sender = client.getRoom(event.sender.roomId).getMember(event.getSender());
|
event.sender = client.getRoom(event.sender.roomId).getMember(event.getSender());
|
||||||
|
|
10
lib/ext.js
10
lib/ext.js
|
@ -26,6 +26,8 @@ export default function(client) {
|
||||||
var content = event.getContent();
|
var content = event.getContent();
|
||||||
|
|
||||||
var mcontent = {
|
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(),
|
body: "> <" + event.sender.userId + "> " + content.body.split("\n")[0] + "\n\n" + text.trim(),
|
||||||
msgtype: "m.notice",
|
msgtype: "m.notice",
|
||||||
"m.relates_to": {
|
"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) => {
|
client.sendEvent(event.event.room_id, "m.room.message", mcontent, "", (err, res) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue