mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 08:57:54 +00:00
save both event types to db
This commit is contained in:
1 parent
da5c1893b3
commit
6445244957
2 files changed
+43
-16
No files matched your search
@@ -52,29 +52,24 @@ impl TwitchPubsubChannelPointsInsertBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_sender_twitch_user_id(mut self, value: Option<&str>) -> Self {
|
||||
self.sender_twitch_user_id = value.map(|s| s.to_string());
|
||||
pub fn set_sender_twitch_user_id(mut self, value: &str) -> Self {
|
||||
self.sender_twitch_user_id = Some(value.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_sender_twitch_username(mut self, value: Option<&str>) -> Self {
|
||||
if let Some(username) = value {
|
||||
self.sender_twitch_username = Some(username.to_string());
|
||||
self.sender_twitch_username_lowercase = Some(username.to_uppercase());
|
||||
} else {
|
||||
self.sender_twitch_username = None;
|
||||
self.sender_twitch_username_lowercase = None;
|
||||
}
|
||||
pub fn set_sender_twitch_username(mut self, value: &str) -> Self {
|
||||
self.sender_twitch_username = Some(value.to_string());
|
||||
self.sender_twitch_username_lowercase = Some(value.to_uppercase());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_destination_channel_id(mut self, value: Option<&str>) -> Self {
|
||||
self.destination_channel_id = value.map(|s| s.to_string());
|
||||
pub fn set_destination_channel_id(mut self, value: &str) -> Self {
|
||||
self.destination_channel_id = Some(value.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_destination_channel_name(mut self, value: Option<&str>) -> Self {
|
||||
self.destination_channel_name = value.map(|s| s.to_string());
|
||||
pub fn set_destination_channel_name(mut self, value: &str) -> Self {
|
||||
self.destination_channel_name = Some(value.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
@@ -88,8 +83,10 @@ impl TwitchPubsubChannelPointsInsertBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_user_tet_input(mut self, value: &str) -> Self {
|
||||
self.user_text_input = value.to_string();
|
||||
pub fn set_user_text_input(mut self, value: Option<&str>) -> Self {
|
||||
self.user_text_input = value
|
||||
.map(|s| s.to_string())
|
||||
.unwrap_or("".to_string());
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ use std::time::Duration;
|
||||
use time::Instant;
|
||||
use twitch_api2::pubsub::{Response, TwitchResponse, TopicData};
|
||||
use twitch_api2::pubsub::channel_bits::ChannelBitsEventsV2Reply;
|
||||
use twitch_api2::pubsub::channel_points::ChannelPointsChannelV1Reply;
|
||||
|
||||
// TODO: Publish events back to OBS thread
|
||||
// TODO: (cleanup) make the logic clearer to follow.
|
||||
@@ -330,6 +331,35 @@ impl TwitchPubsubUserSubscriberThreadStageTwo {
|
||||
}
|
||||
}
|
||||
TopicData::ChannelPointsChannelV1 { topic, reply } => {
|
||||
let mut event_builder = TwitchPubsubChannelPointsInsertBuilder::new();
|
||||
match *reply {
|
||||
// Unimplemented
|
||||
ChannelPointsChannelV1Reply::CustomRewardUpdated { .. } => {}
|
||||
ChannelPointsChannelV1Reply::RedemptionStatusUpdate { .. } => {}
|
||||
ChannelPointsChannelV1Reply::UpdateRedemptionStatusesFinished { .. } => {}
|
||||
ChannelPointsChannelV1Reply::UpdateRedemptionStatusProgress { .. } => {}
|
||||
// Implemented
|
||||
ChannelPointsChannelV1Reply::RewardRedeemed { timestamp, redemption } => {
|
||||
let user_id = redemption.user.id.to_string();
|
||||
let user_name = redemption.user.login.to_string();
|
||||
let mut event_builder = event_builder.set_sender_twitch_user_id(&user_id)
|
||||
.set_sender_twitch_username(&user_name)
|
||||
.set_destination_channel_id(&redemption.channel_id.to_string())
|
||||
// TODO:
|
||||
.set_destination_channel_name("todo: not available")
|
||||
.set_title(&redemption.reward.title)
|
||||
.set_prompt(&redemption.reward.prompt)
|
||||
.set_user_text_input(redemption.user_input.as_deref())
|
||||
.set_redemption_id(&redemption.id.to_string())
|
||||
.set_reward_id(&redemption.reward.id.to_string())
|
||||
.set_is_sub_only(redemption.reward.is_sub_only);
|
||||
// TODO:
|
||||
// .set_max_per_stream(redemption.reward.max_per_stream as u64)
|
||||
// .set_max_per_user_per_stream(redemption.reward.max_per_user_per_stream as u64);
|
||||
event_builder.insert(&self.mysql_pool).await?;
|
||||
}
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user