File tree 3 files changed +28
-2
lines changed
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";
21
21
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread" ;
22
22
import { MsgType } from "matrix-js-sdk/src/@types/event" ;
23
23
import { 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" ;
25
26
26
27
import { PERMITTED_URL_SCHEMES } from "../HtmlUtils" ;
27
28
import { makeUserPermalink , RoomPermalinkCreator } from "./permalinks/Permalinks" ;
@@ -112,6 +113,16 @@ export function getNestedReplyText(
112
113
} ;
113
114
}
114
115
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
+ }
115
126
if ( M_POLL_END . matches ( ev . getType ( ) ) ) {
116
127
return {
117
128
html :
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ import {
26
26
stripHTMLReply ,
27
27
stripPlainReply ,
28
28
} from "../src/utils/Reply" ;
29
- import { mkEvent } from "./test-utils" ;
29
+ import { makePollStartEvent , mkEvent } from "./test-utils" ;
30
30
import { RoomPermalinkCreator } from "../src/utils/permalinks/Permalinks" ;
31
31
32
32
function makeTestEvent ( type : string , content : IContent ) : MatrixEvent {
@@ -160,6 +160,12 @@ But this is not
160
160
161
161
expect ( getNestedReplyText ( event , mockPermalinkGenerator ) ) . toMatchSnapshot ( ) ;
162
162
} ) ;
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
+ } ) ;
163
169
} ) ;
164
170
165
171
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
53
53
" 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>",
54
54
}
55
55
` ;
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