Skip to content

Commit 7fcf409

Browse files
committed
fix(slack): acknowledge recieved messages
1 parent 5e0efdb commit 7fcf409

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/channels/slack.rs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -386,19 +386,29 @@ async fn handle_push_events(
386386
.get_user_state::<SlackUserState>()
387387
.ok_or("Missing user state")?;
388388

389-
if let Err(e) = handle_message_event(
390-
msg_event,
391-
client,
392-
user_state.bot_token.clone(),
393-
user_state.bot_token_str.clone(),
394-
user_state.bot_user_id.clone(),
395-
user_state.task_manager.clone(),
396-
user_state.user_threads.clone(),
397-
)
398-
.await
399-
{
400-
warn!("Error handling Slack message: {}", e);
401-
}
389+
// Spawn message handling in background so we ack the event immediately
390+
// This prevents Slack from retrying delivery
391+
let bot_token = user_state.bot_token.clone();
392+
let bot_token_str = user_state.bot_token_str.clone();
393+
let bot_user_id = user_state.bot_user_id.clone();
394+
let task_manager = user_state.task_manager.clone();
395+
let user_threads = user_state.user_threads.clone();
396+
397+
tokio::spawn(async move {
398+
if let Err(e) = handle_message_event(
399+
msg_event,
400+
client,
401+
bot_token,
402+
bot_token_str,
403+
bot_user_id,
404+
task_manager,
405+
user_threads,
406+
)
407+
.await
408+
{
409+
warn!("Error handling Slack message: {}", e);
410+
}
411+
});
402412
}
403413
_ => {
404414
debug!("Ignoring event type: {:?}", event);
@@ -470,10 +480,12 @@ async fn handle_message_event(
470480
}
471481

472482
info!(
473-
"Message from {} in channel {} (thread: {:?}): {}{}",
483+
"Message from {} in channel {} (thread: {:?}, ts: {}, subtype: {:?}): {}{}",
474484
user_id,
475485
channel_id,
476486
thread_ts,
487+
event.origin.ts,
488+
event.subtype,
477489
text,
478490
if image_paths.is_empty() {
479491
String::new()

0 commit comments

Comments
 (0)