Strip replies when calling EventHandler::getMarkdownBody()

This matches previous behavior before
e2eb6ab33c and including the markdown
blockquote breaks edits. This also adds a test to ensure it does indeed
get stripped.
This commit is contained in:
Joshua Goins
2024-03-21 16:08:30 -04:00
committed by James Graham
parent 46a9600d55
commit 9d3c2e19f5
2 changed files with 12 additions and 1 deletions

View File

@@ -56,6 +56,7 @@ private Q_SLOTS:
void genericBody();
void nullGenericBody();
void markdownBody();
void markdownBodyReply();
void subtitle();
void nullSubtitle();
void mediaInfo();
@@ -301,6 +302,13 @@ void EventHandlerTest::markdownBody()
QCOMPARE(eventHandler.getMarkdownBody(), QStringLiteral("This is an example\ntext message"));
}
void EventHandlerTest::markdownBodyReply()
{
EventHandler eventHandler(room, room->messageEvents().at(5).get());
QCOMPARE(eventHandler.getMarkdownBody(), QStringLiteral("reply"));
}
void EventHandlerTest::subtitle()
{
EventHandler eventHandler(room, room->messageEvents().at(0).get());

View File

@@ -293,7 +293,10 @@ QString EventHandler::getMarkdownBody() const
}
const auto roomMessageEvent = eventCast<const RoomMessageEvent>(m_event);
return roomMessageEvent->plainBody();
QString plainBody = roomMessageEvent->plainBody();
plainBody.remove(TextRegex::removeReply);
return plainBody;
}
QString EventHandler::getBody(const Quotient::RoomEvent *event, Qt::TextFormat format, bool stripNewlines) const