mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
fix(send): run post_send_actions after retried sends
A task only reaches the queue after a failed send, so the fresh attempt never ran post_send_actions (edit-before-forward prompt / channel forward) — it failed before that point. The old guard skipped post_send_actions for resumed tasks (batch_index > 0 or sent ids present), which meant any send that needed a retry after partial progress silently lost its forward and edit prompt. post_send_actions is now run unconditionally on a successful queue send; it executes exactly once, after the whole sequence completed.
This commit is contained in:
@@ -1321,18 +1321,6 @@ pub async fn handle_task(payload: serde_json::Value) -> Result<(), QueueError> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let bot = BOT.clone();
|
let bot = BOT.clone();
|
||||||
// A resumed multi-batch send already ran post_send_actions (edit prompt /
|
|
||||||
// forward) when it first started; running them again on the resume would
|
|
||||||
// open a duplicate edit prompt and double-forward. SendAnimation is
|
|
||||||
// atomic (always a fresh run), so only SendMediaSequence can resume.
|
|
||||||
let resumed = matches!(
|
|
||||||
&task,
|
|
||||||
Task::SendMediaSequence {
|
|
||||||
batch_index,
|
|
||||||
sent_message_ids,
|
|
||||||
..
|
|
||||||
} if *batch_index > 0 || !sent_message_ids.is_empty()
|
|
||||||
);
|
|
||||||
match task {
|
match task {
|
||||||
Task::SendMediaSequence { .. } | Task::SendAnimation { .. } => {
|
Task::SendMediaSequence { .. } | Task::SendAnimation { .. } => {
|
||||||
let message_ids = match send_media_or_animation(&bot, &task).await {
|
let message_ids = match send_media_or_animation(&bot, &task).await {
|
||||||
@@ -1356,9 +1344,14 @@ pub async fn handle_task(payload: serde_json::Value) -> Result<(), QueueError> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if !resumed {
|
// A task only reaches the queue after a failed send, so this
|
||||||
post_send_actions(&bot, &task, message_ids).await;
|
// successful run is the first time post_send_actions can fire —
|
||||||
}
|
// the fresh attempt failed before it ever got here. Run it
|
||||||
|
// unconditionally: `post_send_actions` executes once, after the
|
||||||
|
// whole sequence (every batch) completed, so the channel forward
|
||||||
|
// and the edit-before-forward prompt must not be lost just
|
||||||
|
// because the send needed a retry.
|
||||||
|
post_send_actions(&bot, &task, message_ids).await;
|
||||||
release_keep_alive(&task);
|
release_keep_alive(&task);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user