Add webhook already handled check
Fix all tests Add woodpecker ci (tests + release)
This commit is contained in:
+9
-4
@@ -58,10 +58,15 @@ async fn webhook(
|
||||
) -> Result<impl IntoResponse, AppError> {
|
||||
tracing::Span::current().record("webhook_type", tracing::field::debug(&wb));
|
||||
|
||||
app_state
|
||||
.bot_tx
|
||||
.try_send(wb)
|
||||
.map_err(|_| AppError::ChannelFullErr)?;
|
||||
let event_id = wb.event_id();
|
||||
if app_state.bot.check_and_mark(event_id).await {
|
||||
return Err(AppError::AlreadyProcessedErr);
|
||||
}
|
||||
|
||||
if app_state.bot_tx.try_send(wb).is_err() {
|
||||
app_state.bot.unmark(event_id).await;
|
||||
return Err(AppError::ChannelFullErr);
|
||||
}
|
||||
|
||||
Ok((StatusCode::CREATED, "Task started"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user