Return Ok from addStickerToSet.

This commit is contained in:
levlam 2023-02-16 19:50:52 +03:00
parent 359ec5e66c
commit c3d2ad8c59
4 changed files with 13 additions and 15 deletions

View File

@ -7997,7 +7997,7 @@ createNewStickerSet user_id:int53 title:string name:string sticker_format:Sticke
//@user_id Sticker set owner //@user_id Sticker set owner
//@name Sticker set name //@name Sticker set name
//@sticker Sticker to add to the set //@sticker Sticker to add to the set
addStickerToSet user_id:int53 name:string sticker:inputSticker = StickerSet; addStickerToSet user_id:int53 name:string sticker:inputSticker = Ok;
//@description Sets a sticker set thumbnail; for bots only. Returns the sticker set //@description Sets a sticker set thumbnail; for bots only. Returns the sticker set
//@user_id Sticker set owner //@user_id Sticker set owner

View File

@ -1186,11 +1186,10 @@ class CreateNewStickerSetQuery final : public Td::ResultHandler {
}; };
class AddStickerToSetQuery final : public Td::ResultHandler { class AddStickerToSetQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::stickerSet>> promise_; Promise<Unit> promise_;
public: public:
explicit AddStickerToSetQuery(Promise<td_api::object_ptr<td_api::stickerSet>> &&promise) explicit AddStickerToSetQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
: promise_(std::move(promise)) {
} }
void send(const string &short_name, tl_object_ptr<telegram_api::inputStickerSetItem> &&input_sticker) { void send(const string &short_name, tl_object_ptr<telegram_api::inputStickerSetItem> &&input_sticker) {
@ -1211,7 +1210,7 @@ class AddStickerToSetQuery final : public Td::ResultHandler {
if (!sticker_set_id.is_valid()) { if (!sticker_set_id.is_valid()) {
return on_error(Status::Error(500, "Sticker set not found")); return on_error(Status::Error(500, "Sticker set not found"));
} }
promise_.set_value(td_->stickers_manager_->get_sticker_set_object(sticker_set_id)); promise_.set_value(Unit());
} }
void on_error(Status status) final { void on_error(Status status) final {
@ -8450,8 +8449,7 @@ void StickersManager::on_new_stickers_uploaded(int64 random_id, Result<Unit> res
} }
void StickersManager::add_sticker_to_set(UserId user_id, string short_name, void StickersManager::add_sticker_to_set(UserId user_id, string short_name,
tl_object_ptr<td_api::inputSticker> &&sticker, td_api::object_ptr<td_api::inputSticker> &&sticker, Promise<Unit> &&promise) {
Promise<td_api::object_ptr<td_api::stickerSet>> &&promise) {
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id)); TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id));
short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH)); short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH));
@ -8479,8 +8477,8 @@ void StickersManager::add_sticker_to_set(UserId user_id, string short_name,
} }
void StickersManager::do_add_sticker_to_set(UserId user_id, string short_name, void StickersManager::do_add_sticker_to_set(UserId user_id, string short_name,
tl_object_ptr<td_api::inputSticker> &&sticker, td_api::object_ptr<td_api::inputSticker> &&sticker,
Promise<td_api::object_ptr<td_api::stickerSet>> &&promise) { Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status()); TRY_STATUS_PROMISE(promise, G()->close_status());
const StickerSet *sticker_set = get_sticker_set(short_name_to_sticker_set_id_.get(short_name)); const StickerSet *sticker_set = get_sticker_set(short_name_to_sticker_set_id_.get(short_name));

View File

@ -305,8 +305,8 @@ class StickersManager final : public Actor {
vector<td_api::object_ptr<td_api::inputSticker>> &&stickers, string software, vector<td_api::object_ptr<td_api::inputSticker>> &&stickers, string software,
Promise<td_api::object_ptr<td_api::stickerSet>> &&promise); Promise<td_api::object_ptr<td_api::stickerSet>> &&promise);
void add_sticker_to_set(UserId user_id, string short_name, tl_object_ptr<td_api::inputSticker> &&sticker, void add_sticker_to_set(UserId user_id, string short_name, td_api::object_ptr<td_api::inputSticker> &&sticker,
Promise<td_api::object_ptr<td_api::stickerSet>> &&promise); Promise<Unit> &&promise);
void set_sticker_set_thumbnail(UserId user_id, string short_name, tl_object_ptr<td_api::InputFile> &&thumbnail, void set_sticker_set_thumbnail(UserId user_id, string short_name, tl_object_ptr<td_api::InputFile> &&thumbnail,
Promise<td_api::object_ptr<td_api::stickerSet>> &&promise); Promise<td_api::object_ptr<td_api::stickerSet>> &&promise);
@ -540,7 +540,7 @@ class StickersManager final : public Actor {
string short_name_; string short_name_;
FileId file_id_; FileId file_id_;
tl_object_ptr<td_api::inputSticker> sticker_; tl_object_ptr<td_api::inputSticker> sticker_;
Promise<td_api::object_ptr<td_api::stickerSet>> promise_; Promise<Unit> promise_;
}; };
struct PendingSetStickerSetThumbnail { struct PendingSetStickerSetThumbnail {
@ -874,8 +874,8 @@ class StickersManager final : public Actor {
void on_added_sticker_uploaded(int64 random_id, Result<Unit> result); void on_added_sticker_uploaded(int64 random_id, Result<Unit> result);
void do_add_sticker_to_set(UserId user_id, string short_name, tl_object_ptr<td_api::inputSticker> &&sticker, void do_add_sticker_to_set(UserId user_id, string short_name, td_api::object_ptr<td_api::inputSticker> &&sticker,
Promise<td_api::object_ptr<td_api::stickerSet>> &&promise); Promise<Unit> &&promise);
void on_sticker_set_thumbnail_uploaded(int64 random_id, Result<Unit> result); void on_sticker_set_thumbnail_uploaded(int64 random_id, Result<Unit> result);

View File

@ -7295,7 +7295,7 @@ void Td::on_request(uint64 id, td_api::createNewStickerSet &request) {
void Td::on_request(uint64 id, td_api::addStickerToSet &request) { void Td::on_request(uint64 id, td_api::addStickerToSet &request) {
CHECK_IS_BOT(); CHECK_IS_BOT();
CLEAN_INPUT_STRING(request.name_); CLEAN_INPUT_STRING(request.name_);
CREATE_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
stickers_manager_->add_sticker_to_set(UserId(request.user_id_), std::move(request.name_), std::move(request.sticker_), stickers_manager_->add_sticker_to_set(UserId(request.user_id_), std::move(request.name_), std::move(request.sticker_),
std::move(promise)); std::move(promise));
} }