Simplify uploadStickerFile.
This commit is contained in:
parent
b6de7319d4
commit
4d8fae253e
@ -5023,7 +5023,7 @@ proxies proxies:vector<proxy> = Proxies;
|
||||
|
||||
|
||||
//@description A sticker to be added to a sticker set
|
||||
//@sticker File with the sticker; must fit in a 512x512 square. For WEBP stickers the file must be in PNG format, which will be converted to WEBP server-side.
|
||||
//@sticker File with the sticker; must fit in a 512x512 square. For WEBP stickers the file must be in WEBP or PNG format, which will be converted to WEBP server-side.
|
||||
//-See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
|
||||
//@emojis Emojis corresponding to the sticker
|
||||
//@format Sticker format
|
||||
@ -7969,8 +7969,12 @@ checkPhoneNumberConfirmationCode code:string = Ok;
|
||||
setBotUpdatesStatus pending_update_count:int32 error_message:string = Ok;
|
||||
|
||||
|
||||
//@description Uploads a file with a sticker; returns the uploaded file @user_id Sticker file owner; ignored for regular users @sticker Sticker file to upload
|
||||
uploadStickerFile user_id:int53 sticker:inputSticker = File;
|
||||
//@description Uploads a file with a sticker; returns the uploaded file
|
||||
//@user_id Sticker file owner; ignored for regular users
|
||||
//@sticker_format Sticker format
|
||||
//@sticker File file to upload; must fit in a 512x512 square. For WEBP stickers the file must be in WEBP or PNG format, which will be converted to WEBP server-side.
|
||||
//-See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
|
||||
uploadStickerFile user_id:int53 sticker_format:StickerFormat sticker:InputFile = File;
|
||||
|
||||
//@description Returns a suggested name for a new sticker set with a given title @title Sticker set title; 1-64 characters
|
||||
getSuggestedStickerSetName title:string = Text;
|
||||
|
@ -7981,7 +7981,8 @@ Result<std::tuple<FileId, bool, bool, StickerFormat>> StickersManager::prepare_i
|
||||
return std::make_tuple(file_id, is_url, is_local, format);
|
||||
}
|
||||
|
||||
FileId StickersManager::upload_sticker_file(UserId user_id, tl_object_ptr<td_api::inputSticker> &&sticker,
|
||||
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,
|
||||
Promise<Unit> &&promise) {
|
||||
bool is_bot = td_->auth_manager_->is_bot();
|
||||
if (!is_bot) {
|
||||
@ -7994,8 +7995,13 @@ FileId StickersManager::upload_sticker_file(UserId user_id, tl_object_ptr<td_api
|
||||
return FileId();
|
||||
}
|
||||
|
||||
if (sticker_format == nullptr) {
|
||||
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_sticker(sticker.get(), StickerType::Regular);
|
||||
auto r_file_id = prepare_input_file(input_file, get_sticker_format(sticker_format), StickerType::Regular, false);
|
||||
if (r_file_id.is_error()) {
|
||||
promise.set_error(r_file_id.move_as_error());
|
||||
return FileId();
|
||||
|
@ -285,7 +285,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, tl_object_ptr<td_api::inputSticker> &&sticker, Promise<Unit> &&promise);
|
||||
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);
|
||||
|
||||
void get_suggested_sticker_set_name(string title, Promise<string> &&promise);
|
||||
|
||||
|
@ -2194,12 +2194,14 @@ class ChangeStickerSetRequest final : public RequestOnceActor {
|
||||
|
||||
class UploadStickerFileRequest final : public RequestOnceActor {
|
||||
UserId user_id_;
|
||||
tl_object_ptr<td_api::inputSticker> sticker_;
|
||||
td_api::object_ptr<td_api::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_), std::move(promise));
|
||||
file_id = td_->stickers_manager_->upload_sticker_file(user_id_, std::move(sticker_format_), std::move(input_file_),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
@ -2208,8 +2210,12 @@ class UploadStickerFileRequest final : public RequestOnceActor {
|
||||
|
||||
public:
|
||||
UploadStickerFileRequest(ActorShared<Td> td, uint64 request_id, int64 user_id,
|
||||
tl_object_ptr<td_api::inputSticker> &&sticker)
|
||||
: RequestOnceActor(std::move(td), request_id), user_id_(user_id), sticker_(std::move(sticker)) {
|
||||
td_api::object_ptr<td_api::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_))
|
||||
, input_file_(std::move(input_file)) {
|
||||
}
|
||||
};
|
||||
|
||||
@ -7246,7 +7252,8 @@ 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_));
|
||||
CREATE_REQUEST(UploadStickerFileRequest, request.user_id_, std::move(request.sticker_format_),
|
||||
std::move(request.sticker_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getSuggestedStickerSetName &request) {
|
||||
|
@ -2888,9 +2888,7 @@ class CliClient final : public Actor {
|
||||
const string &name = args;
|
||||
send_request(td_api::make_object<td_api::checkStickerSetName>(name));
|
||||
} else if (op == "usf" || op == "usfa" || op == "usfv") {
|
||||
send_request(td_api::make_object<td_api::uploadStickerFile>(
|
||||
-1, td_api::make_object<td_api::inputSticker>(as_input_file(args), "😀", as_sticker_format(op),
|
||||
as_mask_position(op), Auto())));
|
||||
send_request(td_api::make_object<td_api::uploadStickerFile>(-1, as_sticker_format(op), as_input_file(args)));
|
||||
} else if (op == "cnss" || op == "cnssa" || op == "cnssv" || op == "cnssm" || op == "cnsse") {
|
||||
string title;
|
||||
string name;
|
||||
|
Loading…
Reference in New Issue
Block a user