Revert "Improve sending message with mentions"

This reverts commit b9d34487a4
This commit is contained in:
Carl Schwan
2021-01-22 14:45:40 +00:00
parent b9d34487a4
commit 0f043e36c4
4 changed files with 30 additions and 16 deletions

View File

@@ -159,15 +159,16 @@ void ActionsHandler::createRoom(const QString &name, const QString &topic)
}
void ActionsHandler::postMessage(const QString &text,
const QString &attachementPath, const QString &replyEventId, const QString &editEventId)
const QString &attachementPath, const QString &replyEventId, const QString &editEventId,
const QVariantMap usernames)
{
QString rawText = text;
QString cleanedText = text;
for (const auto *user : m_room->users()) {
const auto displayName = user->displayname(m_room);
cleanedText = cleanedText.replace(displayName,
"[" + displayName + "](https://matrix.to/#/" + user->id() + ")");
for (const auto username : usernames.keys()) {
const auto replacement = usernames.value(username);
cleanedText = cleanedText.replace(username,
"[" + username + "](https://matrix.to/#/" + replacement.toString() + ")");
}
if (attachementPath.length() > 0) {
@@ -270,6 +271,9 @@ void ActionsHandler::postMessage(const QString &text,
if (rawText.indexOf(partPrefix) == 0) {
rawText = rawText.remove(0, partPrefix.length());
const QStringList splittedText = rawText.split(" ");
qDebug() << m_room;
qDebug() << "m_room";
qDebug() << splittedText;
if (splittedText.count() == 0 || splittedText[0].isEmpty()) {
// leave current room
m_connection->leaveRoom(m_room);