diff --git a/m2d/converters/event-to-message.test.js b/m2d/converters/event-to-message.test.js index 7d7aea9..d8dd3fb 100644 --- a/m2d/converters/event-to-message.test.js +++ b/m2d/converters/event-to-message.test.js @@ -1778,6 +1778,60 @@ test("event2message: with layered rich replies, the preview should only be the r ) }) +test("event2message: if event is a reply and starts with a quote, they should be separated by a blank line, so that they don't visually merge together", async t => { + t.deepEqual( + await eventToMessage({ + type: "m.room.message", + sender: "@aflower:syndicated.gay", + content: { + body: "> <@aflower:syndicated.gay> i have a feeling that clients are *meant to* strip these reply fallbacks too, just that none of them, in reality, do\n\n>To strip the fallback on the body, the client should iterate over each line of the string, removing any lines that start with the fallback prefix ("> “, including the space, without quotes) and stopping when a line is encountered without the prefix. This prefix is known as the “fallback prefix sequence”.", + format: "org.matrix.custom.html", + formatted_body: "
In reply to @aflower:syndicated.gay
i have a feeling that clients are meant to strip these reply fallbacks too, just that none of them, in reality, do
\n

To strip the fallback on the body, the client should iterate over each line of the string, removing any lines that start with the fallback prefix ("> “, including the space, without quotes) and stopping when a line is encountered without the prefix. This prefix is known as the “fallback prefix sequence”.

\n
", + "im.nheko.relations.v1.relations": [ + { + event_id: "$tTYQcke93fwocsc1K6itwUq85EG0RZ0ksCuIglKioks", + rel_type: "im.nheko.relations.v1.in_reply_to" + } + ], + "m.relates_to": { + "m.in_reply_to": { + event_id: "$tTYQcke93fwocsc1K6itwUq85EG0RZ0ksCuIglKioks" + } + }, + msgtype: "m.text" + }, + room_id: "!TqlyQmifxGUggEmdBN:cadence.moe", + event_id: "$nCvtZeBFedYuEavt4OftloCHc0kaFW2ktHCfIOklhjU", + }, data.guild.general, { + api: { + getEvent: mockGetEvent(t, "!TqlyQmifxGUggEmdBN:cadence.moe", "$tTYQcke93fwocsc1K6itwUq85EG0RZ0ksCuIglKioks", { + sender: "@aflower:syndicated.gay", + type: "m.room.message", + content: { + body: "i have a feeling that clients are *meant to* strip these reply fallbacks too, just that none of them, in reality, do", + format: "org.matrix.custom.html", + formatted_body: "i have a feeling that clients are meant to strip these reply fallbacks too, just that none of them, in reality, do", + msgtype: "m.text" + } + }) + } + }), + { + ensureJoined: [], + messagesToDelete: [], + messagesToEdit: [], + messagesToSend: [{ + username: "Rose", + content: "> <:L1:1144820033948762203><:L2:1144820084079087647>Ⓜ️**Rose**:" + + "\n> i have a feeling that clients are meant to strip..." + + "\n" + + "\n> To strip the fallback on the `body`, the client should iterate over each line of the string, removing any lines that start with the fallback prefix (\"> “, including the space, without quotes) and stopping when a line is encountered without the prefix. This prefix is known as the “fallback prefix sequence”.", + avatar_url: "https://matrix.cadence.moe/_matrix/media/r0/download/syndicated.gay/ZkBUPXCiXTjdJvONpLJmcbKP" + }] + } + ) +}) + test("event2message: rich reply to a deleted event", async t => { t.deepEqual( await eventToMessage({ diff --git a/test/ooye-test-data.sql b/test/ooye-test-data.sql index 644f732..023d5bb 100644 --- a/test/ooye-test-data.sql +++ b/test/ooye-test-data.sql @@ -116,7 +116,8 @@ INSERT INTO member_cache (room_id, mxid, displayname, avatar_url) VALUES ('!maggESguZBqGBZtSnr:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU'), ('!CzvdIdUQXgUjDVKxeU:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU'), ('!cBxtVRxDlZvSVhJXVK:cadence.moe', '@Milan:tchncs.de', 'Milan', NULL), -('!TqlyQmifxGUggEmdBN:cadence.moe', '@ampflower:matrix.org', 'Ampflower 🌺', 'mxc://cadence.moe/PRfhXYBTOalvgQYtmCLeUXko'); +('!TqlyQmifxGUggEmdBN:cadence.moe', '@ampflower:matrix.org', 'Ampflower 🌺', 'mxc://cadence.moe/PRfhXYBTOalvgQYtmCLeUXko'), +('!TqlyQmifxGUggEmdBN:cadence.moe', '@aflower:syndicated.gay', 'Rose', 'mxc://syndicated.gay/ZkBUPXCiXTjdJvONpLJmcbKP'); INSERT INTO lottie (sticker_id, mxc_url) VALUES ('860171525772279849', 'mxc://cadence.moe/ZtvvVbwMIdUZeovWVyGVFCeR');