diff --git a/imports/NeoChat/Component/ChatTextInput.qml b/imports/NeoChat/Component/ChatTextInput.qml
index 29249dc3c..23c6520a1 100644
--- a/imports/NeoChat/Component/ChatTextInput.qml
+++ b/imports/NeoChat/Component/ChatTextInput.qml
@@ -469,14 +469,9 @@ ToolBar {
autoCompleteEndPosition = cursorPosition
}
- // store each user we autoComplete here, this will be helpful later to generate
- // the matrix.to links.
- // This use an hack to define: https://doc.qt.io/qt-5/qml-var.html#property-value-initialization-semantics
- property var userAutocompleted: ({})
-
function postMessage() {
roomManager.actionsHandler.postMessage(inputField.text.trim(), attachmentPath,
- replyEventID, editEventId, inputField.userAutocompleted);
+ replyEventID, editEventId);
clearAttachment();
currentRoom.markAllMessagesAsRead();
clear();
@@ -487,10 +482,6 @@ ToolBar {
function autoComplete() {
documentHandler.replaceAutoComplete(autoCompleteListView.currentItem.displayText)
- // Unfortunally it doesn't
- if (!autoCompleteListView.currentItem.isEmoji) {
- inputField.userAutocompleted[autoCompleteListView.currentItem.displayText] = autoCompleteListView.currentItem.userId;
- }
}
}
}
@@ -583,7 +574,6 @@ ToolBar {
function clear() {
inputField.clear()
- inputField.userAutocompleted = {};
}
function clearEditReply() {
diff --git a/src/actionshandler.cpp b/src/actionshandler.cpp
index 6bf18ec24..35fd314e1 100644
--- a/src/actionshandler.cpp
+++ b/src/actionshandler.cpp
@@ -159,16 +159,15 @@ 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 QVariantMap usernames)
+ const QString &attachementPath, const QString &replyEventId, const QString &editEventId)
{
QString rawText = text;
QString cleanedText = text;
- for (const auto username : usernames.keys()) {
- const auto replacement = usernames.value(username);
- cleanedText = cleanedText.replace(username,
- "[" + username + "](https://matrix.to/#/" + replacement.toString() + ")");
+ for (const auto *user : m_room->users()) {
+ const auto displayName = user->displayname(m_room);
+ cleanedText = cleanedText.replace(displayName,
+ "[" + displayName + "](https://matrix.to/#/" + user->id() + ")");
}
if (attachementPath.length() > 0) {
@@ -271,9 +270,6 @@ 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);
diff --git a/src/actionshandler.h b/src/actionshandler.h
index 9df180920..caf80f695 100644
--- a/src/actionshandler.h
+++ b/src/actionshandler.h
@@ -70,8 +70,7 @@ public Q_SLOTS:
///
/// This also interprets commands if any.
void postMessage(const QString &text, const QString &attachementPath,
- const QString &replyEventId, const QString &editEventId,
- const QVariantMap usernames);
+ const QString &replyEventId, const QString &editEventId);
private:
Connection *m_connection = nullptr;
diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp
index 00f0756ee..d720a5973 100644
--- a/src/neochatroom.cpp
+++ b/src/neochatroom.cpp
@@ -99,7 +99,6 @@ void NeoChatRoom::uploadFile(const QUrl &url, const QString &body)
});
connect(this, &Room::fileTransferProgress, [=](const QString &id, qint64 progress, qint64 total) {
if (id == txnId) {
- qDebug() << "Progress:" << progress << total;
setFileUploadingProgress(int(float(progress) / float(total) * 100));
}
});
@@ -536,9 +535,7 @@ void NeoChatRoom::postMessage(const QString &text, MessageEventType type, const
void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, MessageEventType type, const QString &replyEventId, const QString &relateToEventId)
{
- QString htmlWithLinks = html;
- htmlWithLinks = htmlWithLinks.replace(QRegularExpression("@([^: ]*):([^ ]*\\.[^ ]*)"), "@$1:$2");
- bool isRichText = Qt::mightBeRichText(htmlWithLinks);
+ bool isRichText = Qt::mightBeRichText(html);
bool isReply = !replyEventId.isEmpty();
bool isEdit = !relateToEventId.isEmpty();
const auto replyIt = findInTimeline(replyEventId);
@@ -551,11 +548,15 @@ void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, Mess
QJsonObject json {
{"type", "m.room.message"},
{"msgtype", msgTypeToString(type)},
- {"body", "* " + (isRichText ? text : htmlWithLinks)},
+ {"body", "* " + text},
+ {"format", "org.matrix.custom.html"},
+ {"formatted_body", html},
{"m.new_content",
QJsonObject {
- {"body", (isRichText ? text : htmlWithLinks)},
- {"msgtype", msgTypeToString(type)}
+ {"body", text},
+ {"msgtype", msgTypeToString(type)},
+ {"format", "org.matrix.custom.html"},
+ {"formatted_body", html}
}
},
{"m.relates_to",
@@ -594,7 +595,7 @@ void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, Mess
"\">In reply to " + replyEvt.senderId() +
"
" + eventToString(replyEvt, Qt::RichText) +
- "" + (isRichText ? htmlWithLinks : text)
+ "" + (isRichText ? html : text)
}
};
// clang-format on