chore(pubsub): remove unused whisper code 👷🏻‍♀️ (#5898)

This commit is contained in:
pajlada
2025-02-03 19:18:08 +01:00
committed by GitHub
parent 0c489e0033
commit 5e3412c3bb
8 changed files with 2 additions and 209 deletions
-2
View File
@@ -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
+1 -57
View File
@@ -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>();
-16
View File
@@ -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.
-1
View File
@@ -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;
}
}