@@ -227,11 +227,13 @@ export async function sendMessageMatrix(
227227 : null ;
228228 let plannedEvents : MatrixPreparedEvent [ ] | undefined = storedPlan ?. events ;
229229 if ( ! plannedEvents ) {
230- const { chunks , tableMode } = chunkMatrixText ( messageText , {
230+ const preparedText = chunkMatrixText ( messageText , {
231231 cfg,
232232 accountId : opts . accountId ,
233233 preserveWhitespace : true ,
234234 } ) ;
235+ const { chunks, convertedText, preparedBody, fitsInSingleEvent, tableMode } = preparedText ;
236+ const singleEventBody = fitsInSingleEvent ? preparedBody : undefined ;
235237 const relation = threadId
236238 ? buildThreadRelation ( threadId , opts . replyToId )
237239 : buildReplyRelation ( opts . replyToId ) ;
@@ -301,6 +303,7 @@ export async function sendMessageMatrix(
301303 client,
302304 content,
303305 markdown : captionMarkdown ,
306+ preparedBody : captionMarkdown === convertedText ? singleEventBody : undefined ,
304307 tableMode,
305308 } ) ;
306309 prepareContent ( content , receiptKind ) ;
@@ -315,6 +318,7 @@ export async function sendMessageMatrix(
315318 client,
316319 content : followup ,
317320 markdown : chunk ,
321+ preparedBody : chunk === convertedText ? singleEventBody : undefined ,
318322 tableMode,
319323 } ) ;
320324 prepareContent ( followup , "text" ) ;
@@ -329,6 +333,7 @@ export async function sendMessageMatrix(
329333 client,
330334 content,
331335 markdown : chunk ,
336+ preparedBody : chunk === convertedText ? singleEventBody : undefined ,
332337 tableMode,
333338 } ) ;
334339 prepareContent ( content , "text" ) ;
@@ -522,6 +527,7 @@ export async function sendSingleTextMessageMatrix(
522527 const {
523528 trimmedText,
524529 convertedText,
530+ preparedBody,
525531 singleEventLimit,
526532 eventTextLength,
527533 fitsInSingleEvent,
@@ -561,6 +567,7 @@ export async function sendSingleTextMessageMatrix(
561567 client,
562568 content,
563569 markdown : convertedText ,
570+ preparedBody,
564571 includeMentions : opts . includeMentions ,
565572 tableMode,
566573 } ) ;
@@ -631,7 +638,7 @@ export async function editMessageMatrix(
631638 async ( client ) => {
632639 const resolvedRoom = await resolveMatrixRoomId ( client , roomId ) ;
633640 const cfg = requireRuntimeConfig ( opts . cfg , "Matrix message edit" ) as CoreConfig ;
634- const { convertedText, tableMode } = prepareMatrixSingleText ( newText , {
641+ const { convertedText, preparedBody , tableMode } = prepareMatrixSingleText ( newText , {
635642 cfg,
636643 accountId : opts . accountId ,
637644 preserveWhitespace : true ,
@@ -646,6 +653,7 @@ export async function editMessageMatrix(
646653 client,
647654 content : newContent ,
648655 markdown : convertedText ,
656+ preparedBody,
649657 includeMentions : opts . includeMentions ,
650658 tableMode,
651659 } ) ;
0 commit comments