mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
send: don't repeat post-send actions on queue resumes
A resumed SendMediaSequence (batch_index>0 or already-sent ids) ran post_send_actions again, opening a second edit prompt and inserting a second edit_message record for the same messages — both Forward buttons worked, enabling double forwards. Resumes now skip it.
This commit is contained in:
@@ -1129,6 +1129,18 @@ pub async fn handle_task(payload: serde_json::Value) -> Result<(), QueueError> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let bot = Bot::from_env();
|
let bot = Bot::from_env();
|
||||||
|
// 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 {
|
||||||
@@ -1150,7 +1162,9 @@ pub async fn handle_task(payload: serde_json::Value) -> Result<(), QueueError> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
post_send_actions(&bot, &task, message_ids).await;
|
if !resumed {
|
||||||
|
post_send_actions(&bot, &task, message_ids).await;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Task::ForwardMessages { .. } => match forward_messages(&bot, &task).await {
|
Task::ForwardMessages { .. } => match forward_messages(&bot, &task).await {
|
||||||
|
|||||||
Reference in New Issue
Block a user