Handle emotes in texthander

This moves the code to add the emote user pill into texthandler removing the now redundant checks from the message delegates.
This commit is contained in:
James Graham
2023-04-07 19:03:04 +00:00
parent abd56baa51
commit be3b5cdb8a
6 changed files with 51 additions and 10 deletions

View File

@@ -59,6 +59,7 @@ private Q_SLOTS:
void receiveRichtextIn();
void receiveRichMxcUrl();
void receiveRichPlainUrl();
void receiveRichEmote();
};
#ifdef QUOTIENT_07
@@ -148,6 +149,22 @@ void TextHandlerTest::initTestCase()
"unsigned": {
"age": 1235
}
},
{
"content": {
"body": "/me This is an emote.",
"format": "org.matrix.custom.html",
"formatted_body": "This is an emote.",
"msgtype": "m.emote"
},
"event_id": "$153273582443PhrSn:example.org",
"origin_server_ts": 1532735824654,
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
"sender": "@example:example.org",
"type": "m.room.message",
"unsigned": {
"age": 1236
}
}
],
"limited": true,
@@ -439,7 +456,7 @@ void TextHandlerTest::receiveRichMxcUrl()
TextHandler testTextHandler;
testTextHandler.setData(testInputString);
QCOMPARE(testTextHandler.handleRecieveRichText(Qt::RichText, room, room->messageEvents().back().get()), testOutputString);
QCOMPARE(testTextHandler.handleRecieveRichText(Qt::RichText, room, room->messageEvents().at(0).get()), testOutputString);
}
#endif
@@ -498,5 +515,19 @@ void TextHandlerTest::receiveRichPlainUrl()
QCOMPARE(testTextHandler.handleRecieveRichText(Qt::RichText), testOutputStringMxId);
}
// Test that user pill is add to an emote message.
// N.B. The second message in the test timeline is marked as an emote.
void TextHandlerTest::receiveRichEmote()
{
const QString testInputString = QStringLiteral("This is an emote.");
const QString testOutputString =
QStringLiteral("* <a href=\"https://matrix.to/#/@example:example.org\" style=\"color:#000000\">@example:example.org</a> This is an emote.");
TextHandler testTextHandler;
testTextHandler.setData(testInputString);
QCOMPARE(testTextHandler.handleRecieveRichText(Qt::RichText, room, room->messageEvents().at(1).get()), testOutputString);
}
QTEST_MAIN(TextHandlerTest)
#include "texthandlertest.moc"