diff options
-rw-r--r-- | jobs/generated/banning.cpp | 35 | ||||
-rw-r--r-- | jobs/generated/banning.h | 31 | ||||
-rw-r--r-- | room.cpp | 31 | ||||
-rw-r--r-- | room.h | 5 |
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 @@ -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 @@ -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); |