feat: refund more
This commit is contained in:
parent
add0e4197b
commit
58718263d7
|
@ -191,13 +191,25 @@ pub async fn handle_pubsub(state: Arc<State>, event: WsMessage) -> anyhow::Resul
|
||||||
async fn rename_a_split(state: Arc<State>, redemption: &Redemption) {
|
async fn rename_a_split(state: Arc<State>, redemption: &Redemption) {
|
||||||
let input = match &redemption.user_input {
|
let input = match &redemption.user_input {
|
||||||
Some(i) => i,
|
Some(i) => i,
|
||||||
None => return,
|
None => {
|
||||||
|
if let Err(e) = update_redemption_status(&*state, &redemption, CustomRewardRedemptionStatus::Canceled).await {
|
||||||
|
eprintln!("could not update redemption status: {:?}", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let (old, new) = match input.split_once("=>")
|
let (old, new) = match input.split_once("=>")
|
||||||
.or_else(|| input.split_once("->"))
|
.or_else(|| input.split_once("->"))
|
||||||
{
|
{
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return,
|
None => {
|
||||||
|
if let Err(e) = update_redemption_status(&*state, &redemption, CustomRewardRedemptionStatus::Canceled).await {
|
||||||
|
eprintln!("could not update redemption status: {:?}", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let fulfilled = match reqwest::Client::new()
|
let fulfilled = match reqwest::Client::new()
|
||||||
|
@ -220,6 +232,12 @@ async fn rename_a_split(state: Arc<State>, redemption: &Redemption) {
|
||||||
CustomRewardRedemptionStatus::Canceled
|
CustomRewardRedemptionStatus::Canceled
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Err(e) = update_redemption_status(&*state, &redemption, status).await {
|
||||||
|
eprintln!("could not update redemption status: {:?}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update_redemption_status(state: &State, redemption: &Redemption, status: CustomRewardRedemptionStatus) -> anyhow::Result<()> {
|
||||||
let req = UpdateRedemptionStatusRequest::builder()
|
let req = UpdateRedemptionStatusRequest::builder()
|
||||||
.broadcaster_id(state.user_config.twitch.channel_id.to_string())
|
.broadcaster_id(state.user_config.twitch.channel_id.to_string())
|
||||||
.reward_id(redemption.reward.id.clone())
|
.reward_id(redemption.reward.id.clone())
|
||||||
|
@ -230,11 +248,11 @@ async fn rename_a_split(state: Arc<State>, redemption: &Redemption) {
|
||||||
.status(status)
|
.status(status)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if let Ok(token) = state.twitch.user_token().await {
|
let token = state.twitch.user_token().await?;
|
||||||
if let Err(e) = state.twitch.client.helix.req_patch(req, body, &token).await {
|
state.twitch.client.helix.req_patch(req, body, &token).await
|
||||||
eprintln!("could not update redemption status: {:?}", e);
|
.context("could not update redemption status")?;
|
||||||
}
|
|
||||||
}
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_channel_points_reply(state: Arc<State>, reply: Box<ChannelPointsChannelV1Reply>) -> anyhow::Result<()> {
|
async fn handle_channel_points_reply(state: Arc<State>, reply: Box<ChannelPointsChannelV1Reply>) -> anyhow::Result<()> {
|
||||||
|
|
Loading…
Reference in New Issue