Some basic reply support.

This commit is contained in:
Black Hat
2018-09-17 11:58:02 +08:00
parent d02c3f6e90
commit 5ca03fdea8
7 changed files with 131 additions and 89 deletions

View File

@@ -124,3 +124,18 @@ void MatriqueRoom::countChanged() {
resetHighlightCount();
}
}
void MatriqueRoom::sendReply(QString userId, QString eventId,
QString replyContent, QString sendContent) {
QJsonObject json{
{"msgtype", "m.text"},
{"body", "> <" + userId + "> " + replyContent + "\n\n" + sendContent},
{"format", "org.matrix.custom.html"},
{"m.relates_to", QJsonObject{{"m.in_reply_to", QJsonObject{{"event_id", eventId}}}}},
{"formatted_body",
"<mx-reply><blockquote><a href=\"https://matrix.to/#/" + id() + "/" +
eventId + "\">In reply to</a> <a href=\"https://matrix.to/#/" +
userId + "\">" + userId + "</a><br>" + replyContent +
"</blockquote></mx-reply>" + sendContent}};
postJson("m.room.message", json);
}

View File

@@ -59,6 +59,7 @@ class MatriqueRoom : public Room {
void acceptInvitation();
void forget();
void sendTypingNotification(bool isTyping);
void sendReply(QString userId, QString eventId, QString replyContent, QString sendContent);
};
#endif // MATRIQUEROOM_H

View File

@@ -15,6 +15,7 @@
QHash<int, QByteArray> MessageEventModel::roleNames() const {
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
roles[EventTypeRole] = "eventType";
roles[MessageRole] = "message";
roles[AboveEventTypeRole] = "aboveEventType";
roles[EventIdRole] = "eventId";
roles[TimeRole] = "time";
@@ -415,6 +416,8 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
tr("Unknown Event"));
}
if (role == MessageRole) return evt.contentJson().value("body");
if (role == Qt::ToolTipRole) {
return evt.originalJson();
}

View File

@@ -13,6 +13,7 @@ class MessageEventModel : public QAbstractListModel {
public:
enum EventRoles {
EventTypeRole = Qt::UserRole + 1,
MessageRole,
AboveEventTypeRole,
EventIdRole,
TimeRole,