This repository was archived by the owner on Jul 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ import escapeHtml from "escape-html";
2121import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread" ;
2222import { MsgType } from "matrix-js-sdk/src/@types/event" ;
2323import { M_BEACON_INFO } from "matrix-js-sdk/src/@types/beacon" ;
24- import { M_POLL_END } from "matrix-js-sdk/src/@types/polls" ;
24+ import { M_POLL_END , M_POLL_START } from "matrix-js-sdk/src/@types/polls" ;
25+ import { PollStartEvent } from "matrix-js-sdk/src/extensible_events_v1/PollStartEvent" ;
2526
2627import { PERMITTED_URL_SCHEMES } from "../HtmlUtils" ;
2728import { makeUserPermalink , RoomPermalinkCreator } from "./permalinks/Permalinks" ;
@@ -112,6 +113,16 @@ export function getNestedReplyText(
112113 } ;
113114 }
114115
116+ if ( M_POLL_START . matches ( ev . getType ( ) ) ) {
117+ const extensibleEvent = ev . unstableExtensibleEvent as PollStartEvent ;
118+ const question = extensibleEvent ?. question ?. text ;
119+ return {
120+ html :
121+ `<mx-reply><blockquote><a href="${ evLink } ">In reply to</a> <a href="${ userLink } ">${ mxid } </a>` +
122+ `<br>Poll: ${ question } </blockquote></mx-reply>` ,
123+ body : `> <${ mxid } > started poll: ${ question } \n\n` ,
124+ } ;
125+ }
115126 if ( M_POLL_END . matches ( ev . getType ( ) ) ) {
116127 return {
117128 html :
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ import {
2626 stripHTMLReply ,
2727 stripPlainReply ,
2828} from "../src/utils/Reply" ;
29- import { mkEvent } from "./test-utils" ;
29+ import { makePollStartEvent , mkEvent } from "./test-utils" ;
3030import { RoomPermalinkCreator } from "../src/utils/permalinks/Permalinks" ;
3131
3232function makeTestEvent ( type : string , content : IContent ) : MatrixEvent {
@@ -160,6 +160,12 @@ But this is not
160160
161161 expect ( getNestedReplyText ( event , mockPermalinkGenerator ) ) . toMatchSnapshot ( ) ;
162162 } ) ;
163+
164+ it ( "should create the expected fallback text for poll start events" , ( ) => {
165+ const event = makePollStartEvent ( "Will this test pass?" , "@user:server.org" ) ;
166+
167+ expect ( getNestedReplyText ( event , mockPermalinkGenerator ) ) . toMatchSnapshot ( ) ;
168+ } ) ;
163169 } ) ;
164170
165171 describe ( "shouldDisplayReply" , ( ) => {
Original file line number Diff line number Diff line change @@ -53,3 +53,12 @@ exports[`Reply getNestedReplyText should create the expected fallback text for p
5353 " html" : " <mx-reply><blockquote><a href=" $$permalink$$ " >In reply to</a> <a href=" https :// matrix.to/#/@user1:server">@user1:server</a><br>Ended poll</blockquote></mx-reply>",
5454}
5555` ;
56+
57+ exports [` Reply getNestedReplyText should create the expected fallback text for poll start events 1` ] = `
58+ {
59+ " body" : " > <@user:server.org> started poll: Will this test pass?
60+
61+ " ,
62+ " html" : " <mx-reply><blockquote><a href=" $$permalink$$ " >In reply to</a> <a href=" https :// matrix.to/#/@user:server.org">@user:server.org</a><br>Poll: Will this test pass?</blockquote></mx-reply>",
63+ }
64+ ` ;
You can’t perform that action at this time.
0 commit comments