aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jobs/postmessagejob.cpp18
-rw-r--r--jobs/postmessagejob.h9
-rw-r--r--room.cpp10
-rw-r--r--room.h4
4 files changed, 33 insertions, 8 deletions
diff --git a/jobs/postmessagejob.cpp b/jobs/postmessagejob.cpp
index 23c2214c..69cc814d 100644
--- a/jobs/postmessagejob.cpp
+++ b/jobs/postmessagejob.cpp
@@ -31,12 +31,24 @@ class PostMessageJob::Private
QString eventId; // unused yet
};
-PostMessageJob::PostMessageJob(ConnectionData* connection, QString roomId,
- QString type, QString message)
+PostMessageJob::PostMessageJob(ConnectionData* connection, const QString& roomId,
+ const QString& type, const QString& plainText)
: BaseJob(connection, HttpVerb::Post, "PostMessageJob",
QString("_matrix/client/r0/rooms/%1/send/m.room.message").arg(roomId),
Query(),
- Data({ { "msgtype", type }, { "body", message } }))
+ Data({ { "msgtype", type }, { "body", plainText } }) )
+ , d(new Private)
+{ }
+
+PostMessageJob::PostMessageJob(ConnectionData* connection, const QString& roomId,
+ const QString& type, const QString& plainText,
+ const QString& richText)
+ : BaseJob(connection, HttpVerb::Post, "PostMessageJob",
+ QStringLiteral("_matrix/client/r0/rooms/%1/send/m.room.message").arg(roomId),
+ Query(),
+ Data({ { "msgtype", type }, { "body", plainText }
+ , { "format", QStringLiteral("org.matrix.custom.html") }
+ , { "formatted_body", richText } }) )
, d(new Private)
{ }
diff --git a/jobs/postmessagejob.h b/jobs/postmessagejob.h
index eba3da51..14de52f0 100644
--- a/jobs/postmessagejob.h
+++ b/jobs/postmessagejob.h
@@ -25,8 +25,13 @@ namespace QMatrixClient
class PostMessageJob: public BaseJob
{
public:
- PostMessageJob(ConnectionData* connection, QString roomId,
- QString type, QString message);
+ /** Constructs a plain text message job */
+ PostMessageJob(ConnectionData* connection, const QString& roomId,
+ const QString& type, const QString& plainText);
+ /** Constructs a rich text message job */
+ PostMessageJob(ConnectionData* connection, const QString& roomId,
+ const QString& type, const QString& plainText,
+ const QString& richText);
virtual ~PostMessageJob();
//bool success();
diff --git a/room.cpp b/room.cpp
index 5aea6ff0..ae341e1b 100644
--- a/room.cpp
+++ b/room.cpp
@@ -535,9 +535,15 @@ void Room::updateData(SyncRoomData& data)
}
}
-void Room::postMessage(QString type, QString content)
+void Room::postMessage(const QString& type, const QString& plainText)
{
- connection()->callApi<PostMessageJob>(id(), type, content);
+ connection()->callApi<PostMessageJob>(id(), type, plainText);
+}
+
+void Room::postMessage(const QString& type, const QString& plainText,
+ const QString& richText)
+{
+ connection()->callApi<PostMessageJob>(id(), type, plainText, richText);
}
void Room::getPreviousContent(int limit)
diff --git a/room.h b/room.h
index 590ddb6d..704fdf00 100644
--- a/room.h
+++ b/room.h
@@ -139,7 +139,9 @@ namespace QMatrixClient
MemberSorter memberSorter() const;
public slots:
- void postMessage(QString msgType, QString msgContent);
+ void postMessage(const QString& type, const QString& plainText);
+ void postMessage(const QString& type, const QString& plainText,
+ const QString& richText);
void getPreviousContent(int limit = 10);
void userRenamed(User* user, QString oldName);