Simplify StickersManager::upload_sticker_file.
This commit is contained in:
parent
7be16c8a68
commit
e8d022e52c
@ -8048,8 +8048,8 @@ Result<std::tuple<FileId, bool, bool>> StickersManager::prepare_input_file(
|
||||
return std::make_tuple(file_id, is_url, is_local);
|
||||
}
|
||||
|
||||
FileId StickersManager::upload_sticker_file(UserId user_id, td_api::object_ptr<td_api::StickerFormat> &&sticker_format,
|
||||
td_api::object_ptr<td_api::InputFile> &&input_file,
|
||||
FileId StickersManager::upload_sticker_file(UserId user_id, StickerFormat sticker_format,
|
||||
const td_api::object_ptr<td_api::InputFile> &input_file,
|
||||
Promise<Unit> &&promise) {
|
||||
bool is_bot = td_->auth_manager_->is_bot();
|
||||
if (!is_bot) {
|
||||
@ -8062,13 +8062,13 @@ FileId StickersManager::upload_sticker_file(UserId user_id, td_api::object_ptr<t
|
||||
return FileId();
|
||||
}
|
||||
|
||||
if (sticker_format == nullptr) {
|
||||
if (sticker_format == StickerFormat::Unknown) {
|
||||
promise.set_error(Status::Error(400, "Sticker format must be non-empty"));
|
||||
return FileId();
|
||||
}
|
||||
|
||||
// StickerType::Regular has less restrictions
|
||||
auto r_file_id = prepare_input_file(input_file, get_sticker_format(sticker_format), StickerType::Regular, false);
|
||||
auto r_file_id = prepare_input_file(input_file, sticker_format, StickerType::Regular, false);
|
||||
if (r_file_id.is_error()) {
|
||||
promise.set_error(r_file_id.move_as_error());
|
||||
return FileId();
|
||||
|
@ -287,8 +287,8 @@ class StickersManager final : public Actor {
|
||||
|
||||
void move_sticker_set_to_top_by_custom_emoji_ids(const vector<CustomEmojiId> &custom_emoji_ids);
|
||||
|
||||
FileId upload_sticker_file(UserId user_id, td_api::object_ptr<td_api::StickerFormat> &&sticker_format,
|
||||
td_api::object_ptr<td_api::InputFile> &&input_file, Promise<Unit> &&promise);
|
||||
FileId upload_sticker_file(UserId user_id, StickerFormat sticker_format,
|
||||
const td_api::object_ptr<td_api::InputFile> &input_file, Promise<Unit> &&promise);
|
||||
|
||||
void get_suggested_sticker_set_name(string title, Promise<string> &&promise);
|
||||
|
||||
|
@ -2194,14 +2194,13 @@ class ChangeStickerSetRequest final : public RequestOnceActor {
|
||||
|
||||
class UploadStickerFileRequest final : public RequestOnceActor {
|
||||
UserId user_id_;
|
||||
td_api::object_ptr<td_api::StickerFormat> sticker_format_;
|
||||
StickerFormat sticker_format_;
|
||||
td_api::object_ptr<td_api::InputFile> input_file_;
|
||||
|
||||
FileId file_id;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
file_id = td_->stickers_manager_->upload_sticker_file(user_id_, std::move(sticker_format_), std::move(input_file_),
|
||||
std::move(promise));
|
||||
file_id = td_->stickers_manager_->upload_sticker_file(user_id_, sticker_format_, input_file_, std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
@ -2209,12 +2208,11 @@ class UploadStickerFileRequest final : public RequestOnceActor {
|
||||
}
|
||||
|
||||
public:
|
||||
UploadStickerFileRequest(ActorShared<Td> td, uint64 request_id, int64 user_id,
|
||||
td_api::object_ptr<td_api::StickerFormat> sticker_format_,
|
||||
UploadStickerFileRequest(ActorShared<Td> td, uint64 request_id, int64 user_id, StickerFormat sticker_format,
|
||||
td_api::object_ptr<td_api::InputFile> input_file)
|
||||
: RequestOnceActor(std::move(td), request_id)
|
||||
, user_id_(user_id)
|
||||
, sticker_format_(std::move(sticker_format_))
|
||||
, sticker_format_(sticker_format)
|
||||
, input_file_(std::move(input_file)) {
|
||||
}
|
||||
};
|
||||
@ -7252,7 +7250,7 @@ void Td::on_request(uint64 id, td_api::reorderInstalledStickerSets &request) {
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::uploadStickerFile &request) {
|
||||
CREATE_REQUEST(UploadStickerFileRequest, request.user_id_, std::move(request.sticker_format_),
|
||||
CREATE_REQUEST(UploadStickerFileRequest, request.user_id_, get_sticker_format(request.sticker_format_),
|
||||
std::move(request.sticker_));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user