diff --git a/src/utils/Reply.ts b/src/utils/Reply.ts index 802f35b0ed..b5dbac41da 100644 --- a/src/utils/Reply.ts +++ b/src/utils/Reply.ts @@ -20,6 +20,7 @@ import escapeHtml from "escape-html"; import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread"; import { MsgType } from "matrix-js-sdk/src/@types/event"; import { M_BEACON_INFO } from "matrix-js-sdk/src/@types/beacon"; +import { M_POLL_END } from "matrix-js-sdk/src/@types/polls"; import { PERMITTED_URL_SCHEMES } from "../HtmlUtils"; import { makeUserPermalink, RoomPermalinkCreator } from "./permalinks/Permalinks"; @@ -110,6 +111,15 @@ export function getNestedReplyText( }; } + if (M_POLL_END.matches(ev.getType())) { + return { + html: + `
In reply to ${mxid}` + + `
Ended poll
`, + body: `> <${mxid}>Ended poll\n\n`, + }; + } + // This fallback contains text that is explicitly EN. switch (msgtype) { case MsgType.Text: diff --git a/test/Reply-test.ts b/test/Reply-test.ts index 002f18ebe6..4ae7f6fa82 100644 --- a/test/Reply-test.ts +++ b/test/Reply-test.ts @@ -17,6 +17,7 @@ limitations under the License. import { IContent, MatrixEvent, MsgType } from "matrix-js-sdk/src/matrix"; import { M_BEACON_INFO } from "matrix-js-sdk/src/@types/beacon"; import { LocationAssetType, M_ASSET } from "matrix-js-sdk/src/@types/location"; +import { M_POLL_END } from "matrix-js-sdk/src/@types/polls"; import { getNestedReplyText, @@ -149,6 +150,14 @@ But this is not expect(getNestedReplyText(event, mockPermalinkGenerator)).toMatchSnapshot(); }); }); + + it("should create the expected fallback text for poll end events", () => { + const event = makeTestEvent(M_POLL_END.name, { + body: "body", + }); + + expect(getNestedReplyText(event, mockPermalinkGenerator)).toMatchSnapshot(); + }); }); describe("shouldDisplayReply", () => { diff --git a/test/__snapshots__/Reply-test.ts.snap b/test/__snapshots__/Reply-test.ts.snap index 867240425a..6822f82f7e 100644 --- a/test/__snapshots__/Reply-test.ts.snap +++ b/test/__snapshots__/Reply-test.ts.snap @@ -44,3 +44,12 @@ exports[`Reply getNestedReplyText should create the expected fallback text for m "html": "
In reply to @user1:server
shared their live location.
", } `; + +exports[`Reply getNestedReplyText should create the expected fallback text for poll end events 1`] = ` +{ + "body": "> <@user1:server>Ended poll + +", + "html": "
In reply to @user1:server
Ended poll
", +} +`;