Add td_api::updateStorySendFailed.

This commit is contained in:
levlam 2023-08-11 16:41:14 +03:00
parent 732b006bf9
commit 155b447420
2 changed files with 22 additions and 2 deletions

View File

@ -5869,6 +5869,12 @@ updateStoryDeleted story_sender_chat_id:int53 story_id:int32 = Update;
//@description A story has been successfully sent @story The sent story @old_story_id The previous temporary story identifier //@description A story has been successfully sent @story The sent story @old_story_id The previous temporary story identifier
updateStorySendSucceeded story:story old_story_id:int32 = Update; updateStorySendSucceeded story:story old_story_id:int32 = Update;
//@description A story failed to send. If the story sending is cancelled, then updateStoryDeleted will be received instead of this update
//@story The failed to send story
//@error_code An error code
//@error_message Error message
updateStorySendFailed story:story error_code:int32 error_message:string = Update;
//@description The list of active stories posted by a specific chat has changed //@description The list of active stories posted by a specific chat has changed
//@active_stories The new list of active stories //@active_stories The new list of active stories
updateChatActiveStories active_stories:chatActiveStories = Update; updateChatActiveStories active_stories:chatActiveStories = Update;

View File

@ -4188,15 +4188,18 @@ void StoryManager::do_edit_story(FileId file_id, unique_ptr<PendingStory> &&pend
} }
void StoryManager::delete_pending_story(FileId file_id, unique_ptr<PendingStory> &&pending_story, Status status) { void StoryManager::delete_pending_story(FileId file_id, unique_ptr<PendingStory> &&pending_story, Status status) {
if (G()->close_flag() && G()->use_message_database()) {
return;
}
if (file_id.is_valid()) { if (file_id.is_valid()) {
td_->file_manager_->delete_partial_remote_location(file_id); td_->file_manager_->delete_partial_remote_location(file_id);
} }
CHECK(pending_story != nullptr); CHECK(pending_story != nullptr);
StoryFullId story_full_id{pending_story->dialog_id_, pending_story->story_id_};
const Story *story = get_story(story_full_id);
bool is_edit = pending_story->story_id_.is_server(); bool is_edit = pending_story->story_id_.is_server();
if (is_edit) { if (is_edit) {
StoryFullId story_full_id{pending_story->dialog_id_, pending_story->story_id_};
const Story *story = get_story(story_full_id);
auto it = being_edited_stories_.find(story_full_id); auto it = being_edited_stories_.find(story_full_id);
if (story == nullptr || it == being_edited_stories_.end() || if (story == nullptr || it == being_edited_stories_.end() ||
edit_generations_[story_full_id] != pending_story->random_id_) { edit_generations_[story_full_id] != pending_story->random_id_) {
@ -4221,6 +4224,17 @@ void StoryManager::delete_pending_story(FileId file_id, unique_ptr<PendingStory>
CHECK(pending_story->log_event_id_ == 0); CHECK(pending_story->log_event_id_ == 0);
} else { } else {
LOG(INFO) << "Finish sending of story " << pending_story->send_story_num_; LOG(INFO) << "Finish sending of story " << pending_story->send_story_num_;
if (story != nullptr) {
if (status.is_ok()) {
LOG(ERROR) << "Failed to receive sent " << story_full_id;
status = Status::Error(500, "Failed to receive a sent story");
}
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateStorySendFailed>(get_story_object(story_full_id, story),
status.code(), status.message().str()));
delete_story_files(story);
stories_.erase(story_full_id);
}
auto it = yet_unsent_stories_.find(pending_story->dialog_id_); auto it = yet_unsent_stories_.find(pending_story->dialog_id_);
CHECK(it != yet_unsent_stories_.end()); CHECK(it != yet_unsent_stories_.end());
bool is_deleted = it->second.erase(pending_story->send_story_num_) > 0; bool is_deleted = it->second.erase(pending_story->send_story_num_) > 0;