aboutsummaryrefslogtreecommitdiff
path: root/jobs/sendeventjob.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-06-22 16:38:29 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-06-27 19:44:14 +0900
commit749def2b983d2338272c0891d15de20df22e2eea (patch)
treea960df12d66c462d261ee84b55903f6cadc74ed8 /jobs/sendeventjob.cpp
parent7d745dca7bdd328fd96acdf53f15f4a5cd7cf484 (diff)
downloadlibquotient-749def2b983d2338272c0891d15de20df22e2eea.tar.gz
libquotient-749def2b983d2338272c0891d15de20df22e2eea.zip
Enable sending RoomMessageEvents
1. PostMessageJob is now SendEventJob, which reflects two things: first, it's a PUT instead of a POST (POST for /send is not supported by the latest spec anyway), so that we could enable tracking transaction ids for local echo in the near future; second, it's no more just about messages, the job can support sending any room events (topic changes etc.). 2. Room::postMessage() now uses the new RoomMessageEvent API to send m.room.message events.
Diffstat (limited to 'jobs/sendeventjob.cpp')
-rw-r--r--jobs/sendeventjob.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/jobs/sendeventjob.cpp b/jobs/sendeventjob.cpp
new file mode 100644
index 00000000..f3c95fe8
--- /dev/null
+++ b/jobs/sendeventjob.cpp
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * Copyright (C) 2015 Felix Rohrbach <kde@fxrh.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "sendeventjob.h"
+
+#include "events/roommessageevent.h"
+
+using namespace QMatrixClient;
+
+SendEventJob::SendEventJob(const ConnectionData* connection,
+ const QString& roomId, const QString& type,
+ const QString& plainText)
+ : SendEventJob(connection, roomId,
+ new RoomMessageEvent(plainText, type))
+{ }
+
+BaseJob::Status SendEventJob::parseJson(const QJsonDocument& data)
+{
+ _eventId = data.object().value("event_id").toString();
+ if (!_eventId.isEmpty())
+ return Success;
+
+ qCDebug(JOBS) << data;
+ return { UserDefinedError, "No event_id in the JSON response" };
+}
+