fix: properly remove reply fallback from (un)localized body
This commit is contained in:
parent
43bc0e1963
commit
e3d41bb449
|
|
@ -869,8 +869,9 @@ class Event extends MatrixEvent {
|
|||
var body = plaintextBody ? this.plaintextBody : this.body;
|
||||
|
||||
// Html messages will already have their reply fallback removed during the Html to Text conversion.
|
||||
var mayHaveReplyFallback =
|
||||
!plaintextBody || content['format'] != 'org.matrix.custom.html';
|
||||
var mayHaveReplyFallback = !plaintextBody ||
|
||||
(content['format'] != 'org.matrix.custom.html' ||
|
||||
formattedText.isEmpty);
|
||||
|
||||
// If we have an edit, we want to operate on the new content
|
||||
final newContent = content.tryGetMap<String, Object?>('m.new_content');
|
||||
|
|
|
|||
|
|
@ -1686,6 +1686,105 @@ void main() {
|
|||
editFormattedBody: '<b>edit formatted body</b>',
|
||||
editHtml: true,
|
||||
);
|
||||
|
||||
// test with reply fallback
|
||||
testUnlocalizedBody(
|
||||
expectation: 'body',
|
||||
plaintextBody: false,
|
||||
body: '> <@some:user.id> acb def\n\nbody',
|
||||
formattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>formatted body</b>',
|
||||
html: true,
|
||||
isEdit: false,
|
||||
// strictly speaking there is no quote in edits, but we have to handle them anyway because of other clients doing it wrong
|
||||
editBody: '> <@some:user.id> acb def\n\nedit body',
|
||||
editFormattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>edit formatted body</b>',
|
||||
editHtml: true,
|
||||
);
|
||||
testUnlocalizedBody(
|
||||
expectation: 'body',
|
||||
plaintextBody: true,
|
||||
body: '> <@some:user.id> acb def\n\nbody',
|
||||
formattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>formatted body</b>',
|
||||
html: false,
|
||||
isEdit: false,
|
||||
// strictly speaking there is no quote in edits, but we have to handle them anyway because of other clients doing it wrong
|
||||
editBody: '> <@some:user.id> acb def\n\nedit body',
|
||||
editFormattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>edit formatted body</b>',
|
||||
editHtml: true,
|
||||
);
|
||||
testUnlocalizedBody(
|
||||
expectation: 'body',
|
||||
plaintextBody: true,
|
||||
body: '> <@some:user.id> acb def\n\nbody',
|
||||
formattedBody: null,
|
||||
html: true,
|
||||
isEdit: false,
|
||||
// strictly speaking there is no quote in edits, but we have to handle them anyway because of other clients doing it wrong
|
||||
editBody: '> <@some:user.id> acb def\n\nedit body',
|
||||
editFormattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>edit formatted body</b>',
|
||||
editHtml: true,
|
||||
);
|
||||
testUnlocalizedBody(
|
||||
expectation: '**formatted body**',
|
||||
plaintextBody: true,
|
||||
body: '> <@some:user.id> acb def\n\nbody',
|
||||
formattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>formatted body</b>',
|
||||
html: true,
|
||||
isEdit: false,
|
||||
// strictly speaking there is no quote in edits, but we have to handle them anyway because of other clients doing it wrong
|
||||
editBody: '> <@some:user.id> acb def\n\nedit body',
|
||||
editFormattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>edit formatted body</b>',
|
||||
editHtml: true,
|
||||
);
|
||||
testUnlocalizedBody(
|
||||
expectation: 'edit body',
|
||||
plaintextBody: false,
|
||||
body: '> <@some:user.id> acb def\n\nbody',
|
||||
formattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>formatted body</b>',
|
||||
html: true,
|
||||
isEdit: true,
|
||||
// strictly speaking there is no quote in edits, but we have to handle them anyway because of other clients doing it wrong
|
||||
editBody: '> <@some:user.id> acb def\n\nedit body',
|
||||
editFormattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>edit formatted body</b>',
|
||||
editHtml: true,
|
||||
);
|
||||
testUnlocalizedBody(
|
||||
expectation: 'edit body',
|
||||
plaintextBody: true,
|
||||
body: '> <@some:user.id> acb def\n\nbody',
|
||||
formattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>formatted body</b>',
|
||||
html: true,
|
||||
isEdit: true,
|
||||
// strictly speaking there is no quote in edits, but we have to handle them anyway because of other clients doing it wrong
|
||||
editBody: '> <@some:user.id> acb def\n\nedit body',
|
||||
editFormattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>edit formatted body</b>',
|
||||
editHtml: false,
|
||||
);
|
||||
testUnlocalizedBody(
|
||||
expectation: '**edit formatted body**',
|
||||
plaintextBody: true,
|
||||
body: '> <@some:user.id> acb def\n\nbody',
|
||||
formattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>formatted body</b>',
|
||||
html: true,
|
||||
isEdit: true,
|
||||
// strictly speaking there is no quote in edits, but we have to handle them anyway because of other clients doing it wrong
|
||||
editBody: '> <@some:user.id> acb def\n\nedit body',
|
||||
editFormattedBody:
|
||||
'<mx-reply><blockquote>abc</blockquote></mx-reply><b>edit formatted body</b>',
|
||||
editHtml: true,
|
||||
);
|
||||
});
|
||||
|
||||
test('getDisplayEvent', () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue