d->m: Fix conversion of PK replies to Discord user
This commit is contained in:
parent
d673296619
commit
13d1f86d31
3 changed files with 78 additions and 5 deletions
|
@ -261,10 +261,14 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||
we generate a partial referenced_message based on what PK provided. we don't need everything, since this will only be used for further message-to-event converting.
|
||||
the following properties are necessary:
|
||||
- content: used for generating the reply fallback
|
||||
- author: used for the top of the reply fallback (only used for discord authors. for matrix authors, repliedToEventSenderMxid is set.)
|
||||
*/
|
||||
// @ts-ignore
|
||||
message.referenced_message = {
|
||||
content: message.embeds[0].description.replace(/^.*?\)\*\*\s*/, "")
|
||||
content: message.embeds[0].description.replace(/^.*?\)\*\*\s*/, ""),
|
||||
// @ts-ignore
|
||||
author: {
|
||||
username: message.embeds[0].author.name.replace(/\s*↩️\s*$/, "")
|
||||
}
|
||||
}
|
||||
message.embeds.shift()
|
||||
repliedToEventRow = row
|
||||
|
|
|
@ -29,8 +29,8 @@ function mockGetEvent(t, roomID_in, eventID_in, outer) {
|
|||
}
|
||||
}
|
||||
|
||||
test("message2event: pk reply is converted to native matrix reply", async t => {
|
||||
const events = await messageToEvent(data.pk_message.pk_reply, {}, {}, {
|
||||
test("message2event: pk reply to matrix is converted to native matrix reply", async t => {
|
||||
const events = await messageToEvent(data.pk_message.pk_reply_to_matrix, {}, {}, {
|
||||
api: {
|
||||
getEvent: mockGetEvent(t, "!TqlyQmifxGUggEmdBN:cadence.moe", "$NB6nPgO2tfXyIwwDSF0Ga0BUrsgX1S-0Xl-jAvI8ucU", {
|
||||
type: "m.room.message",
|
||||
|
@ -62,3 +62,33 @@ test("message2event: pk reply is converted to native matrix reply", async t => {
|
|||
}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event: pk reply to discord is converted to native matrix reply", async t => {
|
||||
const events = await messageToEvent(data.pk_message.pk_reply_to_discord, {}, {}, {
|
||||
api: {
|
||||
getEvent: mockGetEvent(t, "!TqlyQmifxGUggEmdBN:cadence.moe", "$NB6nPgO2tfXyIwwDSF0Ga0BUrsgX1S-0Xl-jAvI8ucU", {
|
||||
type: "m.room.message",
|
||||
sender: "@_ooye_.wing.:cadence.moe",
|
||||
content: {
|
||||
msgtype: "m.text",
|
||||
body: "some text"
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
"m.mentions": {},
|
||||
body: "> wing: some text\n\nthis is a reply",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: '<mx-reply><blockquote><a href="https://matrix.to/#/!kLRqKKUQXcibIMtOpl:cadence.moe/$mtR8cJqM4fKno1bVsm8F4wUVqSntt2sq6jav1lyavuA">In reply to</a> wing<br>'
|
||||
+ "some text</blockquote></mx-reply>"
|
||||
+ "this is a reply",
|
||||
"m.relates_to": {
|
||||
"m.in_reply_to": {
|
||||
event_id: "$mtR8cJqM4fKno1bVsm8F4wUVqSntt2sq6jav1lyavuA"
|
||||
}
|
||||
}
|
||||
}])
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue