Add inputChatPhotoSticker.
This commit is contained in:
parent
f8372a52e3
commit
0469ac0147
@ -551,7 +551,7 @@ chatPhotoStickerTypeRegularOrMask sticker_set_id:int64 sticker_id:int64 = ChatPh
|
||||
chatPhotoStickerTypeCustomEmoji custom_emoji_id:int64 = ChatPhotoStickerType;
|
||||
|
||||
|
||||
//@description Information about the sticker, which was used to create the chat photo
|
||||
//@description Information about the sticker, which was used to create the chat photo. The sticker is shown at the center of the photo and occupies at most 67% of it
|
||||
//@type Type of the sticker
|
||||
//@background_fill Describes a fill of the background under the sticker; rotation angle in backgroundFillGradient isn't supported
|
||||
chatPhotoSticker type:ChatPhotoStickerType background_fill:BackgroundFill = ChatPhotoSticker;
|
||||
@ -590,6 +590,9 @@ inputChatPhotoStatic photo:InputFile = InputChatPhoto;
|
||||
//@main_frame_timestamp Timestamp of the frame, which will be used as static chat photo
|
||||
inputChatPhotoAnimation animation:InputFile main_frame_timestamp:double = InputChatPhoto;
|
||||
|
||||
//@description A sticker on a custom background @sticker Information about the sticker
|
||||
inputChatPhotoSticker sticker:chatPhotoSticker = InputChatPhoto;
|
||||
|
||||
|
||||
//@description Describes actions that a user is allowed to take in a chat
|
||||
//@can_send_messages True, if the user can send text messages, contacts, invoices, locations, and venues
|
||||
@ -6624,8 +6627,7 @@ setChatTitle chat_id:int53 title:string = Ok;
|
||||
//@description Changes the photo of a chat. Supported only for basic groups, supergroups and channels. Requires can_change_info administrator right
|
||||
//@chat_id Chat identifier
|
||||
//@photo New chat photo; pass null to delete the chat photo
|
||||
//@sticker Sticker-based version of the chat photo; pass null if none or an existing photo is set
|
||||
setChatPhoto chat_id:int53 photo:InputChatPhoto sticker:chatPhotoSticker = Ok;
|
||||
setChatPhoto chat_id:int53 photo:InputChatPhoto = Ok;
|
||||
|
||||
//@description Changes the message auto-delete or self-destruct (for secret chats) time in a chat. Requires change_info administrator right in basic groups, supergroups and channels
|
||||
//-Message auto-delete time can't be changed in a chat with the current user (Saved Messages) and the chat 777000 (Telegram).
|
||||
@ -7371,9 +7373,8 @@ getWebPageInstantView url:string force_full:Bool = WebPageInstantView;
|
||||
|
||||
//@description Changes a profile photo for the current user
|
||||
//@photo Profile photo to set
|
||||
//@sticker Sticker-based version of the profile photo; pass null if none or an existing photo is set
|
||||
//@is_public Pass true to set a public photo, which will be visible even the main photo is hidden by privacy settings
|
||||
setProfilePhoto photo:InputChatPhoto sticker:chatPhotoSticker is_public:Bool = Ok;
|
||||
setProfilePhoto photo:InputChatPhoto is_public:Bool = Ok;
|
||||
|
||||
//@description Deletes a profile photo @profile_photo_id Identifier of the profile photo to delete
|
||||
deleteProfilePhoto profile_photo_id:int64 = Ok;
|
||||
|
@ -447,9 +447,8 @@ class UploadProfilePhotoQuery final : public Td::ResultHandler {
|
||||
explicit UploadProfilePhotoQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(UserId user_id, FileId file_id, tl_object_ptr<telegram_api::InputFile> &&input_file,
|
||||
unique_ptr<StickerPhotoSize> sticker_photo_size, bool is_fallback, bool only_suggest, bool is_animation,
|
||||
double main_frame_timestamp) {
|
||||
void send(UserId user_id, FileId file_id, tl_object_ptr<telegram_api::InputFile> &&input_file, bool is_fallback,
|
||||
bool only_suggest, bool is_animation, double main_frame_timestamp) {
|
||||
CHECK(input_file != nullptr);
|
||||
CHECK(file_id.is_valid());
|
||||
|
||||
@ -486,15 +485,9 @@ class UploadProfilePhotoQuery final : public Td::ResultHandler {
|
||||
if (is_fallback) {
|
||||
flags |= telegram_api::photos_uploadProfilePhoto::FALLBACK_MASK;
|
||||
}
|
||||
auto video_emoji_markup =
|
||||
sticker_photo_size != nullptr ? sticker_photo_size->get_input_video_size_object(td_) : nullptr;
|
||||
if (video_emoji_markup != nullptr) {
|
||||
flags |= telegram_api::photos_uploadProfilePhoto::VIDEO_EMOJI_MARKUP_MASK;
|
||||
}
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::photos_uploadProfilePhoto(flags, false /*ignored*/, std::move(photo_input_file),
|
||||
std::move(video_input_file), main_frame_timestamp,
|
||||
std::move(video_emoji_markup)),
|
||||
std::move(video_input_file), main_frame_timestamp, nullptr),
|
||||
{{"me"}}));
|
||||
} else {
|
||||
if (only_suggest) {
|
||||
@ -514,6 +507,41 @@ class UploadProfilePhotoQuery final : public Td::ResultHandler {
|
||||
}
|
||||
}
|
||||
|
||||
void send(UserId user_id, unique_ptr<StickerPhotoSize> sticker_photo_size, bool is_fallback, bool only_suggest) {
|
||||
CHECK(sticker_photo_size != nullptr);
|
||||
user_id_ = user_id;
|
||||
file_id_ = FileId();
|
||||
is_fallback_ = is_fallback;
|
||||
only_suggest_ = only_suggest;
|
||||
|
||||
if (user_id == td_->contacts_manager_->get_my_id()) {
|
||||
int32 flags = telegram_api::photos_uploadProfilePhoto::VIDEO_EMOJI_MARKUP_MASK;
|
||||
if (is_fallback) {
|
||||
flags |= telegram_api::photos_uploadProfilePhoto::FALLBACK_MASK;
|
||||
}
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::photos_uploadProfilePhoto(flags, false /*ignored*/, nullptr, nullptr, 0.0,
|
||||
sticker_photo_size->get_input_video_size_object(td_)),
|
||||
{{"me"}}));
|
||||
} else {
|
||||
int32 flags = telegram_api::photos_uploadContactProfilePhoto::VIDEO_EMOJI_MARKUP_MASK;
|
||||
if (only_suggest) {
|
||||
flags |= telegram_api::photos_uploadContactProfilePhoto::SUGGEST_MASK;
|
||||
} else {
|
||||
flags |= telegram_api::photos_uploadContactProfilePhoto::SAVE_MASK;
|
||||
}
|
||||
auto r_input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||
if (r_input_user.is_error()) {
|
||||
return on_error(r_input_user.move_as_error());
|
||||
}
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::photos_uploadContactProfilePhoto(flags, false /*ignored*/, false /*ignored*/,
|
||||
r_input_user.move_as_ok(), nullptr, nullptr, 0.0,
|
||||
sticker_photo_size->get_input_video_size_object(td_)),
|
||||
{{user_id}}));
|
||||
}
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
static_assert(std::is_same<telegram_api::photos_uploadProfilePhoto::ReturnType,
|
||||
telegram_api::photos_uploadContactProfilePhoto::ReturnType>::value,
|
||||
@ -527,14 +555,18 @@ class UploadProfilePhotoQuery final : public Td::ResultHandler {
|
||||
td_->contacts_manager_->on_set_profile_photo(user_id_, result_ptr.move_as_ok(), is_fallback_, 0);
|
||||
}
|
||||
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
if (file_id_.is_valid()) {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
}
|
||||
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
if (file_id_.is_valid()) {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -7057,15 +7089,13 @@ FileId ContactsManager::get_profile_photo_file_id(int64 photo_id) const {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void ContactsManager::set_profile_photo(const td_api::object_ptr<td_api::InputChatPhoto> &input_photo,
|
||||
const td_api::object_ptr<td_api::chatPhotoSticker> &sticker, bool is_fallback,
|
||||
void ContactsManager::set_profile_photo(const td_api::object_ptr<td_api::InputChatPhoto> &input_photo, bool is_fallback,
|
||||
Promise<Unit> &&promise) {
|
||||
set_profile_photo_impl(get_my_id(), input_photo, sticker, is_fallback, false, std::move(promise));
|
||||
set_profile_photo_impl(get_my_id(), input_photo, is_fallback, false, std::move(promise));
|
||||
}
|
||||
|
||||
void ContactsManager::set_profile_photo_impl(UserId user_id,
|
||||
const td_api::object_ptr<td_api::InputChatPhoto> &input_photo,
|
||||
const td_api::object_ptr<td_api::chatPhotoSticker> &sticker,
|
||||
bool is_fallback, bool only_suggest, Promise<Unit> &&promise) {
|
||||
if (input_photo == nullptr) {
|
||||
return promise.set_error(Status::Error(400, "New profile photo must be non-empty"));
|
||||
@ -7079,9 +7109,6 @@ void ContactsManager::set_profile_photo_impl(UserId user_id,
|
||||
if (user_id != get_my_id()) {
|
||||
return promise.set_error(Status::Error(400, "Can't use inputChatPhotoPrevious"));
|
||||
}
|
||||
if (sticker != nullptr) {
|
||||
return promise.set_error(Status::Error(400, "Can't use sticker with a previous photo"));
|
||||
}
|
||||
auto photo = static_cast<const td_api::inputChatPhotoPrevious *>(input_photo.get());
|
||||
auto photo_id = photo->chat_photo_id_;
|
||||
auto *u = get_user(user_id);
|
||||
@ -7109,6 +7136,14 @@ void ContactsManager::set_profile_photo_impl(UserId user_id,
|
||||
is_animation = true;
|
||||
break;
|
||||
}
|
||||
case td_api::inputChatPhotoSticker::ID: {
|
||||
auto photo = static_cast<const td_api::inputChatPhotoSticker *>(input_photo.get());
|
||||
TRY_RESULT_PROMISE(promise, sticker_photo_size, StickerPhotoSize::get_sticker_photo_size(td_, photo->sticker_));
|
||||
|
||||
td_->create_handler<UploadProfilePhotoQuery>(std::move(promise))
|
||||
->send(user_id, std::move(sticker_photo_size), is_fallback, only_suggest);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
@ -7119,8 +7154,6 @@ void ContactsManager::set_profile_photo_impl(UserId user_id,
|
||||
return promise.set_error(Status::Error(400, "Wrong main frame timestamp specified"));
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, sticker_photo_size, StickerPhotoSize::get_sticker_photo_size(td_, sticker));
|
||||
|
||||
auto file_type = is_animation ? FileType::Animation : FileType::Photo;
|
||||
auto r_file_id = td_->file_manager_->get_input_file_id(file_type, *input_file, DialogId(user_id), false, false);
|
||||
if (r_file_id.is_error()) {
|
||||
@ -7130,9 +7163,8 @@ void ContactsManager::set_profile_photo_impl(UserId user_id,
|
||||
FileId file_id = r_file_id.ok();
|
||||
CHECK(file_id.is_valid());
|
||||
|
||||
upload_profile_photo(user_id, td_->file_manager_->dup_file_id(file_id, "set_profile_photo_impl"),
|
||||
std::move(sticker_photo_size), is_fallback, only_suggest, is_animation, main_frame_timestamp,
|
||||
std::move(promise));
|
||||
upload_profile_photo(user_id, td_->file_manager_->dup_file_id(file_id, "set_profile_photo_impl"), is_fallback,
|
||||
only_suggest, is_animation, main_frame_timestamp, std::move(promise));
|
||||
}
|
||||
|
||||
void ContactsManager::set_user_profile_photo(UserId user_id,
|
||||
@ -7156,7 +7188,7 @@ void ContactsManager::set_user_profile_photo(UserId user_id,
|
||||
return;
|
||||
}
|
||||
|
||||
set_profile_photo_impl(user_id, input_photo, nullptr, false, only_suggest, std::move(promise));
|
||||
set_profile_photo_impl(user_id, input_photo, false, only_suggest, std::move(promise));
|
||||
}
|
||||
|
||||
void ContactsManager::send_update_profile_photo_query(FileId file_id, int64 old_photo_id, bool is_fallback,
|
||||
@ -7166,16 +7198,15 @@ void ContactsManager::send_update_profile_photo_query(FileId file_id, int64 old_
|
||||
->send(file_id, old_photo_id, is_fallback, file_view.main_remote_location().as_input_photo());
|
||||
}
|
||||
|
||||
void ContactsManager::upload_profile_photo(UserId user_id, FileId file_id,
|
||||
unique_ptr<StickerPhotoSize> sticker_photo_size, bool is_fallback,
|
||||
bool only_suggest, bool is_animation, double main_frame_timestamp,
|
||||
Promise<Unit> &&promise, int reupload_count, vector<int> bad_parts) {
|
||||
void ContactsManager::upload_profile_photo(UserId user_id, FileId file_id, bool is_fallback, bool only_suggest,
|
||||
bool is_animation, double main_frame_timestamp, Promise<Unit> &&promise,
|
||||
int reupload_count, vector<int> bad_parts) {
|
||||
CHECK(file_id.is_valid());
|
||||
bool is_inserted = uploaded_profile_photos_
|
||||
.emplace(file_id, UploadedProfilePhoto{user_id, std::move(sticker_photo_size), is_fallback,
|
||||
only_suggest, main_frame_timestamp, is_animation,
|
||||
reupload_count, std::move(promise)})
|
||||
.second;
|
||||
bool is_inserted =
|
||||
uploaded_profile_photos_
|
||||
.emplace(file_id, UploadedProfilePhoto{user_id, is_fallback, only_suggest, main_frame_timestamp, is_animation,
|
||||
reupload_count, std::move(promise)})
|
||||
.second;
|
||||
CHECK(is_inserted);
|
||||
LOG(INFO) << "Ask to upload " << (is_animation ? "animated" : "static") << " profile photo " << file_id
|
||||
<< " for user " << user_id << " with bad parts " << bad_parts;
|
||||
@ -17914,7 +17945,6 @@ void ContactsManager::on_upload_profile_photo(FileId file_id, tl_object_ptr<tele
|
||||
CHECK(it != uploaded_profile_photos_.end());
|
||||
|
||||
UserId user_id = it->second.user_id;
|
||||
auto sticker_photo_size = std::move(it->second.sticker_photo_size);
|
||||
bool is_fallback = it->second.is_fallback;
|
||||
bool only_suggest = it->second.only_suggest;
|
||||
double main_frame_timestamp = it->second.main_frame_timestamp;
|
||||
@ -17947,15 +17977,14 @@ void ContactsManager::on_upload_profile_photo(FileId file_id, tl_object_ptr<tele
|
||||
is_animation ? FileManager::extract_file_reference(file_view.main_remote_location().as_input_document())
|
||||
: FileManager::extract_file_reference(file_view.main_remote_location().as_input_photo());
|
||||
td_->file_manager_->delete_file_reference(file_id, file_reference);
|
||||
upload_profile_photo(user_id, file_id, std::move(sticker_photo_size), is_fallback, only_suggest, is_animation,
|
||||
main_frame_timestamp, std::move(promise), reupload_count + 1, {-1});
|
||||
upload_profile_photo(user_id, file_id, is_fallback, only_suggest, is_animation, main_frame_timestamp,
|
||||
std::move(promise), reupload_count + 1, {-1});
|
||||
return;
|
||||
}
|
||||
CHECK(input_file != nullptr);
|
||||
|
||||
td_->create_handler<UploadProfilePhotoQuery>(std::move(promise))
|
||||
->send(user_id, file_id, std::move(input_file), std::move(sticker_photo_size), is_fallback, only_suggest,
|
||||
is_animation, main_frame_timestamp);
|
||||
->send(user_id, file_id, std::move(input_file), is_fallback, only_suggest, is_animation, main_frame_timestamp);
|
||||
}
|
||||
|
||||
void ContactsManager::on_upload_profile_photo_error(FileId file_id, Status status) {
|
||||
|
@ -366,8 +366,7 @@ class ContactsManager final : public Actor {
|
||||
|
||||
FileId get_profile_photo_file_id(int64 photo_id) const;
|
||||
|
||||
void set_profile_photo(const td_api::object_ptr<td_api::InputChatPhoto> &input_photo,
|
||||
const td_api::object_ptr<td_api::chatPhotoSticker> &sticker, bool is_fallback,
|
||||
void set_profile_photo(const td_api::object_ptr<td_api::InputChatPhoto> &input_photo, bool is_fallback,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void set_user_profile_photo(UserId user_id, const td_api::object_ptr<td_api::InputChatPhoto> &input_photo,
|
||||
@ -1353,12 +1352,11 @@ class ContactsManager final : public Actor {
|
||||
void apply_pending_user_photo(User *u, UserId user_id);
|
||||
|
||||
void set_profile_photo_impl(UserId user_id, const td_api::object_ptr<td_api::InputChatPhoto> &input_photo,
|
||||
const td_api::object_ptr<td_api::chatPhotoSticker> &sticker, bool is_fallback,
|
||||
bool only_suggest, Promise<Unit> &&promise);
|
||||
bool is_fallback, bool only_suggest, Promise<Unit> &&promise);
|
||||
|
||||
void upload_profile_photo(UserId user_id, FileId file_id, unique_ptr<StickerPhotoSize> sticker_photo_size,
|
||||
bool is_fallback, bool only_suggest, bool is_animation, double main_frame_timestamp,
|
||||
Promise<Unit> &&promise, int reupload_count = 0, vector<int> bad_parts = {});
|
||||
void upload_profile_photo(UserId user_id, FileId file_id, bool is_fallback, bool only_suggest, bool is_animation,
|
||||
double main_frame_timestamp, Promise<Unit> &&promise, int reupload_count = 0,
|
||||
vector<int> bad_parts = {});
|
||||
|
||||
void on_upload_profile_photo(FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file);
|
||||
void on_upload_profile_photo_error(FileId file_id, Status status);
|
||||
@ -1897,7 +1895,6 @@ class ContactsManager final : public Actor {
|
||||
|
||||
struct UploadedProfilePhoto {
|
||||
UserId user_id;
|
||||
unique_ptr<StickerPhotoSize> sticker_photo_size;
|
||||
bool is_fallback;
|
||||
bool only_suggest;
|
||||
double main_frame_timestamp;
|
||||
@ -1905,11 +1902,9 @@ class ContactsManager final : public Actor {
|
||||
int reupload_count;
|
||||
Promise<Unit> promise;
|
||||
|
||||
UploadedProfilePhoto(UserId user_id, unique_ptr<StickerPhotoSize> sticker_photo_size, bool is_fallback,
|
||||
bool only_suggest, double main_frame_timestamp, bool is_animation, int32 reupload_count,
|
||||
Promise<Unit> promise)
|
||||
UploadedProfilePhoto(UserId user_id, bool is_fallback, bool only_suggest, double main_frame_timestamp,
|
||||
bool is_animation, int32 reupload_count, Promise<Unit> promise)
|
||||
: user_id(user_id)
|
||||
, sticker_photo_size(std::move(sticker_photo_size))
|
||||
, is_fallback(is_fallback)
|
||||
, only_suggest(only_suggest)
|
||||
, main_frame_timestamp(main_frame_timestamp)
|
||||
|
@ -1316,8 +1316,7 @@ class EditDialogPhotoQuery final : public Td::ResultHandler {
|
||||
if (file_id_.is_valid() && !was_uploaded_) {
|
||||
VLOG(file_references) << "Receive " << status << " for " << file_id_;
|
||||
td_->file_manager_->delete_file_reference(file_id_, file_reference_);
|
||||
td_->messages_manager_->upload_dialog_photo(dialog_id_, file_id_, nullptr, false, 0.0, false,
|
||||
std::move(promise_), {-1});
|
||||
td_->messages_manager_->upload_dialog_photo(dialog_id_, file_id_, false, 0.0, false, std::move(promise_), {-1});
|
||||
return;
|
||||
} else {
|
||||
LOG(ERROR) << "Receive file reference error, but file_id = " << file_id_
|
||||
@ -9492,7 +9491,6 @@ void MessagesManager::on_upload_dialog_photo(FileId file_id, tl_object_ptr<teleg
|
||||
}
|
||||
|
||||
DialogId dialog_id = it->second.dialog_id;
|
||||
auto sticker_photo_size = std::move(it->second.sticker_photo_size);
|
||||
double main_frame_timestamp = it->second.main_frame_timestamp;
|
||||
bool is_animation = it->second.is_animation;
|
||||
bool is_reupload = it->second.is_reupload;
|
||||
@ -9515,8 +9513,7 @@ void MessagesManager::on_upload_dialog_photo(FileId file_id, tl_object_ptr<teleg
|
||||
// delete file reference and forcely reupload the file
|
||||
auto file_reference = FileManager::extract_file_reference(file_view.main_remote_location().as_input_document());
|
||||
td_->file_manager_->delete_file_reference(file_id, file_reference);
|
||||
upload_dialog_photo(dialog_id, file_id, std::move(sticker_photo_size), is_animation, main_frame_timestamp, true,
|
||||
std::move(promise), {-1});
|
||||
upload_dialog_photo(dialog_id, file_id, is_animation, main_frame_timestamp, true, std::move(promise), {-1});
|
||||
} else {
|
||||
CHECK(file_view.get_type() == FileType::Photo);
|
||||
auto input_photo = file_view.main_remote_location().as_input_photo();
|
||||
@ -9541,15 +9538,9 @@ void MessagesManager::on_upload_dialog_photo(FileId file_id, tl_object_ptr<teleg
|
||||
flags |= telegram_api::inputChatUploadedPhoto::FILE_MASK;
|
||||
photo_input_file = std::move(input_file);
|
||||
}
|
||||
auto video_emoji_markup =
|
||||
sticker_photo_size != nullptr ? sticker_photo_size->get_input_video_size_object(td_) : nullptr;
|
||||
if (video_emoji_markup != nullptr) {
|
||||
flags |= telegram_api::inputChatUploadedPhoto::VIDEO_EMOJI_MARKUP_MASK;
|
||||
}
|
||||
|
||||
auto input_chat_photo = make_tl_object<telegram_api::inputChatUploadedPhoto>(
|
||||
flags, std::move(photo_input_file), std::move(video_input_file), main_frame_timestamp,
|
||||
std::move(video_emoji_markup));
|
||||
flags, std::move(photo_input_file), std::move(video_input_file), main_frame_timestamp, nullptr);
|
||||
send_edit_dialog_photo_query(dialog_id, file_id, std::move(input_chat_photo), std::move(promise));
|
||||
}
|
||||
|
||||
@ -34587,7 +34578,6 @@ void MessagesManager::on_updated_dialog_folder_id(DialogId dialog_id, uint64 gen
|
||||
}
|
||||
|
||||
void MessagesManager::set_dialog_photo(DialogId dialog_id, const tl_object_ptr<td_api::InputChatPhoto> &input_photo,
|
||||
const td_api::object_ptr<td_api::chatPhotoSticker> &sticker,
|
||||
Promise<Unit> &&promise) {
|
||||
if (!have_dialog_force(dialog_id, "set_dialog_photo")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
@ -34634,8 +34624,7 @@ void MessagesManager::set_dialog_photo(DialogId dialog_id, const tl_object_ptr<t
|
||||
auto file_view = td_->file_manager_->get_file_view(file_id);
|
||||
auto input_chat_photo =
|
||||
make_tl_object<telegram_api::inputChatPhoto>(file_view.main_remote_location().as_input_photo());
|
||||
send_edit_dialog_photo_query(dialog_id, file_id, std::move(input_chat_photo), std::move(promise));
|
||||
return;
|
||||
return send_edit_dialog_photo_query(dialog_id, file_id, std::move(input_chat_photo), std::move(promise));
|
||||
}
|
||||
case td_api::inputChatPhotoStatic::ID: {
|
||||
auto photo = static_cast<const td_api::inputChatPhotoStatic *>(input_photo.get());
|
||||
@ -34649,6 +34638,15 @@ void MessagesManager::set_dialog_photo(DialogId dialog_id, const tl_object_ptr<t
|
||||
is_animation = true;
|
||||
break;
|
||||
}
|
||||
case td_api::inputChatPhotoSticker::ID: {
|
||||
auto photo = static_cast<const td_api::inputChatPhotoSticker *>(input_photo.get());
|
||||
TRY_RESULT_PROMISE(promise, sticker_photo_size, StickerPhotoSize::get_sticker_photo_size(td_, photo->sticker_));
|
||||
|
||||
int32 flags = telegram_api::inputChatUploadedPhoto::VIDEO_EMOJI_MARKUP_MASK;
|
||||
auto input_chat_photo = make_tl_object<telegram_api::inputChatUploadedPhoto>(
|
||||
flags, nullptr, nullptr, 0.0, sticker_photo_size->get_input_video_size_object(td_));
|
||||
return send_edit_dialog_photo_query(dialog_id, FileId(), std::move(input_chat_photo), std::move(promise));
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
@ -34665,8 +34663,6 @@ void MessagesManager::set_dialog_photo(DialogId dialog_id, const tl_object_ptr<t
|
||||
return promise.set_error(Status::Error(400, "Wrong main frame timestamp specified"));
|
||||
}
|
||||
|
||||
TRY_RESULT_PROMISE(promise, sticker_photo_size, StickerPhotoSize::get_sticker_photo_size(td_, sticker));
|
||||
|
||||
auto file_type = is_animation ? FileType::Animation : FileType::Photo;
|
||||
auto r_file_id = td_->file_manager_->get_input_file_id(file_type, *input_file, dialog_id, true, false);
|
||||
if (r_file_id.is_error()) {
|
||||
@ -34680,8 +34676,8 @@ void MessagesManager::set_dialog_photo(DialogId dialog_id, const tl_object_ptr<t
|
||||
return;
|
||||
}
|
||||
|
||||
upload_dialog_photo(dialog_id, td_->file_manager_->dup_file_id(file_id, "set_dialog_photo"),
|
||||
std::move(sticker_photo_size), is_animation, main_frame_timestamp, false, std::move(promise));
|
||||
upload_dialog_photo(dialog_id, td_->file_manager_->dup_file_id(file_id, "set_dialog_photo"), is_animation,
|
||||
main_frame_timestamp, false, std::move(promise));
|
||||
}
|
||||
|
||||
void MessagesManager::send_edit_dialog_photo_query(DialogId dialog_id, FileId file_id,
|
||||
@ -34691,17 +34687,15 @@ void MessagesManager::send_edit_dialog_photo_query(DialogId dialog_id, FileId fi
|
||||
td_->create_handler<EditDialogPhotoQuery>(std::move(promise))->send(dialog_id, file_id, std::move(input_chat_photo));
|
||||
}
|
||||
|
||||
void MessagesManager::upload_dialog_photo(DialogId dialog_id, FileId file_id,
|
||||
unique_ptr<StickerPhotoSize> sticker_photo_size, bool is_animation,
|
||||
void MessagesManager::upload_dialog_photo(DialogId dialog_id, FileId file_id, bool is_animation,
|
||||
double main_frame_timestamp, bool is_reupload, Promise<Unit> &&promise,
|
||||
vector<int> bad_parts) {
|
||||
CHECK(file_id.is_valid());
|
||||
LOG(INFO) << "Ask to upload chat photo " << file_id;
|
||||
bool is_inserted =
|
||||
being_uploaded_dialog_photos_
|
||||
.emplace(file_id, UploadedDialogPhotoInfo{dialog_id, std::move(sticker_photo_size), main_frame_timestamp,
|
||||
is_animation, is_reupload, std::move(promise)})
|
||||
.second;
|
||||
bool is_inserted = being_uploaded_dialog_photos_
|
||||
.emplace(file_id, UploadedDialogPhotoInfo{dialog_id, main_frame_timestamp, is_animation,
|
||||
is_reupload, std::move(promise)})
|
||||
.second;
|
||||
CHECK(is_inserted);
|
||||
// TODO use force_reupload if is_reupload
|
||||
td_->file_manager_->resume_upload(file_id, std::move(bad_parts), upload_dialog_photo_callback_, 32, 0);
|
||||
|
@ -535,7 +535,7 @@ class MessagesManager final : public Actor {
|
||||
void add_dialog_to_list(DialogId dialog_id, DialogListId dialog_list_id, Promise<Unit> &&promise);
|
||||
|
||||
void set_dialog_photo(DialogId dialog_id, const tl_object_ptr<td_api::InputChatPhoto> &input_photo,
|
||||
const td_api::object_ptr<td_api::chatPhotoSticker> &sticker, Promise<Unit> &&promise);
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void set_dialog_title(DialogId dialog_id, const string &title, Promise<Unit> &&promise);
|
||||
|
||||
@ -993,9 +993,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void on_update_scope_mention_notifications(NotificationSettingsScope scope, bool disable_mention_notifications);
|
||||
|
||||
void upload_dialog_photo(DialogId dialog_id, FileId file_id, unique_ptr<StickerPhotoSize> sticker_photo_size,
|
||||
bool is_animation, double main_frame_timestamp, bool is_reupload, Promise<Unit> &&promise,
|
||||
vector<int> bad_parts = {});
|
||||
void upload_dialog_photo(DialogId dialog_id, FileId file_id, bool is_animation, double main_frame_timestamp,
|
||||
bool is_reupload, Promise<Unit> &&promise, vector<int> bad_parts = {});
|
||||
|
||||
void on_binlog_events(vector<BinlogEvent> &&events);
|
||||
|
||||
@ -3482,16 +3481,14 @@ class MessagesManager final : public Actor {
|
||||
|
||||
struct UploadedDialogPhotoInfo {
|
||||
DialogId dialog_id;
|
||||
unique_ptr<StickerPhotoSize> sticker_photo_size;
|
||||
double main_frame_timestamp;
|
||||
bool is_animation;
|
||||
bool is_reupload;
|
||||
Promise<Unit> promise;
|
||||
|
||||
UploadedDialogPhotoInfo(DialogId dialog_id, unique_ptr<StickerPhotoSize> sticker_photo_size,
|
||||
double main_frame_timestamp, bool is_animation, bool is_reupload, Promise<Unit> promise)
|
||||
UploadedDialogPhotoInfo(DialogId dialog_id, double main_frame_timestamp, bool is_animation, bool is_reupload,
|
||||
Promise<Unit> promise)
|
||||
: dialog_id(dialog_id)
|
||||
, sticker_photo_size(std::move(sticker_photo_size))
|
||||
, main_frame_timestamp(main_frame_timestamp)
|
||||
, is_animation(is_animation)
|
||||
, is_reupload(is_reupload)
|
||||
|
@ -14,7 +14,7 @@ namespace td {
|
||||
Result<unique_ptr<StickerPhotoSize>> StickerPhotoSize::get_sticker_photo_size(
|
||||
Td *td, const td_api::object_ptr<td_api::chatPhotoSticker> &sticker) {
|
||||
if (sticker == nullptr) {
|
||||
return nullptr;
|
||||
return Status::Error(400, "Sticker must not be null");
|
||||
}
|
||||
if (sticker->type_ == nullptr) {
|
||||
return Status::Error(400, "Type must be non-null");
|
||||
|
@ -6157,7 +6157,7 @@ void Td::on_request(uint64 id, td_api::setChatTitle &request) {
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setChatPhoto &request) {
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
messages_manager_->set_dialog_photo(DialogId(request.chat_id_), request.photo_, request.sticker_, std::move(promise));
|
||||
messages_manager_->set_dialog_photo(DialogId(request.chat_id_), request.photo_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setChatMessageAutoDeleteTime &request) {
|
||||
@ -7002,7 +7002,7 @@ void Td::on_request(uint64 id, const td_api::setLocation &request) {
|
||||
void Td::on_request(uint64 id, td_api::setProfilePhoto &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_profile_photo(request.photo_, request.sticker_, request.is_public_, std::move(promise));
|
||||
contacts_manager_->set_profile_photo(request.photo_, request.is_public_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::deleteProfilePhoto &request) {
|
||||
|
@ -893,8 +893,12 @@ class CliClient final : public Actor {
|
||||
string sticker_set_id;
|
||||
string sticker_id;
|
||||
std::tie(sticker_set_id, sticker_id) = split(args, get_delimiter(args));
|
||||
arg.sticker_set_id = to_integer<int64>(sticker_set_id);
|
||||
arg.sticker_id = to_integer<int64>(sticker_id);
|
||||
if (sticker_id.empty()) {
|
||||
arg.sticker_id = to_integer<int64>(sticker_set_id);
|
||||
} else {
|
||||
arg.sticker_set_id = to_integer<int64>(sticker_set_id);
|
||||
arg.sticker_id = to_integer<int64>(sticker_id);
|
||||
}
|
||||
}
|
||||
|
||||
template <class FirstType, class SecondType, class... Types>
|
||||
@ -4485,47 +4489,33 @@ class CliClient final : public Actor {
|
||||
} else if (op == "scpe") {
|
||||
ChatId chat_id;
|
||||
get_args(args, chat_id);
|
||||
send_request(td_api::make_object<td_api::setChatPhoto>(chat_id, nullptr, nullptr));
|
||||
send_request(td_api::make_object<td_api::setChatPhoto>(chat_id, nullptr));
|
||||
} else if (op == "scpp") {
|
||||
ChatId chat_id;
|
||||
int64 photo_id;
|
||||
get_args(args, chat_id, photo_id);
|
||||
send_request(td_api::make_object<td_api::setChatPhoto>(
|
||||
chat_id, td_api::make_object<td_api::inputChatPhotoPrevious>(photo_id), nullptr));
|
||||
chat_id, td_api::make_object<td_api::inputChatPhotoPrevious>(photo_id)));
|
||||
} else if (op == "scp") {
|
||||
ChatId chat_id;
|
||||
string photo_path;
|
||||
get_args(args, chat_id, photo_path);
|
||||
send_request(td_api::make_object<td_api::setChatPhoto>(
|
||||
chat_id, td_api::make_object<td_api::inputChatPhotoStatic>(as_input_file(photo_path)), nullptr));
|
||||
chat_id, td_api::make_object<td_api::inputChatPhotoStatic>(as_input_file(photo_path))));
|
||||
} else if (op == "scpa") {
|
||||
ChatId chat_id;
|
||||
string animation;
|
||||
string main_frame_timestamp;
|
||||
get_args(args, chat_id, animation, main_frame_timestamp);
|
||||
send_request(
|
||||
td_api::make_object<td_api::setChatPhoto>(chat_id,
|
||||
td_api::make_object<td_api::inputChatPhotoAnimation>(
|
||||
as_input_file(animation), to_double(main_frame_timestamp)),
|
||||
nullptr));
|
||||
send_request(td_api::make_object<td_api::setChatPhoto>(
|
||||
chat_id, td_api::make_object<td_api::inputChatPhotoAnimation>(as_input_file(animation),
|
||||
to_double(main_frame_timestamp))));
|
||||
} else if (op == "scps") {
|
||||
ChatId chat_id;
|
||||
string photo_path;
|
||||
ChatPhotoSticker sticker;
|
||||
get_args(args, chat_id, photo_path, sticker);
|
||||
get_args(args, chat_id, sticker);
|
||||
send_request(td_api::make_object<td_api::setChatPhoto>(
|
||||
chat_id, td_api::make_object<td_api::inputChatPhotoStatic>(as_input_file(photo_path)), sticker));
|
||||
} else if (op == "scpas") {
|
||||
ChatId chat_id;
|
||||
string animation;
|
||||
string main_frame_timestamp;
|
||||
ChatPhotoSticker sticker;
|
||||
get_args(args, chat_id, animation, main_frame_timestamp, sticker);
|
||||
send_request(
|
||||
td_api::make_object<td_api::setChatPhoto>(chat_id,
|
||||
td_api::make_object<td_api::inputChatPhotoAnimation>(
|
||||
as_input_file(animation), to_double(main_frame_timestamp)),
|
||||
sticker));
|
||||
chat_id, td_api::make_object<td_api::inputChatPhotoSticker>(sticker)));
|
||||
} else if (op == "scmt") {
|
||||
ChatId chat_id;
|
||||
int32 auto_delete_time;
|
||||
@ -4926,10 +4916,10 @@ class CliClient final : public Actor {
|
||||
int64 profile_photo_id;
|
||||
get_args(args, profile_photo_id);
|
||||
send_request(td_api::make_object<td_api::setProfilePhoto>(
|
||||
td_api::make_object<td_api::inputChatPhotoPrevious>(profile_photo_id), nullptr, op == "spppf"));
|
||||
td_api::make_object<td_api::inputChatPhotoPrevious>(profile_photo_id), op == "spppf"));
|
||||
} else if (op == "spp" || op == "sppf") {
|
||||
send_request(td_api::make_object<td_api::setProfilePhoto>(
|
||||
td_api::make_object<td_api::inputChatPhotoStatic>(as_input_file(args)), nullptr, op == "sppf"));
|
||||
td_api::make_object<td_api::inputChatPhotoStatic>(as_input_file(args)), op == "sppf"));
|
||||
} else if (op == "sppa" || op == "sppaf") {
|
||||
string animation;
|
||||
string main_frame_timestamp;
|
||||
@ -4937,22 +4927,12 @@ class CliClient final : public Actor {
|
||||
send_request(
|
||||
td_api::make_object<td_api::setProfilePhoto>(td_api::make_object<td_api::inputChatPhotoAnimation>(
|
||||
as_input_file(animation), to_double(main_frame_timestamp)),
|
||||
nullptr, op == "sppaf"));
|
||||
op == "sppaf"));
|
||||
} else if (op == "spps" || op == "sppsf") {
|
||||
string photo;
|
||||
ChatPhotoSticker sticker;
|
||||
get_args(args, photo, sticker);
|
||||
get_args(args, sticker);
|
||||
send_request(td_api::make_object<td_api::setProfilePhoto>(
|
||||
td_api::make_object<td_api::inputChatPhotoStatic>(as_input_file(photo)), sticker, op == "sppsf"));
|
||||
} else if (op == "sppas" || op == "sppasf") {
|
||||
string animation;
|
||||
string main_frame_timestamp;
|
||||
ChatPhotoSticker sticker;
|
||||
get_args(args, animation, main_frame_timestamp, sticker);
|
||||
send_request(
|
||||
td_api::make_object<td_api::setProfilePhoto>(td_api::make_object<td_api::inputChatPhotoAnimation>(
|
||||
as_input_file(animation), to_double(main_frame_timestamp)),
|
||||
sticker, op == "sppasf"));
|
||||
td_api::make_object<td_api::inputChatPhotoSticker>(sticker), op == "sppsf"));
|
||||
} else if (op == "suppp") {
|
||||
UserId user_id;
|
||||
string photo;
|
||||
@ -4967,10 +4947,16 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::setUserPersonalProfilePhoto>(
|
||||
user_id, td_api::make_object<td_api::inputChatPhotoAnimation>(as_input_file(animation),
|
||||
to_double(main_frame_timestamp))));
|
||||
} else if (op == "suppe") {
|
||||
} else if (op == "supppe") {
|
||||
UserId user_id;
|
||||
get_args(args, user_id);
|
||||
send_request(td_api::make_object<td_api::setUserPersonalProfilePhoto>(user_id, nullptr));
|
||||
} else if (op == "suppps") {
|
||||
UserId user_id;
|
||||
ChatPhotoSticker sticker;
|
||||
get_args(args, user_id, sticker);
|
||||
send_request(td_api::make_object<td_api::setUserPersonalProfilePhoto>(
|
||||
user_id, td_api::make_object<td_api::inputChatPhotoSticker>(sticker)));
|
||||
} else if (op == "supp") {
|
||||
UserId user_id;
|
||||
string photo;
|
||||
@ -4985,6 +4971,12 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::suggestUserProfilePhoto>(
|
||||
user_id, td_api::make_object<td_api::inputChatPhotoAnimation>(as_input_file(animation),
|
||||
to_double(main_frame_timestamp))));
|
||||
} else if (op == "supps") {
|
||||
UserId user_id;
|
||||
ChatPhotoSticker sticker;
|
||||
get_args(args, user_id, sticker);
|
||||
send_request(td_api::make_object<td_api::suggestUserProfilePhoto>(
|
||||
user_id, td_api::make_object<td_api::inputChatPhotoSticker>(sticker)));
|
||||
} else if (op == "sh") {
|
||||
const string &prefix = args;
|
||||
send_request(td_api::make_object<td_api::searchHashtags>(prefix, 10));
|
||||
|
Loading…
Reference in New Issue
Block a user