aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jobs/generated/banning.cpp35
-rw-r--r--jobs/generated/banning.h31
-rw-r--r--room.cpp31
-rw-r--r--room.h5
4 files changed, 90 insertions, 12 deletions
diff --git a/jobs/generated/banning.cpp b/jobs/generated/banning.cpp
new file mode 100644
index 00000000..9fc5810a
--- /dev/null
+++ b/jobs/generated/banning.cpp
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+
+#include "banning.h"
+
+#include "jobs/converters.h"
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+BanJob::BanJob(QString roomId, QString user_id, QString reason)
+ : BaseJob(HttpVerb::Post, "BanJob",
+ basePath % "/rooms/" % roomId % "/ban",
+ Query { },
+ Data {
+ { "user_id", toJson(user_id) },
+ { "reason", toJson(reason) }
+ }
+ )
+{ }
+
+UnbanJob::UnbanJob(QString roomId, QString user_id)
+ : BaseJob(HttpVerb::Post, "UnbanJob",
+ basePath % "/rooms/" % roomId % "/unban",
+ Query { },
+ Data {
+ { "user_id", toJson(user_id) }
+ }
+ )
+{ }
+
diff --git a/jobs/generated/banning.h b/jobs/generated/banning.h
new file mode 100644
index 00000000..b9d5b8db
--- /dev/null
+++ b/jobs/generated/banning.h
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QString>
+
+
+namespace QMatrixClient
+{
+
+ // Operations
+
+ class BanJob : public BaseJob
+ {
+ public:
+ explicit BanJob(QString roomId, QString user_id, QString reason = {});
+
+ };
+ class UnbanJob : public BaseJob
+ {
+ public:
+ explicit UnbanJob(QString roomId, QString user_id);
+
+ };
+
+} // namespace QMatrixClient
diff --git a/room.cpp b/room.cpp
index 05b16b65..79168d85 100644
--- a/room.cpp
+++ b/room.cpp
@@ -20,17 +20,8 @@
#include "jobs/generated/kicking.h"
#include "jobs/generated/inviting.h"
-
-#include <array>
-
-#include <QtCore/QHash>
-#include <QtCore/QStringBuilder> // for efficient string concats (operator%)
-#include <QtCore/QElapsedTimer>
-#include <jobs/setroomstatejob.h>
-
-#include "connection.h"
-#include "state.h"
-#include "user.h"
+#include "jobs/generated/banning.h"
+#include "jobs/setroomstatejob.h"
#include "events/roomnameevent.h"
#include "events/roomaliasesevent.h"
#include "events/roomcanonicalaliasevent.h"
@@ -42,6 +33,14 @@
#include "jobs/roommessagesjob.h"
#include "jobs/postreceiptjob.h"
#include "jobs/leaveroomjob.h"
+#include "connection.h"
+#include "user.h"
+
+#include <QtCore/QHash>
+#include <QtCore/QStringBuilder> // for efficient string concats (operator%)
+#include <QtCore/QElapsedTimer>
+
+#include <array>
using namespace QMatrixClient;
@@ -639,6 +638,16 @@ void Room::kickMember(const QString& memberId, const QString& reason) const
connection()->callApi<KickJob>(id(), memberId, reason);
}
+void Room::ban(const QString& userId, const QString& reason) const
+{
+ connection()->callApi<BanJob>(id(), userId, reason);
+}
+
+void Room::unban(const QString& userId) const
+{
+ connection()->callApi<UnbanJob>(id(), userId);
+}
+
void Room::Private::dropDuplicateEvents(RoomEvents* events) const
{
// Collect all duplicate events at the end of the container
diff --git a/room.h b/room.h
index 455ef6cc..d62d160f 100644
--- a/room.h
+++ b/room.h
@@ -159,7 +159,10 @@ namespace QMatrixClient
void inviteToRoom(const QString& memberId) const;
void leaveRoom() const;
- void kickMember(const QString& memberId, const QString& reason) const;
+ void kickMember(const QString& memberId,
+ const QString& reason = {}) const;
+ void ban(const QString& userId, const QString& reason = {}) const;
+ void unban(const QString& userId) const;
void userRenamed(User* user, QString oldName);