Support FILE_PART_MISSING errors for stories.
This commit is contained in:
parent
04764cbc2e
commit
173ba06d62
@ -186,7 +186,13 @@ class StoryManager::SendStoryQuery final : public Td::ResultHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
if (begins_with(status.message(), "FILE_PART_") && ends_with(status.message(), "_MISSING")) {
|
||||
td_->story_manager_->on_send_story_file_part_missing(std::move(pending_story_),
|
||||
to_integer<int32>(status.message().substr(10)));
|
||||
return;
|
||||
} else {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -551,17 +557,17 @@ void StoryManager::send_story(td_api::object_ptr<td_api::InputStoryContent> &&in
|
||||
random_id = Random::secure_int64();
|
||||
} while (random_id == 0);
|
||||
|
||||
// auto log_event_id = save_send_story_log_event(dialog_id, random_id, story.get());
|
||||
auto story_ptr = story.get();
|
||||
|
||||
do_send_story(dialog_id, StoryId(), 0 /*log_event_id*/, ++send_story_count_, random_id, std::move(story), {},
|
||||
std::move(promise));
|
||||
do_send_story(dialog_id, StoryId(), 0 /*log_event_id*/, ++send_story_count_, random_id, std::move(story), {});
|
||||
|
||||
promise.set_value(get_story_object({dialog_id, StoryId()}, story_ptr));
|
||||
}
|
||||
|
||||
void StoryManager::do_send_story(DialogId dialog_id, StoryId story_id, uint64 log_event_id, uint32 send_story_num,
|
||||
int64 random_id, unique_ptr<Story> &&story, vector<int> bad_parts,
|
||||
Promise<td_api::object_ptr<td_api::story>> &&promise) {
|
||||
auto story_ptr = story.get();
|
||||
auto content = story_ptr->content_.get();
|
||||
int64 random_id, unique_ptr<Story> &&story, vector<int> bad_parts) {
|
||||
CHECK(story != nullptr);
|
||||
auto content = story->content_.get();
|
||||
CHECK(content != nullptr);
|
||||
|
||||
FileId file_id = get_story_content_any_file_id(td_, content);
|
||||
@ -575,8 +581,6 @@ void StoryManager::do_send_story(DialogId dialog_id, StoryId story_id, uint64 lo
|
||||
// need to call resume_upload synchronously to make upload process consistent with being_uploaded_files_
|
||||
// and to send is_uploading_active == true in response
|
||||
td_->file_manager_->resume_upload(file_id, std::move(bad_parts), upload_media_callback_, 1, send_story_num);
|
||||
|
||||
promise.set_value(get_story_object({dialog_id, story_id}, story_ptr));
|
||||
}
|
||||
|
||||
void StoryManager::on_upload_story(FileId file_id, telegram_api::object_ptr<telegram_api::InputFile> input_file) {
|
||||
@ -623,4 +627,10 @@ void StoryManager::on_upload_story_error(FileId file_id, Status status) {
|
||||
being_uploaded_files_.erase(it);
|
||||
}
|
||||
|
||||
void StoryManager::on_send_story_file_part_missing(unique_ptr<PendingStory> &&pending_story, int bad_part) {
|
||||
do_send_story(pending_story->dialog_id_, pending_story->story_id_, pending_story->log_event_id_,
|
||||
pending_story->send_story_num_, pending_story->random_id_, std::move(pending_story->story_),
|
||||
{bad_part});
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -31,39 +31,6 @@ class StoryContent;
|
||||
class Td;
|
||||
|
||||
class StoryManager final : public Actor {
|
||||
public:
|
||||
StoryManager(Td *td, ActorShared<> parent);
|
||||
StoryManager(const StoryManager &) = delete;
|
||||
StoryManager &operator=(const StoryManager &) = delete;
|
||||
StoryManager(StoryManager &&) = delete;
|
||||
StoryManager &operator=(StoryManager &&) = delete;
|
||||
~StoryManager() final;
|
||||
|
||||
void send_story(td_api::object_ptr<td_api::InputStoryContent> &&input_story_content,
|
||||
td_api::object_ptr<td_api::formattedText> &&input_caption,
|
||||
td_api::object_ptr<td_api::userPrivacySettingRules> &&rules, bool is_pinned,
|
||||
Promise<td_api::object_ptr<td_api::story>> &&promise);
|
||||
|
||||
void get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId from_story_id, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
void get_dialog_expiring_stories(DialogId owner_dialog_id, Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
StoryId on_get_story(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::storyItem> &&story_item);
|
||||
|
||||
std::pair<int32, vector<StoryId>> on_get_stories(DialogId owner_dialog_id,
|
||||
telegram_api::object_ptr<telegram_api::stories_stories> &&stories);
|
||||
|
||||
td_api::object_ptr<td_api::story> get_story_object(StoryFullId story_full_id) const;
|
||||
|
||||
td_api::object_ptr<td_api::stories> get_stories_object(int32 total_count,
|
||||
const vector<StoryFullId> &story_full_ids) const;
|
||||
|
||||
FileSourceId get_story_file_source_id(StoryFullId story_full_id);
|
||||
|
||||
void reload_story(StoryFullId story_full_id, Promise<Unit> &&promise);
|
||||
|
||||
private:
|
||||
struct Story {
|
||||
int32 date_ = 0;
|
||||
int32 expire_date_ = 0;
|
||||
@ -88,6 +55,41 @@ class StoryManager final : public Actor {
|
||||
unique_ptr<Story> &&story);
|
||||
};
|
||||
|
||||
public:
|
||||
StoryManager(Td *td, ActorShared<> parent);
|
||||
StoryManager(const StoryManager &) = delete;
|
||||
StoryManager &operator=(const StoryManager &) = delete;
|
||||
StoryManager(StoryManager &&) = delete;
|
||||
StoryManager &operator=(StoryManager &&) = delete;
|
||||
~StoryManager() final;
|
||||
|
||||
void send_story(td_api::object_ptr<td_api::InputStoryContent> &&input_story_content,
|
||||
td_api::object_ptr<td_api::formattedText> &&input_caption,
|
||||
td_api::object_ptr<td_api::userPrivacySettingRules> &&rules, bool is_pinned,
|
||||
Promise<td_api::object_ptr<td_api::story>> &&promise);
|
||||
|
||||
void on_send_story_file_part_missing(unique_ptr<PendingStory> &&pending_story, int bad_part);
|
||||
|
||||
void get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId from_story_id, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
void get_dialog_expiring_stories(DialogId owner_dialog_id, Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
StoryId on_get_story(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::storyItem> &&story_item);
|
||||
|
||||
std::pair<int32, vector<StoryId>> on_get_stories(DialogId owner_dialog_id,
|
||||
telegram_api::object_ptr<telegram_api::stories_stories> &&stories);
|
||||
|
||||
td_api::object_ptr<td_api::story> get_story_object(StoryFullId story_full_id) const;
|
||||
|
||||
td_api::object_ptr<td_api::stories> get_stories_object(int32 total_count,
|
||||
const vector<StoryFullId> &story_full_ids) const;
|
||||
|
||||
FileSourceId get_story_file_source_id(StoryFullId story_full_id);
|
||||
|
||||
void reload_story(StoryFullId story_full_id, Promise<Unit> &&promise);
|
||||
|
||||
private:
|
||||
class UploadMediaCallback;
|
||||
|
||||
class SendStoryQuery;
|
||||
@ -122,8 +124,7 @@ class StoryManager final : public Actor {
|
||||
static bool is_local_story_id(StoryId story_id);
|
||||
|
||||
void do_send_story(DialogId dialog_id, StoryId story_id, uint64 log_event_id, uint32 send_story_num, int64 random_id,
|
||||
unique_ptr<Story> &&story, vector<int> bad_parts,
|
||||
Promise<td_api::object_ptr<td_api::story>> &&promise);
|
||||
unique_ptr<Story> &&story, vector<int> bad_parts);
|
||||
|
||||
void on_upload_story(FileId file_id, telegram_api::object_ptr<telegram_api::InputFile> input_file);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user