refactor(eventsub): more references, less const (#5953)
This commit is contained in:
@@ -18,39 +18,40 @@ public:
|
||||
virtual ~Listener() = default;
|
||||
|
||||
virtual void onSessionWelcome(
|
||||
messages::Metadata metadata,
|
||||
payload::session_welcome::Payload payload) = 0;
|
||||
const messages::Metadata &metadata,
|
||||
const payload::session_welcome::Payload &payload) = 0;
|
||||
|
||||
virtual void onNotification(messages::Metadata metadata,
|
||||
virtual void onNotification(const messages::Metadata &metadata,
|
||||
const boost::json::value &jv) = 0;
|
||||
|
||||
// Subscription types
|
||||
virtual void onChannelBan(messages::Metadata metadata,
|
||||
payload::channel_ban::v1::Payload payload) = 0;
|
||||
virtual void onChannelBan(
|
||||
const messages::Metadata &metadata,
|
||||
const payload::channel_ban::v1::Payload &payload) = 0;
|
||||
|
||||
virtual void onStreamOnline(
|
||||
messages::Metadata metadata,
|
||||
payload::stream_online::v1::Payload payload) = 0;
|
||||
const messages::Metadata &metadata,
|
||||
const payload::stream_online::v1::Payload &payload) = 0;
|
||||
|
||||
virtual void onStreamOffline(
|
||||
messages::Metadata metadata,
|
||||
payload::stream_offline::v1::Payload payload) = 0;
|
||||
const messages::Metadata &metadata,
|
||||
const payload::stream_offline::v1::Payload &payload) = 0;
|
||||
|
||||
virtual void onChannelChatNotification(
|
||||
messages::Metadata metadata,
|
||||
payload::channel_chat_notification::v1::Payload payload) = 0;
|
||||
const messages::Metadata &metadata,
|
||||
const payload::channel_chat_notification::v1::Payload &payload) = 0;
|
||||
|
||||
virtual void onChannelUpdate(
|
||||
messages::Metadata metadata,
|
||||
payload::channel_update::v1::Payload payload) = 0;
|
||||
const messages::Metadata &metadata,
|
||||
const payload::channel_update::v1::Payload &payload) = 0;
|
||||
|
||||
virtual void onChannelChatMessage(
|
||||
messages::Metadata metadata,
|
||||
payload::channel_chat_message::v1::Payload payload) = 0;
|
||||
const messages::Metadata &metadata,
|
||||
const payload::channel_chat_message::v1::Payload &payload) = 0;
|
||||
|
||||
virtual void onChannelModerate(
|
||||
messages::Metadata metadata,
|
||||
payload::channel_moderate::v2::Payload payload) = 0;
|
||||
const messages::Metadata &metadata,
|
||||
const payload::channel_moderate::v2::Payload &payload) = 0;
|
||||
|
||||
// Add your new subscription types above this line
|
||||
};
|
||||
|
||||
@@ -21,13 +21,13 @@ namespace chatterino::eventsub::lib::messages {
|
||||
*/
|
||||
|
||||
struct Metadata {
|
||||
const std::string messageID;
|
||||
const std::string messageType;
|
||||
std::string messageID;
|
||||
std::string messageType;
|
||||
// TODO: should this be chronofied?
|
||||
const std::string messageTimestamp;
|
||||
std::string messageTimestamp;
|
||||
|
||||
const std::optional<std::string> subscriptionType;
|
||||
const std::optional<std::string> subscriptionVersion;
|
||||
std::optional<std::string> subscriptionType;
|
||||
std::optional<std::string> subscriptionVersion;
|
||||
};
|
||||
|
||||
#include "twitch-eventsub-ws/messages/metadata.inc"
|
||||
|
||||
@@ -91,9 +91,9 @@ struct Event {
|
||||
};
|
||||
|
||||
struct Payload {
|
||||
const subscription::Subscription subscription;
|
||||
subscription::Subscription subscription;
|
||||
|
||||
const Event event;
|
||||
Event event;
|
||||
};
|
||||
|
||||
#include "twitch-eventsub-ws/payloads/channel-ban-v1.inc"
|
||||
|
||||
+2
-2
@@ -135,9 +135,9 @@ struct Event {
|
||||
};
|
||||
|
||||
struct Payload {
|
||||
const subscription::Subscription subscription;
|
||||
subscription::Subscription subscription;
|
||||
|
||||
const Event event;
|
||||
Event event;
|
||||
};
|
||||
|
||||
#include "twitch-eventsub-ws/payloads/channel-chat-message-v1.inc"
|
||||
|
||||
+2
-2
@@ -190,9 +190,9 @@ struct Event {
|
||||
};
|
||||
|
||||
struct Payload {
|
||||
const subscription::Subscription subscription;
|
||||
subscription::Subscription subscription;
|
||||
|
||||
const Event event;
|
||||
Event event;
|
||||
};
|
||||
|
||||
#include "twitch-eventsub-ws/payloads/channel-chat-notification-v1.inc"
|
||||
|
||||
@@ -10,31 +10,31 @@ namespace chatterino::eventsub::lib::payload::channel_update::v1 {
|
||||
|
||||
struct Event {
|
||||
// The broadcaster's user ID
|
||||
const std::string broadcasterUserID;
|
||||
std::string broadcasterUserID;
|
||||
// The broadcaster's user login
|
||||
const std::string broadcasterUserLogin;
|
||||
std::string broadcasterUserLogin;
|
||||
// The broadcaster's user display name
|
||||
const std::string broadcasterUserName;
|
||||
std::string broadcasterUserName;
|
||||
|
||||
// The channel's stream title
|
||||
const std::string title;
|
||||
std::string title;
|
||||
|
||||
// The channel's broadcast language
|
||||
const std::string language;
|
||||
std::string language;
|
||||
|
||||
// The channels category ID
|
||||
const std::string categoryID;
|
||||
std::string categoryID;
|
||||
// The category name
|
||||
const std::string categoryName;
|
||||
std::string categoryName;
|
||||
|
||||
// A boolean identifying whether the channel is flagged as mature
|
||||
const bool isMature;
|
||||
bool isMature;
|
||||
};
|
||||
|
||||
struct Payload {
|
||||
const subscription::Subscription subscription;
|
||||
subscription::Subscription subscription;
|
||||
|
||||
const Event event;
|
||||
Event event;
|
||||
};
|
||||
|
||||
#include "twitch-eventsub-ws/payloads/channel-update-v1.inc"
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace chatterino::eventsub::lib::payload::session_welcome {
|
||||
|
||||
/// json_inner=session
|
||||
struct Payload {
|
||||
const std::string id;
|
||||
std::string id;
|
||||
};
|
||||
|
||||
#include "twitch-eventsub-ws/payloads/session-welcome.inc"
|
||||
|
||||
@@ -10,17 +10,17 @@ namespace chatterino::eventsub::lib::payload::stream_offline::v1 {
|
||||
|
||||
struct Event {
|
||||
// The broadcaster's user ID
|
||||
const std::string broadcasterUserID;
|
||||
std::string broadcasterUserID;
|
||||
// The broadcaster's user login
|
||||
const std::string broadcasterUserLogin;
|
||||
std::string broadcasterUserLogin;
|
||||
// The broadcaster's user display name
|
||||
const std::string broadcasterUserName;
|
||||
std::string broadcasterUserName;
|
||||
};
|
||||
|
||||
struct Payload {
|
||||
const subscription::Subscription subscription;
|
||||
subscription::Subscription subscription;
|
||||
|
||||
const Event event;
|
||||
Event event;
|
||||
};
|
||||
|
||||
#include "twitch-eventsub-ws/payloads/stream-offline-v1.inc"
|
||||
|
||||
@@ -10,27 +10,27 @@ namespace chatterino::eventsub::lib::payload::stream_online::v1 {
|
||||
|
||||
struct Event {
|
||||
// The ID of the stream
|
||||
const std::string id;
|
||||
std::string id;
|
||||
|
||||
// The broadcaster's user ID
|
||||
const std::string broadcasterUserID;
|
||||
std::string broadcasterUserID;
|
||||
// The broadcaster's user login
|
||||
const std::string broadcasterUserLogin;
|
||||
std::string broadcasterUserLogin;
|
||||
// The broadcaster's user display name
|
||||
const std::string broadcasterUserName;
|
||||
std::string broadcasterUserName;
|
||||
|
||||
// The stream type (e.g. live, playlist, watch_party)
|
||||
const std::string type;
|
||||
std::string type;
|
||||
|
||||
// The timestamp at which the stream went online
|
||||
// TODO: chronofy?
|
||||
const std::string startedAt;
|
||||
std::string startedAt;
|
||||
};
|
||||
|
||||
struct Payload {
|
||||
const subscription::Subscription subscription;
|
||||
subscription::Subscription subscription;
|
||||
|
||||
const Event event;
|
||||
Event event;
|
||||
};
|
||||
|
||||
#include "twitch-eventsub-ws/payloads/stream-online-v1.inc"
|
||||
|
||||
@@ -33,23 +33,23 @@ namespace chatterino::eventsub::lib::payload::subscription {
|
||||
*/
|
||||
|
||||
struct Transport {
|
||||
const std::string method;
|
||||
const std::string sessionID;
|
||||
std::string method;
|
||||
std::string sessionID;
|
||||
};
|
||||
|
||||
struct Subscription {
|
||||
const std::string id;
|
||||
const std::string status;
|
||||
const std::string type;
|
||||
const std::string version;
|
||||
std::string id;
|
||||
std::string status;
|
||||
std::string type;
|
||||
std::string version;
|
||||
|
||||
// TODO: How do we map condition here? vector of key/value pairs?
|
||||
|
||||
const Transport transport;
|
||||
Transport transport;
|
||||
|
||||
// TODO: chronofy?
|
||||
const std::string createdAt;
|
||||
const int cost;
|
||||
std::string createdAt;
|
||||
int cost;
|
||||
};
|
||||
|
||||
#include "twitch-eventsub-ws/payloads/subscription.inc"
|
||||
|
||||
Reference in New Issue
Block a user