nit: fix some eventsub mini things (#5895)
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
- Bugfix: Fixed announcements not showing up in mentions tab. (#5857)
|
- Bugfix: Fixed announcements not showing up in mentions tab. (#5857)
|
||||||
- Bugfix: Fixed the reply button showing for inline whispers and announcements. (#5863)
|
- Bugfix: Fixed the reply button showing for inline whispers and announcements. (#5863)
|
||||||
- Bugfix: Fixed suspicious user treatment update messages not being searchable. (#5865)
|
- Bugfix: Fixed suspicious user treatment update messages not being searchable. (#5865)
|
||||||
- Dev: Add initial experimental EventSub support. (#5837)
|
- Dev: Add initial experimental EventSub support. (#5837, #5895)
|
||||||
- Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784)
|
- Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784)
|
||||||
- Dev: Updated Conan dependencies. (#5776)
|
- Dev: Updated Conan dependencies. (#5776)
|
||||||
- Dev: Disable QT keywords (i.e. `emit`, `slots`, and `signals`). (#5882)
|
- Dev: Disable QT keywords (i.e. `emit`, `slots`, and `signals`). (#5882)
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <boost/json/object.hpp>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <optional>
|
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
namespace chatterino::eventsub::lib {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
std::optional<T> readMember(const boost::json::object &obj,
|
|
||||||
std::string_view key)
|
|
||||||
{
|
|
||||||
const auto *it = obj.find(key);
|
|
||||||
|
|
||||||
if (it == obj.end())
|
|
||||||
{
|
|
||||||
// No member with the key found
|
|
||||||
std::cerr << "No member with the key " << key << " found\n";
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto result = boost::json::try_value_to<T>(it->value());
|
|
||||||
if (!result.has_value())
|
|
||||||
{
|
|
||||||
std::cerr << key << " could not be deserialized to the desired type\n";
|
|
||||||
// Member could not be serialized to this type
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace chatterino::eventsub::lib
|
|
||||||
@@ -461,8 +461,6 @@ CommandController::CommandController(const Paths &paths)
|
|||||||
|
|
||||||
this->registerCommand("/debug-test", &commands::debugTest);
|
this->registerCommand("/debug-test", &commands::debugTest);
|
||||||
|
|
||||||
this->registerCommand("/debug-eventsub", &commands::debugEventSub);
|
|
||||||
|
|
||||||
this->registerCommand("/shield", &commands::shieldModeOn);
|
this->registerCommand("/shield", &commands::shieldModeOn);
|
||||||
this->registerCommand("/shieldoff", &commands::shieldModeOff);
|
this->registerCommand("/shieldoff", &commands::shieldModeOff);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#include "messages/Message.hpp"
|
#include "messages/Message.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
#include "messages/MessageElement.hpp"
|
#include "messages/MessageElement.hpp"
|
||||||
#include "providers/twitch/eventsub/Controller.hpp"
|
|
||||||
#include "providers/twitch/PubSubActions.hpp"
|
#include "providers/twitch/PubSubActions.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||||
@@ -190,57 +189,4 @@ QString debugTest(const CommandContext &ctx)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString debugEventSub(const CommandContext &ctx)
|
|
||||||
{
|
|
||||||
(void)ctx;
|
|
||||||
|
|
||||||
if (ctx.twitchChannel == nullptr)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// purposefully subscribe multiple times to ensure we can't sub too many times
|
|
||||||
// or create too many connections
|
|
||||||
|
|
||||||
static eventsub::SubscriptionHandle handle1;
|
|
||||||
|
|
||||||
handle1 = getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
|
|
||||||
.subscriptionType = "channel.ban",
|
|
||||||
.subscriptionVersion = "1",
|
|
||||||
.conditions =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"broadcaster_user_id",
|
|
||||||
ctx.twitchChannel->roomId(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
auto handle2 =
|
|
||||||
getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
|
|
||||||
.subscriptionType = "channel.ban",
|
|
||||||
.subscriptionVersion = "1",
|
|
||||||
.conditions =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"broadcaster_user_id",
|
|
||||||
ctx.twitchChannel->roomId(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
auto handle3 =
|
|
||||||
getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
|
|
||||||
.subscriptionType = "channel.ban",
|
|
||||||
.subscriptionVersion = "1",
|
|
||||||
.conditions =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"broadcaster_user_id",
|
|
||||||
ctx.twitchChannel->roomId(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace chatterino::commands
|
} // namespace chatterino::commands
|
||||||
|
|||||||
@@ -24,6 +24,4 @@ QString forceImageUnload(const CommandContext &ctx);
|
|||||||
|
|
||||||
QString debugTest(const CommandContext &ctx);
|
QString debugTest(const CommandContext &ctx);
|
||||||
|
|
||||||
QString debugEventSub(const CommandContext &ctx);
|
|
||||||
|
|
||||||
} // namespace chatterino::commands
|
} // namespace chatterino::commands
|
||||||
|
|||||||
@@ -1473,18 +1473,6 @@ void TwitchChannel::refreshPubSub()
|
|||||||
{
|
{
|
||||||
getApp()->getTwitchPubSub()->listenToAutomod(roomId);
|
getApp()->getTwitchPubSub()->listenToAutomod(roomId);
|
||||||
getApp()->getTwitchPubSub()->listenToLowTrustUsers(roomId);
|
getApp()->getTwitchPubSub()->listenToLowTrustUsers(roomId);
|
||||||
this->eventSubChannelBanHandle =
|
|
||||||
getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
|
|
||||||
.subscriptionType = "channel.ban",
|
|
||||||
.subscriptionVersion = "1",
|
|
||||||
.conditions =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"broadcaster_user_id",
|
|
||||||
roomId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
this->eventSubChannelModerateHandle =
|
this->eventSubChannelModerateHandle =
|
||||||
getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
|
getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
|
||||||
@@ -1505,7 +1493,7 @@ void TwitchChannel::refreshPubSub()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->eventSubChannelBanHandle.reset();
|
this->eventSubChannelModerateHandle.reset();
|
||||||
}
|
}
|
||||||
getApp()->getTwitchPubSub()->listenToChannelPointRewards(roomId);
|
getApp()->getTwitchPubSub()->listenToChannelPointRewards(roomId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -500,7 +500,6 @@ private:
|
|||||||
pajlada::Signals::SignalHolder signalHolder_;
|
pajlada::Signals::SignalHolder signalHolder_;
|
||||||
std::vector<boost::signals2::scoped_connection> bSignals_;
|
std::vector<boost::signals2::scoped_connection> bSignals_;
|
||||||
|
|
||||||
eventsub::SubscriptionHandle eventSubChannelBanHandle;
|
|
||||||
eventsub::SubscriptionHandle eventSubChannelModerateHandle;
|
eventsub::SubscriptionHandle eventSubChannelModerateHandle;
|
||||||
|
|
||||||
friend class TwitchIrcServer;
|
friend class TwitchIrcServer;
|
||||||
|
|||||||
@@ -31,10 +31,6 @@ public:
|
|||||||
///
|
///
|
||||||
/// If no open connection has room for this subscription, this function will
|
/// If no open connection has room for this subscription, this function will
|
||||||
/// create a new connection and queue up the subscription to run again after X seconds.
|
/// create a new connection and queue up the subscription to run again after X seconds.
|
||||||
///
|
|
||||||
/// TODO: Return a SubscriptionHandle that handles unsubscriptions
|
|
||||||
/// Dupe subscriptions should return shared subscription handles
|
|
||||||
/// So no more owners of the subscription handle means we send an unsubscribe request
|
|
||||||
[[nodiscard]] virtual SubscriptionHandle subscribe(
|
[[nodiscard]] virtual SubscriptionHandle subscribe(
|
||||||
const SubscriptionRequest &request) = 0;
|
const SubscriptionRequest &request) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace chatterino::eventsub {
|
|||||||
RawSubscriptionHandle::RawSubscriptionHandle(SubscriptionRequest request_)
|
RawSubscriptionHandle::RawSubscriptionHandle(SubscriptionRequest request_)
|
||||||
: request(std::move(request_))
|
: request(std::move(request_))
|
||||||
{
|
{
|
||||||
// getApp()->getEventSub()->addRef(request);
|
// The reference is added by the EventSub controller
|
||||||
}
|
}
|
||||||
|
|
||||||
RawSubscriptionHandle::~RawSubscriptionHandle()
|
RawSubscriptionHandle::~RawSubscriptionHandle()
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ struct RawSubscriptionHandle {
|
|||||||
~RawSubscriptionHandle();
|
~RawSubscriptionHandle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Keeps a reference count of a specific subscription
|
||||||
|
///
|
||||||
|
/// If no more references exist of a specific subscription, we send an
|
||||||
|
/// unsubscription request
|
||||||
using SubscriptionHandle = std::unique_ptr<RawSubscriptionHandle>;
|
using SubscriptionHandle = std::unique_ptr<RawSubscriptionHandle>;
|
||||||
|
|
||||||
} // namespace chatterino::eventsub
|
} // namespace chatterino::eventsub
|
||||||
|
|||||||
Reference in New Issue
Block a user