chore(pubsub): remove unused whisper code 👷🏻♀️ (#5898)
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
- Bugfix: Ensure miniaudio backend exits even if it doesn't exit cleanly. (#5896)
|
||||
- Dev: Add initial experimental EventSub support. (#5837, #5895)
|
||||
- Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784)
|
||||
- Dev: Removed unused PubSub whisper code. (#5898)
|
||||
- Dev: Updated Conan dependencies. (#5776)
|
||||
- Dev: Disable QT keywords (i.e. `emit`, `slots`, and `signals`). (#5882)
|
||||
- Dev: Replaced usage of `parseTime` with `serverReceivedTime` for clearchat messages. (#5824, #5855)
|
||||
|
||||
@@ -454,8 +454,6 @@ set(SOURCE_FILES
|
||||
providers/twitch/pubsubmessages/Message.hpp
|
||||
providers/twitch/pubsubmessages/Unlisten.cpp
|
||||
providers/twitch/pubsubmessages/Unlisten.hpp
|
||||
providers/twitch/pubsubmessages/Whisper.cpp
|
||||
providers/twitch/pubsubmessages/Whisper.hpp
|
||||
|
||||
providers/twitch/api/Helix.cpp
|
||||
providers/twitch/api/Helix.hpp
|
||||
|
||||
@@ -616,30 +616,6 @@ void PubSub::stop()
|
||||
this->thread->detach();
|
||||
}
|
||||
|
||||
bool PubSub::listenToWhispers()
|
||||
{
|
||||
if (this->userID_.isEmpty())
|
||||
{
|
||||
qCDebug(chatterinoPubSub)
|
||||
<< "Unable to listen to whispers topic, no user logged in";
|
||||
return false;
|
||||
}
|
||||
|
||||
static const QString topicFormat("whispers.%1");
|
||||
auto topic = topicFormat.arg(this->userID_);
|
||||
|
||||
qCDebug(chatterinoPubSub) << "Listen to whispers" << topic;
|
||||
|
||||
this->listenToTopic(topic);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PubSub::unlistenWhispers()
|
||||
{
|
||||
this->unlistenPrefix("whispers.");
|
||||
}
|
||||
|
||||
void PubSub::listenToChannelModerationActions(const QString &channelID)
|
||||
{
|
||||
if (this->userID_.isEmpty())
|
||||
@@ -1108,39 +1084,7 @@ void PubSub::handleMessageResponse(const PubSubMessageMessage &message)
|
||||
{
|
||||
QString topic = message.topic;
|
||||
|
||||
if (topic.startsWith("whispers."))
|
||||
{
|
||||
auto oInnerMessage = message.toInner<PubSubWhisperMessage>();
|
||||
if (!oInnerMessage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto whisperMessage = *oInnerMessage;
|
||||
|
||||
switch (whisperMessage.type)
|
||||
{
|
||||
case PubSubWhisperMessage::Type::WhisperReceived: {
|
||||
this->whisper.received.invoke(whisperMessage);
|
||||
}
|
||||
break;
|
||||
case PubSubWhisperMessage::Type::WhisperSent: {
|
||||
this->whisper.sent.invoke(whisperMessage);
|
||||
}
|
||||
break;
|
||||
case PubSubWhisperMessage::Type::Thread: {
|
||||
// Handle thread?
|
||||
}
|
||||
break;
|
||||
|
||||
case PubSubWhisperMessage::Type::INVALID:
|
||||
default: {
|
||||
qCDebug(chatterinoPubSub)
|
||||
<< "Invalid whisper type:" << whisperMessage.typeString;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (topic.startsWith("chat_moderator_actions."))
|
||||
if (topic.startsWith("chat_moderator_actions."))
|
||||
{
|
||||
auto oInnerMessage =
|
||||
message.toInner<PubSubChatModeratorActionMessage>();
|
||||
|
||||
@@ -129,26 +129,10 @@ public:
|
||||
Signal<AutomodInfoAction> automodInfoMessage;
|
||||
} moderation;
|
||||
|
||||
struct {
|
||||
// Parsing should be done in PubSubManager as well,
|
||||
// but for now we just send the raw data
|
||||
Signal<const PubSubWhisperMessage &> received;
|
||||
Signal<const PubSubWhisperMessage &> sent;
|
||||
} whisper;
|
||||
|
||||
struct {
|
||||
Signal<const QJsonObject &> redeemed;
|
||||
} pointReward;
|
||||
|
||||
/**
|
||||
* Listen to incoming whispers for the currently logged in user.
|
||||
* This topic is relevant for everyone.
|
||||
*
|
||||
* PubSub topic: whispers.{currentUserID}
|
||||
*/
|
||||
bool listenToWhispers();
|
||||
void unlistenWhispers();
|
||||
|
||||
/**
|
||||
* Listen to moderation actions in the given channel.
|
||||
* This topic is relevant for everyone.
|
||||
|
||||
@@ -8,4 +8,3 @@
|
||||
#include "providers/twitch/pubsubmessages/LowTrustUsers.hpp" // IWYU pragma: export
|
||||
#include "providers/twitch/pubsubmessages/Message.hpp" // IWYU pragma: export
|
||||
#include "providers/twitch/pubsubmessages/Unlisten.hpp" // IWYU pragma: export
|
||||
#include "providers/twitch/pubsubmessages/Whisper.hpp" // IWYU pragma: export
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
#include "providers/twitch/pubsubmessages/Whisper.hpp"
|
||||
|
||||
#include "util/QMagicEnum.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
PubSubWhisperMessage::PubSubWhisperMessage(const QJsonObject &root)
|
||||
: typeString(root.value("type").toString())
|
||||
{
|
||||
auto oType = qmagicenum::enumCast<Type>(this->typeString);
|
||||
if (oType.has_value())
|
||||
{
|
||||
this->type = oType.value();
|
||||
}
|
||||
|
||||
// Parse information from data_object
|
||||
auto data = root.value("data_object").toObject();
|
||||
|
||||
this->messageID = data.value("message_id").toString();
|
||||
this->id = data.value("id").toInt();
|
||||
this->threadID = data.value("thread_id").toString();
|
||||
this->body = data.value("body").toString();
|
||||
auto fromID = data.value("from_id");
|
||||
if (fromID.isString())
|
||||
{
|
||||
this->fromUserID = fromID.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->fromUserID = QString::number(data.value("from_id").toInt());
|
||||
}
|
||||
|
||||
auto tags = data.value("tags").toObject();
|
||||
|
||||
this->fromUserLogin = tags.value("login").toString();
|
||||
this->fromUserDisplayName = tags.value("display_name").toString();
|
||||
this->fromUserColor = QColor(tags.value("color").toString());
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
@@ -1,55 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <QColor>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
struct PubSubWhisperMessage {
|
||||
enum class Type {
|
||||
WhisperReceived,
|
||||
WhisperSent,
|
||||
Thread,
|
||||
|
||||
INVALID,
|
||||
};
|
||||
|
||||
QString typeString;
|
||||
Type type = Type::INVALID;
|
||||
|
||||
QString messageID;
|
||||
int id;
|
||||
QString threadID;
|
||||
QString body;
|
||||
QString fromUserID;
|
||||
QString fromUserLogin;
|
||||
QString fromUserDisplayName;
|
||||
QColor fromUserColor;
|
||||
|
||||
PubSubWhisperMessage() = default;
|
||||
explicit PubSubWhisperMessage(const QJsonObject &root);
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
template <>
|
||||
constexpr magic_enum::customize::customize_t
|
||||
magic_enum::customize::enum_name<chatterino::PubSubWhisperMessage::Type>(
|
||||
chatterino::PubSubWhisperMessage::Type value) noexcept
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case chatterino::PubSubWhisperMessage::Type::WhisperReceived:
|
||||
return "whisper_received";
|
||||
|
||||
case chatterino::PubSubWhisperMessage::Type::WhisperSent:
|
||||
return "whisper_sent";
|
||||
|
||||
case chatterino::PubSubWhisperMessage::Type::Thread:
|
||||
return "thread";
|
||||
default:
|
||||
return default_tag;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "providers/twitch/PubSubClient.hpp"
|
||||
#include "providers/twitch/PubSubManager.hpp"
|
||||
#include "providers/twitch/pubsubmessages/AutoMod.hpp"
|
||||
#include "providers/twitch/pubsubmessages/Whisper.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "Test.hpp"
|
||||
|
||||
@@ -22,7 +21,6 @@ using namespace std::chrono_literals;
|
||||
* Server sends RECONNECT message to us, we should reconnect (INCOMPLETE, leaving for now since if we just ignore it and Twitch disconnects us we should already handle it properly)
|
||||
* Listen that required authentication, but authentication is missing (COMPLETE)
|
||||
* Listen that required authentication, but authentication is wrong (COMPLETE)
|
||||
* Incoming Whisper message (COMPLETE)
|
||||
* Incoming AutoMod message
|
||||
* Incoming ChannelPoints message
|
||||
* Incoming ChatModeratorAction message (COMPLETE)
|
||||
@@ -260,42 +258,6 @@ TEST(TwitchPubSubClient, ExceedTopicLimitSingleStep)
|
||||
ASSERT_EQ(pubSub.diag.connectionsFailed, 0);
|
||||
}
|
||||
|
||||
TEST(TwitchPubSubClient, ReceivedWhisper)
|
||||
{
|
||||
FTest pubSub("/receive-whisper", 1s);
|
||||
|
||||
pubSub.start();
|
||||
|
||||
ReceivedMessage<PubSubWhisperMessage> aReceivedWhisper;
|
||||
|
||||
std::ignore = pubSub.whisper.received.connect(
|
||||
[&aReceivedWhisper](const auto &whisperMessage) {
|
||||
aReceivedWhisper = whisperMessage;
|
||||
});
|
||||
|
||||
pubSub.listenToWhispers();
|
||||
|
||||
std::this_thread::sleep_for(150ms);
|
||||
|
||||
ASSERT_EQ(pubSub.diag.connectionsOpened, 1);
|
||||
ASSERT_EQ(pubSub.diag.connectionsClosed, 0);
|
||||
ASSERT_EQ(pubSub.diag.connectionsFailed, 0);
|
||||
ASSERT_EQ(pubSub.diag.messagesReceived, 3);
|
||||
ASSERT_EQ(pubSub.diag.listenResponses, 1);
|
||||
|
||||
ASSERT_TRUE(aReceivedWhisper);
|
||||
|
||||
ASSERT_EQ(aReceivedWhisper->body, QString("me Kappa"));
|
||||
ASSERT_EQ(aReceivedWhisper->fromUserLogin, QString("pajbot"));
|
||||
ASSERT_EQ(aReceivedWhisper->fromUserID, QString("82008718"));
|
||||
|
||||
pubSub.stop();
|
||||
|
||||
ASSERT_EQ(pubSub.diag.connectionsOpened, 1);
|
||||
ASSERT_EQ(pubSub.diag.connectionsClosed, 1);
|
||||
ASSERT_EQ(pubSub.diag.connectionsFailed, 0);
|
||||
}
|
||||
|
||||
TEST(TwitchPubSubClient, ModeratorActionsUserBanned)
|
||||
{
|
||||
FTest pubSub("/moderator-actions-user-banned", 1s);
|
||||
|
||||
Reference in New Issue
Block a user