Some basic reply support.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ class MessageEventModel : public QAbstractListModel {
|
||||
public:
|
||||
enum EventRoles {
|
||||
EventTypeRole = Qt::UserRole + 1,
|
||||
MessageRole,
|
||||
AboveEventTypeRole,
|
||||
EventIdRole,
|
||||
TimeRole,
|
||||
|
||||
Reference in New Issue
Block a user