Combine Ban/Timeout pubsub actions

Fully implement PubSub ban/unban messages
Move the "message combining" to Channel::addMessage

Disable "irc" ban/timeout handling for now. In the future, we might want
to use this if you're not a moderator in a channel.
This commit is contained in:
Rasmus Karlsson
2018-04-27 18:35:31 +02:00
parent 42182ed504
commit 32b6417a55
8 changed files with 163 additions and 37 deletions
+12 -9
View File
@@ -46,21 +46,19 @@ struct ModeChangedAction : PubSubAction {
} args;
};
struct TimeoutAction : PubSubAction {
using PubSubAction::PubSubAction;
ActionUser target;
QString reason;
uint32_t duration;
};
struct BanAction : PubSubAction {
using PubSubAction::PubSubAction;
ActionUser target;
QString reason;
uint32_t duration = 0;
bool isBan() const
{
return this->duration == 0;
}
};
struct UnbanAction : PubSubAction {
@@ -72,6 +70,11 @@ struct UnbanAction : PubSubAction {
Banned,
TimedOut,
} previousState;
bool wasBan() const
{
return this->previousState == Banned;
}
};
struct ClearChatAction : PubSubAction {
+2 -2
View File
@@ -300,7 +300,7 @@ PubSubManager::PubSubManager()
};
this->moderationActionHandlers["timeout"] = [this](const auto &data, const auto &roomID) {
TimeoutAction action(data, roomID);
BanAction action(data, roomID);
getCreatedByUser(data, action.source);
getTargetUser(data, action.target);
@@ -329,7 +329,7 @@ PubSubManager::PubSubManager()
}
}
this->sig.moderation.userTimedOut.invoke(action);
this->sig.moderation.userBanned.invoke(action);
} catch (const std::runtime_error &ex) {
debug::Log("Error parsing moderation action: {}", ex.what());
}
-1
View File
@@ -102,7 +102,6 @@ public:
Signal<ModeChangedAction> modeChanged;
Signal<ModerationStateAction> moderationStateChanged;
Signal<TimeoutAction> userTimedOut;
Signal<BanAction> userBanned;
Signal<UnbanAction> userUnbanned;
} moderation;