From d22dabfdaf70c5792444c5d55fa6deb49118c16d Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 9 Nov 2020 23:41:23 +0300 Subject: [PATCH 1/8] Update layer to 121. --- td/generate/scheme/telegram_api.tl | 1 + td/generate/scheme/telegram_api.tlo | Bin 218572 -> 218692 bytes td/telegram/DocumentsManager.cpp | 14 ++++---- td/telegram/MessageContent.cpp | 5 +-- td/telegram/Photo.cpp | 16 +++++++-- td/telegram/Photo.h | 2 +- td/telegram/StickersManager.cpp | 51 +++++++++++++++++++--------- td/telegram/StickersManager.h | 6 ++-- td/telegram/StickersManager.hpp | 33 +++++++++++++++--- td/telegram/Version.h | 2 +- 10 files changed, 96 insertions(+), 34 deletions(-) diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 5bdda4caa..e5c176f6d 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -181,6 +181,7 @@ photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = Phot photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize; photoStrippedSize#e0b0bc2e type:string bytes:bytes = PhotoSize; photoSizeProgressive#5aa86a51 type:string location:FileLocation w:int h:int sizes:Vector = PhotoSize; +photoPathSize#d8214d41 type:string bytes:bytes = PhotoSize; geoPointEmpty#1117dd5f = GeoPoint; geoPoint#b2a2f663 flags:# long:double lat:double access_hash:long accuracy_radius:flags.0?int = GeoPoint; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index bb3f233d1cffbcd3c131306b6869984832e834b8..bb074e3407a2d6f860ee5dcae08145d8f77d38ba 100644 GIT binary patch delta 255 zcmX@Jn)k>W-VGg6f{%Zjec}wr$S=tc&a6shU|^eE$Sl5jgH(+SWAtWS^XzyQkc!Q7 zraid@W=(G?WSjzF$rLdfKv)4qj4}{bK@sB`2uq=uQ2{R2G5vu8lM00UrI-=QnlO)1 zX0pIWfyp_`p&|t(j2cLqVhR~mCL6pF(Ez!D0Sd0lam6_LD&F8N0J%CKu_OcHa*&$o a7)EYSC}m8s1e@7@Vjbi56YH2*mIDC(-*9^X delta 192 zcmX@IhWE^B-VGg6f{V6^YjFl-14}d3HPtNX6zk z)1KS{v!=HcGERZ8WQrIKAgq8QMi~gJponn|gr!i-r~nu1n4Gg*1;YDM%m`)4lrRQB oRg^GlAkthumbs_) { - auto photo_size = - get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, id, access_hash, file_reference, - DcId::create(dc_id), owner_dialog_id, std::move(thumb), thumbnail_format); + auto photo_size = get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, id, access_hash, + file_reference, DcId::create(dc_id), owner_dialog_id, std::move(thumb), + thumbnail_format, document_type != Document::Type::Sticker); if (photo_size.get_offset() == 0) { - thumbnail = std::move(photo_size.get<0>()); + if (!thumbnail.file_id.is_valid()) { + thumbnail = std::move(photo_size.get<0>()); + } } else { minithumbnail = std::move(photo_size.get<1>()); } @@ -429,8 +431,8 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo std::move(mime_type), !is_web); break; case Document::Type::Sticker: - td_->stickers_manager_->create_sticker(file_id, std::move(thumbnail), dimensions, std::move(sticker), - is_animated_sticker, load_data_multipromise_ptr); + td_->stickers_manager_->create_sticker(file_id, std::move(minithumbnail), std::move(thumbnail), dimensions, + std::move(sticker), is_animated_sticker, load_data_multipromise_ptr); break; case Document::Type::Video: td_->videos_manager_->create_video(file_id, std::move(minithumbnail), std::move(thumbnail), diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index c0a86779d..a52766d90 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -1638,8 +1638,9 @@ static Result create_input_message_content( } case td_api::inputMessageSticker::ID: { auto input_sticker = static_cast(input_message_content.get()); - td->stickers_manager_->create_sticker( - file_id, thumbnail, get_dimensions(input_sticker->width_, input_sticker->height_), nullptr, false, nullptr); + td->stickers_manager_->create_sticker(file_id, string(), thumbnail, + get_dimensions(input_sticker->width_, input_sticker->height_), nullptr, + false, nullptr); content = make_unique(file_id); break; diff --git a/td/telegram/Photo.cpp b/td/telegram/Photo.cpp index c512b1637..1e35b4175 100644 --- a/td/telegram/Photo.cpp +++ b/td/telegram/Photo.cpp @@ -358,7 +358,7 @@ PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice Variant get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id, int64 access_hash, std::string file_reference, DcId dc_id, DialogId owner_dialog_id, tl_object_ptr &&size_ptr, - PhotoFormat format) { + PhotoFormat format, bool expect_jpeg_minithumbnail) { CHECK(size_ptr != nullptr); tl_object_ptr location; @@ -393,6 +393,10 @@ Variant get_photo_size(FileManager *file_manager, PhotoSizeSo } case telegram_api::photoStrippedSize::ID: { auto size = move_tl_object_as(size_ptr); + if (!expect_jpeg_minithumbnail) { + LOG(ERROR) << "Receive unexpected JPEG minithumbnail"; + return std::move(res); + } return size->bytes_.as_slice().str(); } case telegram_api::photoSizeProgressive::ID: { @@ -413,6 +417,14 @@ Variant get_photo_size(FileManager *file_manager, PhotoSizeSo break; } + case telegram_api::photoPathSize::ID: { + auto size = move_tl_object_as(size_ptr); + if (expect_jpeg_minithumbnail) { + LOG(ERROR) << "Receive unexpected SVG minithumbnail"; + return std::move(res); + } + return size->bytes_.as_slice().str(); + } default: UNREACHABLE(); break; @@ -704,7 +716,7 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr && for (auto &size_ptr : photo->sizes_) { auto photo_size = get_photo_size(file_manager, {FileType::Photo, 0}, photo->id_, photo->access_hash_, photo->file_reference_.as_slice().str(), dc_id, owner_dialog_id, - std::move(size_ptr), PhotoFormat::Jpeg); + std::move(size_ptr), PhotoFormat::Jpeg, true); if (photo_size.get_offset() == 0) { PhotoSize &size = photo_size.get<0>(); if (size.type == 0 || size.type == 't' || size.type == 'i' || size.type == 'u' || size.type == 'v') { diff --git a/td/telegram/Photo.h b/td/telegram/Photo.h index 43db9372a..1d8a23572 100644 --- a/td/telegram/Photo.h +++ b/td/telegram/Photo.h @@ -113,7 +113,7 @@ PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice Variant get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id, int64 access_hash, string file_reference, DcId dc_id, DialogId owner_dialog_id, tl_object_ptr &&size_ptr, - PhotoFormat format); + PhotoFormat format, bool expect_jpeg_minithumbnail); AnimationSize get_animation_size(FileManager *file_manager, PhotoSizeSource source, int64 id, int64 access_hash, string file_reference, DcId dc_id, DialogId owner_dialog_id, tl_object_ptr &&size); diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index e335d7f8f..32fac339e 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1547,19 +1547,24 @@ FileId StickersManager::on_get_sticker(unique_ptr new_sticker, bool rep } if (s->alt != new_sticker->alt && !new_sticker->alt.empty()) { LOG(DEBUG) << "Sticker " << file_id << " emoji has changed"; - s->alt = new_sticker->alt; + s->alt = std::move(new_sticker->alt); + s->is_changed = true; + } + if (s->minithumbnail != new_sticker->minithumbnail) { + LOG(DEBUG) << "Sticker " << file_id << " minithumbnail has changed"; + s->minithumbnail = std::move(new_sticker->minithumbnail); s->is_changed = true; } if (s->s_thumbnail != new_sticker->s_thumbnail && new_sticker->s_thumbnail.file_id.is_valid()) { LOG_IF(INFO, s->s_thumbnail.file_id.is_valid()) << "Sticker " << file_id << " s thumbnail has changed from " << s->s_thumbnail << " to " << new_sticker->s_thumbnail; - s->s_thumbnail = new_sticker->s_thumbnail; + s->s_thumbnail = std::move(new_sticker->s_thumbnail); s->is_changed = true; } if (s->m_thumbnail != new_sticker->m_thumbnail && new_sticker->m_thumbnail.file_id.is_valid()) { LOG_IF(INFO, s->m_thumbnail.file_id.is_valid()) << "Sticker " << file_id << " m thumbnail has changed from " << s->m_thumbnail << " to " << new_sticker->m_thumbnail; - s->m_thumbnail = new_sticker->m_thumbnail; + s->m_thumbnail = std::move(new_sticker->m_thumbnail); s->is_changed = true; } if (s->is_animated != new_sticker->is_animated && new_sticker->is_animated) { @@ -1635,20 +1640,24 @@ std::pair StickersManager::on_get_sticker_document( PSTRING() << document_id << (is_animated ? ".tgs" : ".webp")); PhotoSize thumbnail; + string minithumbnail; for (auto &thumb : document->thumbs_) { auto photo_size = get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, document_id, document->access_hash_, document->file_reference_.as_slice().str(), dc_id, DialogId(), std::move(thumb), - has_webp_thumbnail(sticker) ? PhotoFormat::Webp : PhotoFormat::Jpeg); + has_webp_thumbnail(sticker) ? PhotoFormat::Webp : PhotoFormat::Jpeg, false); if (photo_size.get_offset() == 0) { - thumbnail = std::move(photo_size.get<0>()); + if (!thumbnail.file_id.is_valid()) { + thumbnail = std::move(photo_size.get<0>()); + } break; } else { - LOG(ERROR) << "Receive minithumbnail for a sticker " << sticker_id << ": " << to_string(sticker); + minithumbnail = std::move(photo_size.get<1>()); } } - create_sticker(sticker_id, std::move(thumbnail), dimensions, std::move(sticker), is_animated, nullptr); + create_sticker(sticker_id, std::move(minithumbnail), std::move(thumbnail), dimensions, std::move(sticker), + is_animated, nullptr); return {document_id, sticker_id}; } @@ -1963,7 +1972,7 @@ void StickersManager::add_sticker_thumbnail(Sticker *s, PhotoSize thumbnail) { LOG(ERROR) << "Receive sticker thumbnail of unsupported type " << thumbnail.type; } -void StickersManager::create_sticker(FileId file_id, PhotoSize thumbnail, Dimensions dimensions, +void StickersManager::create_sticker(FileId file_id, string minithumbnail, PhotoSize thumbnail, Dimensions dimensions, tl_object_ptr sticker, bool is_animated, MultiPromiseActor *load_data_multipromise_ptr) { if (is_animated && dimensions.width == 0) { @@ -1974,6 +1983,7 @@ void StickersManager::create_sticker(FileId file_id, PhotoSize thumbnail, Dimens auto s = make_unique(); s->file_id = file_id; s->dimensions = dimensions; + s->minithumbnail = std::move(minithumbnail); add_sticker_thumbnail(s.get(), thumbnail); if (sticker != nullptr) { s->set_id = on_get_input_sticker_set(file_id, std::move(sticker->stickerset_), load_data_multipromise_ptr); @@ -2158,14 +2168,17 @@ StickerSetId StickersManager::on_get_sticker_set(tl_object_ptrflags_ & telegram_api::stickerSet::MASKS_MASK) != 0; PhotoSize thumbnail; + string minithumbnail; if (set->thumb_ != nullptr) { auto photo_size = get_photo_size(td_->file_manager_.get(), {set_id.get(), s->access_hash}, 0, 0, "", DcId::create(set->thumb_dc_id_), DialogId(), std::move(set->thumb_), - is_animated ? PhotoFormat::Tgs : PhotoFormat::Webp); + is_animated ? PhotoFormat::Tgs : PhotoFormat::Webp, false); if (photo_size.get_offset() == 0) { - thumbnail = std::move(photo_size.get<0>()); + if (!thumbnail.file_id.is_valid()) { + thumbnail = std::move(photo_size.get<0>()); + } } else { - LOG(ERROR) << "Receive minithumbnail for a " << set_id; + minithumbnail = std::move(photo_size.get<1>()); } } if (!s->is_inited) { @@ -2173,9 +2186,10 @@ StickerSetId StickersManager::on_get_sticker_set(tl_object_ptris_inited = true; s->title = std::move(set->title_); s->short_name = std::move(set->short_name_); + s->minithumbnail = std::move(minithumbnail); s->thumbnail = std::move(thumbnail); s->is_thumbnail_reloaded = true; - s->are_legacy_thumbnails_reloaded = true; + s->are_legacy_sticker_thumbnails_reloaded = true; s->sticker_count = set->count_; s->hash = set->hash_; s->is_official = is_official; @@ -2209,15 +2223,20 @@ StickerSetId StickersManager::on_get_sticker_set(tl_object_ptris_masks].add(set_id.get(), PSLICE() << s->title << ' ' << s->short_name); } } + if (s->minithumbnail != minithumbnail) { + LOG(INFO) << "Minithumbnail of " << set_id << " has changed"; + s->minithumbnail = std::move(minithumbnail); + s->is_changed = true; + } if (s->thumbnail != thumbnail) { LOG(INFO) << "Thumbnail of " << set_id << " has changed from " << s->thumbnail << " to " << thumbnail; s->thumbnail = std::move(thumbnail); s->is_changed = true; } - if (!s->is_thumbnail_reloaded || !s->are_legacy_thumbnails_reloaded) { + if (!s->is_thumbnail_reloaded || !s->are_legacy_sticker_thumbnails_reloaded) { LOG(INFO) << "Sticker thumbnails and thumbnail of " << set_id << " was reloaded"; s->is_thumbnail_reloaded = true; - s->are_legacy_thumbnails_reloaded = true; + s->are_legacy_sticker_thumbnails_reloaded = true; s->need_save_to_database = true; } @@ -3399,7 +3418,7 @@ void StickersManager::on_load_sticker_set_from_database(StickerSetId sticker_set << format::as_hex_dump<4>(Slice(value)); } } - if (!sticker_set->is_thumbnail_reloaded || !sticker_set->are_legacy_thumbnails_reloaded) { + if (!sticker_set->is_thumbnail_reloaded || !sticker_set->are_legacy_sticker_thumbnails_reloaded) { do_reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto()); } @@ -4290,7 +4309,7 @@ Result> StickersManager::prepare_input_file if (is_animated) { int32 width = for_thumbnail ? 100 : 512; - create_sticker(file_id, PhotoSize(), get_dimensions(width, width), nullptr, true, nullptr); + create_sticker(file_id, string(), PhotoSize(), get_dimensions(width, width), nullptr, true, nullptr); } else { td_->documents_manager_->create_document(file_id, string(), PhotoSize(), "sticker.png", "image/png", false); } diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index dc018fca7..7e4ec1254 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -69,7 +69,7 @@ class StickersManager : public Actor { void unregister_dice(const string &emoji, int32 value, FullMessageId full_message_id, const char *source); - void create_sticker(FileId file_id, PhotoSize thumbnail, Dimensions dimensions, + void create_sticker(FileId file_id, string minithumbnail, PhotoSize thumbnail, Dimensions dimensions, tl_object_ptr sticker, bool is_animated, MultiPromiseActor *load_data_multipromise_ptr); @@ -304,6 +304,7 @@ class StickersManager : public Actor { StickerSetId set_id; string alt; Dimensions dimensions; + string minithumbnail; PhotoSize s_thumbnail; PhotoSize m_thumbnail; FileId file_id; @@ -331,6 +332,7 @@ class StickersManager : public Actor { int32 hash = 0; int32 expires_at = 0; + string minithumbnail; PhotoSize thumbnail; vector sticker_ids; @@ -344,7 +346,7 @@ class StickersManager : public Actor { bool is_masks = false; bool is_viewed = true; bool is_thumbnail_reloaded = false; - bool are_legacy_thumbnails_reloaded = false; + bool are_legacy_sticker_thumbnails_reloaded = false; mutable bool was_update_sent = false; // does the sticker set is known to the client bool is_changed = true; // have new changes that need to be sent to the client and database bool need_save_to_database = true; // have new changes that need only to be saved to the database diff --git a/td/telegram/StickersManager.hpp b/td/telegram/StickersManager.hpp index a2bff4cc8..640822d33 100644 --- a/td/telegram/StickersManager.hpp +++ b/td/telegram/StickersManager.hpp @@ -25,11 +25,13 @@ void StickersManager::store_sticker(FileId file_id, bool in_sticker_set, StorerT CHECK(it != stickers_.end()); const Sticker *sticker = it->second.get(); bool has_sticker_set_access_hash = sticker->set_id.is_valid() && !in_sticker_set; + bool has_minithumbnail = !sticker->minithumbnail.empty(); BEGIN_STORE_FLAGS(); STORE_FLAG(sticker->is_mask); STORE_FLAG(has_sticker_set_access_hash); STORE_FLAG(in_sticker_set); STORE_FLAG(sticker->is_animated); + STORE_FLAG(has_minithumbnail); END_STORE_FLAGS(); if (!in_sticker_set) { store(sticker->set_id.get(), storer); @@ -50,6 +52,9 @@ void StickersManager::store_sticker(FileId file_id, bool in_sticker_set, StorerT store(sticker->y_shift, storer); store(sticker->scale, storer); } + if (has_minithumbnail) { + store(sticker->minithumbnail, storer); + } } template @@ -61,11 +66,13 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) { auto sticker = make_unique(); bool has_sticker_set_access_hash; bool in_sticker_set_stored; + bool has_minithumbnail; BEGIN_PARSE_FLAGS(); PARSE_FLAG(sticker->is_mask); PARSE_FLAG(has_sticker_set_access_hash); PARSE_FLAG(in_sticker_set_stored); PARSE_FLAG(sticker->is_animated); + PARSE_FLAG(has_minithumbnail); END_PARSE_FLAGS(); if (in_sticker_set_stored != in_sticker_set) { Slice data = parser.template fetch_string_raw(parser.get_left_len()); @@ -105,6 +112,9 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) { parse(sticker->y_shift, parser); parse(sticker->scale, parser); } + if (has_minithumbnail) { + parse(sticker->minithumbnail, parser); + } if (parser.get_error() != nullptr || !sticker->file_id.is_valid()) { return FileId(); } @@ -119,6 +129,7 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with bool is_loaded = sticker_set->is_loaded && is_full; bool has_expires_at = !sticker_set->is_installed && sticker_set->expires_at != 0; bool has_thumbnail = sticker_set->thumbnail.file_id.is_valid(); + bool has_minithumbnail = !sticker_set->minithumbnail.empty(); BEGIN_STORE_FLAGS(); STORE_FLAG(sticker_set->is_inited); STORE_FLAG(was_loaded); @@ -132,7 +143,8 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with STORE_FLAG(has_thumbnail); STORE_FLAG(sticker_set->is_thumbnail_reloaded); STORE_FLAG(sticker_set->is_animated); - STORE_FLAG(sticker_set->are_legacy_thumbnails_reloaded); + STORE_FLAG(sticker_set->are_legacy_sticker_thumbnails_reloaded); + STORE_FLAG(has_minithumbnail); END_STORE_FLAGS(); store(sticker_set->id.get(), storer); store(sticker_set->access_hash, storer); @@ -147,6 +159,9 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with if (has_thumbnail) { store(sticker_set->thumbnail, storer); } + if (has_minithumbnail) { + store(sticker_set->minithumbnail, storer); + } uint32 stored_sticker_count = narrow_cast(is_full ? sticker_set->sticker_ids.size() : stickers_limit); store(stored_sticker_count, storer); @@ -175,9 +190,10 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser bool is_archived; bool is_official; bool is_masks; - bool is_animated; bool has_expires_at; bool has_thumbnail; + bool is_animated; + bool has_minithumbnail; BEGIN_PARSE_FLAGS(); PARSE_FLAG(sticker_set->is_inited); PARSE_FLAG(sticker_set->was_loaded); @@ -191,7 +207,8 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser PARSE_FLAG(has_thumbnail); PARSE_FLAG(sticker_set->is_thumbnail_reloaded); PARSE_FLAG(is_animated); - PARSE_FLAG(sticker_set->are_legacy_thumbnails_reloaded); + PARSE_FLAG(sticker_set->are_legacy_sticker_thumbnails_reloaded); + PARSE_FLAG(has_minithumbnail); END_PARSE_FLAGS(); int64 sticker_set_id; int64 access_hash; @@ -206,6 +223,8 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser if (sticker_set->is_inited) { string title; string short_name; + string minithumbnail; + PhotoSize thumbnail; int32 sticker_count; int32 hash; int32 expires_at = 0; @@ -217,11 +236,17 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser parse(expires_at, parser); } if (has_thumbnail) { - parse(sticker_set->thumbnail, parser); + parse(thumbnail, parser); } + if (has_minithumbnail) { + parse(minithumbnail, parser); + } + if (!was_inited) { sticker_set->title = std::move(title); sticker_set->short_name = std::move(short_name); + sticker_set->minithumbnail = std::move(minithumbnail); + sticker_set->thumbnail = std::move(thumbnail); sticker_set->sticker_count = sticker_count; sticker_set->hash = hash; sticker_set->expires_at = expires_at; diff --git a/td/telegram/Version.h b/td/telegram/Version.h index 4a2097404..79e030266 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -8,7 +8,7 @@ namespace td { -constexpr int32 MTPROTO_LAYER = 120; +constexpr int32 MTPROTO_LAYER = 121; enum class Version : int32 { Initial, // 0 From 3ff1f6cec195e5fc278f5db8a4548fd69333f575 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 20 Nov 2020 16:22:07 +0300 Subject: [PATCH 2/8] Add sticker cover to API. --- td/generate/scheme/td_api.tl | 4 +-- td/generate/scheme/td_api.tlo | Bin 185276 -> 185308 bytes td/telegram/InlineQueriesManager.cpp | 2 +- td/telegram/StickersManager.cpp | 37 ++++++++++++++++++++++++++- td/telegram/StickersManager.h | 2 ++ 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0b0292236..0771082d7 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -270,8 +270,8 @@ photo has_stickers:Bool minithumbnail:minithumbnail sizes:vector = Ph //@description Describes a sticker @set_id The identifier of the sticker set to which the sticker belongs; 0 if none @width Sticker width; as defined by the sender @height Sticker height; as defined by the sender //@emoji Emoji corresponding to the sticker @is_animated True, if the sticker is an animated sticker in TGS format @is_mask True, if the sticker is a mask @mask_position Position where the mask should be placed; may be null -//@thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @sticker File containing the sticker -sticker set_id:int64 width:int32 height:int32 emoji:string is_animated:Bool is_mask:Bool mask_position:maskPosition thumbnail:thumbnail sticker:file = Sticker; +//@cover Sticker cover in an SVG format; may be empty @thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @sticker File containing the sticker +sticker set_id:int64 width:int32 height:int32 emoji:string is_animated:Bool is_mask:Bool mask_position:maskPosition cover:string thumbnail:thumbnail sticker:file = Sticker; //@description Describes a video file @duration Duration of the video, in seconds; as defined by the sender @width Video width; as defined by the sender @height Video height; as defined by the sender //@file_name Original name of the file; as defined by the sender @mime_type MIME type of the file; as defined by the sender diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 9379f8423d0c402634a64468d158bb80aa85aa81..825cc0800680de63f9e32c4704a4ac41b8e6fe7a 100644 GIT binary patch delta 287 zcmdn9ocqpl?hOqZJb&Jr^son)WF}{)7EL@Lv3ZHcjcOK<;N*rS2`V54BLf6TKfABV znv+_VS_I*9*tQ)6D`Z)!0MVfVWB5QBn+uk9NI~R2>{8e)bKplXm^VE@kWpc~g$U!5 zEHHn&LOtUKMNzO@iXm#JGWx73|!}3%^NER#+jjonr~(3r2{2UzRd{fyhojD9$9moo6|tMg~Oc Z0XLJ(^c)dJf$0{aj4InZ_?b+O003m+d7S_N delta 274 zcmcb!oO{o5?hOqZJpBjuU1JX}$xO~pEt+^hV)GJ>8`Ufz!O0Cv5>!A8Mg|Cwes*7z zH7B(!wFtuJux&dCR>-nc0ir_##_)kMHWw`Ikb=m4*rl*p=D?3&FmHN*Afv)|3lYXA zSz!Klg?h#filSh*6hqtsV&6O_ copy(const td_api::photo &obj) { template <> tl_object_ptr copy(const td_api::sticker &obj) { return make_tl_object(obj.set_id_, obj.width_, obj.height_, obj.emoji_, obj.is_animated_, - obj.is_mask_, copy(obj.mask_position_), copy(obj.thumbnail_), + obj.is_mask_, copy(obj.mask_position_), obj.cover_, copy(obj.thumbnail_), copy(obj.sticker_)); } diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 32fac339e..2e93cdf86 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1334,6 +1334,40 @@ tl_object_ptr StickersManager::get_mask_point_object(int32 po } } +string StickersManager::get_sticker_minithumbnail(const string &path) { + if (path.empty()) { + return string(); + } + + const auto prefix = Slice( + ""); + + auto buf = StackAllocator::alloc(1 << 7); + StringBuilder sb(buf.as_slice(), true); + + sb << prefix; + for (unsigned char c : path) { + if (c >= 128 + 64) { + sb << "AACAAAAHAAALMAAAQASTAVAAAZaacaaaahaaalmaaaqastava.az0123456789-,"[c - 128 - 64]; + } else { + if (c >= 128) { + sb << ','; + } else if (c >= 64) { + sb << '-'; + } + sb << (c & 63); + } + } + sb << suffix; + + CHECK(!sb.is_error()); + return sb.as_cslice().str(); +} + tl_object_ptr StickersManager::get_sticker_object(FileId file_id) const { if (!file_id.is_valid()) { return nullptr; @@ -1362,7 +1396,8 @@ tl_object_ptr StickersManager::get_sticker_object(FileId file_i auto thumbnail_object = get_thumbnail_object(td_->file_manager_.get(), thumbnail, thumbnail_format); return make_tl_object(sticker->set_id.get(), sticker->dimensions.width, sticker->dimensions.height, sticker->alt, sticker->is_animated, sticker->is_mask, std::move(mask_position), - std::move(thumbnail_object), td_->file_manager_->get_file_object(file_id)); + get_sticker_minithumbnail(sticker->minithumbnail), std::move(thumbnail_object), + td_->file_manager_->get_file_object(file_id)); } tl_object_ptr StickersManager::get_stickers_object(const vector &sticker_ids) const { diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index 7e4ec1254..ae4032d29 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -393,6 +393,8 @@ class StickersManager : public Actor { class UploadStickerFileCallback; + static string get_sticker_minithumbnail(const string &path); + static tl_object_ptr get_mask_point_object(int32 point); tl_object_ptr get_sticker_set_info_object(StickerSetId sticker_set_id, From ccb0a4f63c87e1d3a9e347fb03b67e2771c308f5 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 23 Nov 2020 18:48:55 +0300 Subject: [PATCH 3/8] Update layer to 122. --- td/generate/scheme/telegram_api.tl | 32 +++++++++++++++++++++++++--- td/generate/scheme/telegram_api.tlo | Bin 218692 -> 222768 bytes td/telegram/DialogParticipant.cpp | 6 +++--- td/telegram/UpdatesManager.cpp | 6 ++++++ td/telegram/UpdatesManager.h | 4 ++++ td/telegram/Version.h | 2 +- 6 files changed, 43 insertions(+), 7 deletions(-) diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index e5c176f6d..d40821f2f 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -111,11 +111,11 @@ userStatusLastMonth#77ebc742 = UserStatus; chatEmpty#9ba2d800 id:int = Chat; chat#3bda1bde flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true deactivated:flags.5?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; chatForbidden#7328bdb id:int title:string = Chat; -channel#d31a961e flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat; +channel#d31a961e flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat; channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat; chatFull#1b7c9db3 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int = ChatFull; -channelFull#f0e6672a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?int location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int = ChatFull; +channelFull#ef3a6acd flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?int location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall = ChatFull; chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; chatParticipantCreator#da13538a user_id:int = ChatParticipant; @@ -169,6 +169,8 @@ messageActionSecureValuesSentMe#1b287353 values:Vector credentials: messageActionSecureValuesSent#d95c6154 types:Vector = MessageAction; messageActionContactSignUp#f3f25f76 = MessageAction; messageActionGeoProximityReached#98e0d697 from_id:Peer to_id:Peer distance:int = MessageAction; +messageActionGroupCall#7a0d7f42 flags:# call:InputGroupCall duration:flags.0?int = MessageAction; +messageActionInviteToGroupCall#f25f03a call:InputGroupCall user_id:int = MessageAction; dialog#2c171f72 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -350,6 +352,8 @@ updatePeerBlocked#246a4b22 peer_id:Peer blocked:Bool = Update; updateChannelUserTyping#ff2abe9f flags:# channel_id:int top_msg_id:flags.0?int user_id:int action:SendMessageAction = Update; updatePinnedMessages#ed85eab5 flags:# pinned:flags.0?true peer:Peer messages:Vector pts:int pts_count:int = Update; updatePinnedChannelMessages#8588878b flags:# pinned:flags.0?true channel_id:int messages:Vector pts:int pts_count:int = Update; +updateGroupCallParticipants#f2ebdb4e call:InputGroupCall participants:Vector version:int = Update; +updateGroupCall#85fe86ed call:GroupCall = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -436,6 +440,7 @@ sendMessageChooseContactAction#628cbc6f = SendMessageAction; sendMessageGamePlayAction#dd6a8f48 = SendMessageAction; sendMessageRecordRoundAction#88f27fbc = SendMessageAction; sendMessageUploadRoundAction#243e1c66 progress:int = SendMessageAction; +speakingInGroupCallAction#d92c2285 = SendMessageAction; contacts.found#b3134d9d my_results:Vector results:Vector chats:Vector users:Vector = contacts.Found; @@ -1024,7 +1029,7 @@ chatOnlines#f041e250 onlines:int = ChatOnlines; statsURL#47a971e0 url:string = StatsURL; -chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true = ChatAdminRights; +chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true = ChatAdminRights; chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true until_date:int = ChatBannedRights; @@ -1166,6 +1171,17 @@ peerBlocked#e8fd8014 peer_id:Peer date:int = PeerBlocked; stats.messageStats#8999f295 views_graph:StatsGraph = stats.MessageStats; +groupCallDiscarded#7780bcb4 id:long access_hash:long duration:int = GroupCall; +groupCall#55903081 flags:# join_muted:flags.1?true can_change_join_muted:flags.2?true id:long access_hash:long participants_count:int params:flags.0?DataJSON version:int = GroupCall; + +inputGroupCall#d8aa840f id:long access_hash:long = InputGroupCall; + +groupCallParticipant#56b087c9 flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true user_id:int date:int active_date:flags.3?int source:int = GroupCallParticipant; + +phone.groupCall#985c2087 call:GroupCall sources:Vector participants:Vector participants_next_offset:string users:Vector = phone.GroupCall; + +phone.groupParticipants#9cfeb92d count:int participants:Vector next_offset:string users:Vector version:int = phone.GroupParticipants; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1520,6 +1536,16 @@ phone.discardCall#b2cbc1c0 flags:# video:flags.0?true peer:InputPhoneCall durati phone.setCallRating#59ead627 flags:# user_initiative:flags.0?true peer:InputPhoneCall rating:int comment:string = Updates; phone.saveCallDebug#277add7e peer:InputPhoneCall debug:DataJSON = Bool; phone.sendSignalingData#ff7a9383 peer:InputPhoneCall data:bytes = Bool; +phone.createGroupCall#e428fa02 channel:InputChannel random_id:int = Updates; +phone.joinGroupCall#5f9c8e62 flags:# muted:flags.0?true call:InputGroupCall params:DataJSON = Updates; +phone.leaveGroupCall#500377f9 call:InputGroupCall source:int = Updates; +phone.editGroupCallMember#63146ae4 flags:# muted:flags.0?true call:InputGroupCall user_id:InputUser = Updates; +phone.inviteToGroupCall#dd698f84 call:InputGroupCall user_id:InputUser = Updates; +phone.discardGroupCall#7a777135 call:InputGroupCall = Updates; +phone.toggleGroupCallSettings#74bbb43d flags:# call:InputGroupCall join_muted:flags.0?Bool = Updates; +phone.getGroupCall#c7cb017 call:InputGroupCall = phone.GroupCall; +phone.getGroupParticipants#ae1910a4 call:InputGroupCall offset:string limit:int = phone.GroupParticipants; +phone.checkGroupCall#b74a7bea call:InputGroupCall source:int = Bool; langpack.getLangPack#f2f2330a lang_pack:string lang_code:string = LangPackDifference; langpack.getStrings#efea3803 lang_pack:string lang_code:string keys:Vector = Vector; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index bb074e3407a2d6f860ee5dcae08145d8f77d38ba..64da7db6c00e07be1f387dcc7815491b9b3fc1f9 100644 GIT binary patch delta 5637 zcma)Ae^gV~9nbf@sGuORLIcILmIoj6Qo;F?Ff{Gd{vs%%{iZv=)P->~zmTjEPw#>78-+lMxNlDK5 zhnw&Bdq4O4{d~Xgdw+Dil^*O&Prvs2IrDYO-~4yeo%;0W|MTcj%A#tA_tD0>I;nkJ zUZ_QXd(6ZKwi@nDeXOCr(Y?rlRn4~jDJN7q(K>cAza#Cw^e04*$5ACNbb4#*T{>NEXqyp@&)M|H*z`%u zL|5eq^~BJ^Y0vTLPtQ4b|JbM8l@70{dsUmn>y18Sd(Omw3Otn$%Nd zHqSnAXIHjHsPWRXEno^oi^@1y6`K9vqWd8?v{szOrA=_+0LvZNrFA0O`Yl+bz;-jT z41+P$SyjSI-d78yZkI8%qIL^NO|CH$);L@^hH^4ZGH*ABdg`K_p3sOaS)35+tM7xE zJD{g3v$KJ~>vhtsFCl;NdBpGHo*cpYqU) z?SxZ?)Uar5A(4^Up^^=KKQixcYg&I#6-(3N8jsV_P$^dGNctrIjS^H?3u!3uW8Nq= zm8KLBF#{uRZ5I4brK;0)bee6EkUD;KeT}PpO`}%==k)B!PKT?Uc#p$o3cQH)%7T34 zuLhgc?=edKP7~_h$EA#sBS70?U`8vC!gOKeqH-Oni)u22JtMlE9&WB4FD;_8Cm>Ub zbWW0{Jd+`{m6;3~#1W5Jx2n9+MJy!$0t>R(c!T8rd7%`%HZGN9v7D5O)U@A%PMqNk zQtL*ep5TTG-dU1wl54c)t{T-5nbdT`t|x;~Mb!TjJt)ZFW`W5>ev*6<@>mvR zlf_wJrN-_osHCG<78KG^MGgpbRGiIZb=gc7z@x;-{dh(yTNlvMA($lzw~Pv~iNX0z z46Xx@;uEB`z8T2&8%~xWA&1$=UD~0_0?$AZ#T`~17IMK(WzD%@P3&ezE)*u#rsOet zit-rVmORB5$-YlOWzTXYXvrn;p`aNG=!!A3CUg$<=E0Lvpf!amtEVu?ij~}4blM3S zQp*Apx-|thC>B$b@fw`UsOZ6VbcS&n!?aCfGOs$?I}NH8I|~Rr&IzjB%qcbEwF>8&sDax&kv|OEBUco=Z+)Sl2kcq4#AWJPS&F)GtuNa9r zfAGGHsdr&M?pjyl6-(>y#wO)VKGnP%pUl*cvV;`)g;gz}aC1Iv-E1PAdgNz7WXQT3 z*GNKb^=_PygxVn1>SYx7YnUy0WZsi(MkUscoDm&GR{Yv`?e=0>VqXT6YUjO_#v>UUg@Q!KCATK#gC!44zcMmY(Pzi55W#P+R=tv z1Pg_e+LvXco;J*|?4j{6{=~^h60Rwt4Tssnfy1~F$!0^?OvT`(g|E**_9L)_Dt8@G zFi__a*iU86N0|&qUa~X7AgvMRU`d3{Z;2@GONKLM)DwYXieYJ2Fv9kBumBZ$-%|jj zz#S6`zQ;g@nH*V;F|WPH6yR{+7^Eox!45`NcL(?>sQd34UU}4h9%`u~<+wI(O&N3? zXDEZm!Ka|S&tj8z37NRg_nBS1 z!plaO7`$Dbfj6m7z7Lu2aS|<2hKmnjVT_xiU^0qqItax-QLS)MDB0`+N&xey$Z|QpH%vD z!8PW;3`D}7NlJn3K;*Wv``fHvO=y%af~D2s8j%$ypkHp`vUgr*%bKpUWo_44(d@vo z#FZSq&PW=*4$U;Q=01iJt>lVOPaiC%3hSqLmD#(U%E4T&++Ck0TPOA@i!$v7te|k! zH(13*hvuT$12BDiWj;#(40cof{?G8So`w3Iei&VVJEN^1%+$D|U#T9s3tQgDoyb0b zEetnd9uhvs=UD3H=TM}@?1%bzQ!Ty80{7iy^hIwf1WEqq@dv5kCfWQu1{kA*129Ba z?Z3r7K`dK=++RT8DdLVc$3MF~@XtJ&WAzNAxgvU0BJiX{Cs&;W8}rZ}8#hIduYEeS z^eD_J8@bRIFWz|}W5hxX91?(QZ?f7WQP}t;>>WdcjQk6>&{5NJZXtSk2tK>}=dy6x zzv1>1^u<7UjN9-=(_${aMDv_c#qRS&Ms}w$|A#+>jB%d&#s;V8L4j5%l+rdDWD=}| z1m%xdncVTG8&A1Q+~6&*U$x33dZkH^n$eo?aSuK~7G_h(m#2AFk)6|Kgy>`^(b{)l zhPo=He)AkYTe82IgI-?F{ScKM#g#?u!(Nf|Po%sM3c^iZu0q-B@NYM2Th3XLZyndK z+PK59^<0}CR)=5paWnoZAEm>Qxx8;e&duk38aC2LA7{1btW^sK^={@eb4I(|$iboZ zGh8-#9zZ>tI0Gtvi0{bbzOnXARCh{G!40%-Dt=4Z`koO*2f^?+{ICMH z2iC6Nm__GQ(ifQcq-DSLeM#6!R8r){0YwJEQqZ^B=**!gVr5PI1?>rO&9h>IPDhYX z@C)t-y!L5i)XQP86?a?WA2L477jMcA`qJ*9$W>w-SjWmMnQyELSh` zm1j~{$s?AUqtS^qj&dc|p|ktAIWn_3U$5uwO3~Gcj&<=mL2#Wjnns&V;)>TC$xqn+ zFki-7AKHJ&JB51Yt*@%8i-Ro_ysDtpYFs;R6h=;pur=YDg4$W Id`ss40Prn}zW@LL delta 3685 zcmai1e{7R=8sGE29Sq#et2c5bE3CMpy`v``nU{I#X_0x%SatqNRElodrn_7-iu4jL zqBr6+CN8n?UHWjcKbmMF>M+x{TH*nAP`8N#3k(@-%ESR3_M~caA#-~7ec$i@6!hyL08Aij2RT-Y#pll>KY^<*!QCv^9nP^7lZ1_0O+R zcUUeLtC@vKSslOHId9QZ6^@3oyIMDGYI>q|b#v&i8`_JCtZdr~t6IJ2p9>dH@6AnL zbAM}l%M~VNY@_^Jb)vFGF3UYR@bJ6`gDp*=)}ja1d#mPOtM0kUFTpx>QSF)=VKLj* zd_S|Rin{mlAyE6;w#e9dGq{*7Sgr;FFMw)qPe~Rn(8y8AtvWVN!tb=>#5t5y4{d1=T`u9@d5`SbJry2+~*;1tHG3TP3hS{t~;DX|pX;?!fxhHZu{vIN}u zf$NtLNXK(fXTX`VEcX>M2ftzgg$L}5bvH2O<`SU`FC~oGKys!mcm!&MoxhUM!j;e< zWRsQP%paY@4zB##Han5hZ6~}m_t24kasWsni~)LsWJGkytIFN1qn_<)hX&~*k7 zORRQd=5L^|%k5V5Rl#QAJycbQL&ZV)dmWTv$U(71P1%TfDp?L~0y(stJc2#oM$dMs zTqv^33#DFjJ&_u?9zwcD+~$O?tyXOwu52MqhKbiX)A_WKH+X{ilvvNT79GU>Ccjrd z#R_`N{DMc@n?FYx`30G`w@@rE6x61AIcs_IDBoQO+0V6CWEn4g3p|QNTOjD$4?%HC z><7DkV)jGU?T;&%T_rn(s`dk3cHP|juvCM6OJoHTKY~Xe7G0kG035a(ccf{BAihFoNJl0OT>WLez2QP7S_Mc z$@cwwEtVdVj5J~geqyjuUCVk}6s$Q2wE{SJkT<^`ZS)}c#3@TM7QWyXq6d=3{kSE` zXH|DdB@NfehrEY%(dG~Nm{JnO2-Cm=TE8MP0DfW6I6&8NN{o6~290{4a}erBLg5}0V{TWL?ELiXIibgK9&sD8V(V7<9i%v_aPV) zKwTe`LaCQ++h0=9<&f=HbbxP|!VL~n3X{VWTE4!C9tNk(nPD3qsm7VZM78gT38w8? zoy1*7D2myht^dT3vBXX{W*xE%Q=dRsIJBhZux`Pvr(p#KbFf8d>yA=veOYj`iC1ix zI7-z_bER1@3l*#qTaFQleaFZ)bqnX>@-b>j<@lV80>`0IT$efy4lA|5+z+9iTj>bc z^K0uyDD&V5j0?Pm6Li0K6RcwU*DuA4g$I&80Rdt0(5IB(EMGI95>np;gs|r%B!zLy zD8ZS=kyCteXwm84oahMD;og&=;GR>^ZNzYz*!LcAWAAB#7@-rh?{=YcjN}bte2wMh zpnHsO^1RxSu|f=$ju&FLetgajF&g33asJ>C+-a`ygDGDaqLmh47NJLStlRQbL% z@R(LoJ}ot~J3d#?(>+P;qIq`HFC3bjGY^h)G~pqWS&elZK1XfqId9-#@H})F`JSgT z*e*bqko8_LWLlF&(v-X_4Gwd10pH%ohrTmS!`YLjnc#048%sPO3KW^5*tLdjoC1%y zBRWN;NstBRrYM%w`|tXQDGFXJL~idzigNTKbc!n)znbkUmfcsXeR%yOw|3yNS(Q-tMP}!P{o3e*_n6BhT%yl#sy!) zvjRK(HF=wxQMp7RcrHGr^Yxbd-dOQ*?+iGNf#b*S_kM)Scj^Bxq5Vc_^J^iWv@E`7gVcGoeqG%A zj5JE-k4if*{V0DWB|D^1p^k2qT*c5BKm5FO!@I@WW3C9BUX&{1R*&qz3Uh1aWZZLy XTn^ZAr|gM$-Yxs(_>TMJ9l!ZM!|UyA diff --git a/td/telegram/DialogParticipant.cpp b/td/telegram/DialogParticipant.cpp index 5907fca2b..2fb216fd9 100644 --- a/td/telegram/DialogParticipant.cpp +++ b/td/telegram/DialogParticipant.cpp @@ -162,9 +162,9 @@ tl_object_ptr DialogParticipantStatus::get_chat_a } LOG(INFO) << "Create chat admin rights " << flags; - return make_tl_object(flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, - false /*ignored*/, false /*ignored*/, false /*ignored*/, - false /*ignored*/, false /*ignored*/, false /*ignored*/); + return make_tl_object( + flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, + false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/); } tl_object_ptr DialogParticipantStatus::get_chat_banned_rights() const { diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index c86f2d789..5ad5d8520 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -2173,4 +2173,10 @@ void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { } +void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { +} + +void UpdatesManager::on_update(tl_object_ptr update, bool /*force_apply*/) { +} + } // namespace td diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index 9bf7aa365..efe3f3dbf 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -318,6 +318,10 @@ class UpdatesManager : public Actor { // unsupported updates void on_update(tl_object_ptr update, bool /*force_apply*/); + + void on_update(tl_object_ptr update, bool /*force_apply*/); + + void on_update(tl_object_ptr update, bool /*force_apply*/); }; } // namespace td diff --git a/td/telegram/Version.h b/td/telegram/Version.h index 79e030266..670deef38 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -8,7 +8,7 @@ namespace td { -constexpr int32 MTPROTO_LAYER = 121; +constexpr int32 MTPROTO_LAYER = 122; enum class Version : int32 { Initial, // 0 From 905aa871e1407f7ccd8780277e041b72d514de5e Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 23 Nov 2020 19:50:03 +0300 Subject: [PATCH 4/8] Add SpeakingInCall chat action. --- td/generate/scheme/td_api.tl | 2 ++ td/generate/scheme/td_api.tlo | Bin 185308 -> 185376 bytes td/telegram/DialogAction.cpp | 14 ++++++++++++++ td/telegram/DialogAction.h | 3 ++- td/telegram/cli.cpp | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0771082d7..29f73cd64 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1931,6 +1931,8 @@ chatActionStartPlayingGame = ChatAction; chatActionRecordingVideoNote = ChatAction; //@description The user is uploading a video note @progress Upload progress, as a percentage chatActionUploadingVideoNote progress:int32 = ChatAction; +//@description The user is speaking in a call; supergroups only +chatActionSpeakingInCall = ChatAction; //@description The user has cancelled the previous action chatActionCancel = ChatAction; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 825cc0800680de63f9e32c4704a4ac41b8e6fe7a..c1f7b57070961819d7f9401a23202b7018745567 100644 GIT binary patch delta 471 zcmcb!oO{6v?hPtzf;S#-zrp34kyzrGT#}ie$G|r^P*P&EFPpYDqtE6_!^4^qAQd-{ z3HdMpL6I|?4u@^qL6F$wkZ2v;k~5-pSiq`kVobn{NihbvReQu3psJp{B?e9ZWSLlW zk(O9I4mg2Nk|z$2&VV>PE}apFaH$8#gP>pmfva*{G52SD^_NJ72WD_VYGQU~Ub<(V zb7D>oPz}zYWQkY7892=j@!K8Z886hcf~}iwc#=_myUBgVIftME7X_K*w|`m4^uiDT DCfU%? delta 400 zcmZ3mg8R;L?hPtzg6!2!)47~85=$JDOEUBG7cq~hi= zAs+@HC~{`g;jnEx2ojqd60L( &&action) { init(Type::UploadingVideoNote, uploading_action->progress_); break; } + case td_api::chatActionSpeakingInCall::ID: + init(Type::SpeakingInCall); + break; default: UNREACHABLE(); break; @@ -137,6 +140,9 @@ DialogAction::DialogAction(tl_object_ptr &&acti init(Type::UploadingVideoNote, upload_round_action->progress_); break; } + case telegram_api::speakingInGroupCallAction::ID: + init(Type::SpeakingInCall); + break; default: UNREACHABLE(); break; @@ -171,6 +177,8 @@ tl_object_ptr DialogAction::get_input_send_mess return make_tl_object(); case Type::UploadingVideoNote: return make_tl_object(progress_); + case Type::SpeakingInCall: + return make_tl_object(); default: UNREACHABLE(); return nullptr; @@ -205,6 +213,8 @@ tl_object_ptr DialogAction::get_secret_input_send return make_tl_object(); case Type::UploadingVideoNote: return make_tl_object(); + case Type::SpeakingInCall: + return make_tl_object(); default: UNREACHABLE(); return nullptr; @@ -239,6 +249,8 @@ tl_object_ptr DialogAction::get_chat_action_object() const { return td_api::make_object(); case Type::UploadingVideoNote: return td_api::make_object(progress_); + case Type::SpeakingInCall: + return td_api::make_object(); default: UNREACHABLE(); return td_api::make_object(); @@ -366,6 +378,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const DialogAction &act return "RecordingVideoNote"; case DialogAction::Type::UploadingVideoNote: return "UploadingVideoNote"; + case DialogAction::Type::SpeakingInCall: + return "SpeakingInCall"; default: UNREACHABLE(); return "Cancel"; diff --git a/td/telegram/DialogAction.h b/td/telegram/DialogAction.h index 4be76e03d..fc8cc9888 100644 --- a/td/telegram/DialogAction.h +++ b/td/telegram/DialogAction.h @@ -30,7 +30,8 @@ class DialogAction { ChoosingContact, StartPlayingGame, RecordingVideoNote, - UploadingVideoNote + UploadingVideoNote, + SpeakingInCall }; Type type_ = Type::Cancel; int32 progress_ = 0; diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 945c40581..3121eb6d5 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1195,6 +1195,9 @@ class CliClient final : public Actor { if (action == "uvn" || action == "upload_video_note") { return td_api::make_object(50); } + if (action == "sic" || action == "speaking_in_call") { + return td_api::make_object(); + } return td_api::make_object(); } From 59e0f03b5f73bf704752c7a6b39366d2b5354e21 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 24 Nov 2020 01:36:20 +0300 Subject: [PATCH 5/8] Update UpdatesManager::is_acceptable_message. --- td/telegram/UpdatesManager.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 5ad5d8520..7191d924e 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -557,6 +557,7 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_ case telegram_api::messageActionSecureValuesSent::ID: case telegram_api::messageActionSecureValuesSentMe::ID: case telegram_api::messageActionContactSignUp::ID: + case telegram_api::messageActionGroupCall::ID: break; case telegram_api::messageActionChatCreate::ID: { auto chat_create = static_cast(action); @@ -614,6 +615,13 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_ } break; } + case telegram_api::messageActionInviteToGroupCall::ID: { + auto invite_to_group_call = static_cast(action); + if (!is_acceptable_user(UserId(invite_to_group_call->user_id_))) { + return false; + } + break; + } default: UNREACHABLE(); return false; From 3e13b0cd3104f8be046e69367051ab0a84ae1847 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 24 Nov 2020 02:43:14 +0300 Subject: [PATCH 6/8] Add can_manage_calls admin right. --- td/generate/scheme/td_api.tl | 3 ++- td/generate/scheme/td_api.tlo | Bin 185376 -> 185420 bytes td/telegram/DialogParticipant.cpp | 28 +++++++++++++++++++--------- td/telegram/DialogParticipant.h | 9 +++++++-- td/telegram/cli.cpp | 14 +++++++------- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 29f73cd64..70928b050 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -458,8 +458,9 @@ chatMemberStatusCreator custom_title:string is_anonymous:Bool is_member:Bool = C //@can_restrict_members True, if the administrator can restrict, ban, or unban chat members //@can_pin_messages True, if the administrator can pin messages; applicable to groups only //@can_promote_members True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that were directly or indirectly promoted by them +//@can_manage_calls True, if the administrator can manage group calls; applicable to supergroups only //@is_anonymous True, if the administrator isn't shown in the chat member list and sends messages anonymously; applicable to supergroups only -chatMemberStatusAdministrator custom_title:string can_be_edited:Bool can_change_info:Bool can_post_messages:Bool can_edit_messages:Bool can_delete_messages:Bool can_invite_users:Bool can_restrict_members:Bool can_pin_messages:Bool can_promote_members:Bool is_anonymous:Bool = ChatMemberStatus; +chatMemberStatusAdministrator custom_title:string can_be_edited:Bool can_change_info:Bool can_post_messages:Bool can_edit_messages:Bool can_delete_messages:Bool can_invite_users:Bool can_restrict_members:Bool can_pin_messages:Bool can_promote_members:Bool can_manage_calls:Bool is_anonymous:Bool = ChatMemberStatus; //@description The user is a member of a chat, without any additional privileges or restrictions chatMemberStatusMember = ChatMemberStatus; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index c1f7b57070961819d7f9401a23202b7018745567..d3b24a8f09e3762d8c236db89de7827710fd18da 100644 GIT binary patch delta 303 zcmZ3mg8R%0?hQ9MSR_iXSZ=<<(P0B&Ww@?U0JA0^NK=?>k(L1A%t?cbwqS@TZ0<>y z5r7DB) zMt~J$62tVyzl_F{AC&7rR0&kHh=9czAmFMTS4=dEGwK0kP*nH6G;(H5w3AJ~a?u sHuuzQ@2O#2q7QNNWJOow_KY=*+cVZM9bkd_(can_be_edited) * CAN_BE_EDITED) | (static_cast(can_change_info) * CAN_CHANGE_INFO_AND_SETTINGS_ADMIN) | (static_cast(can_post_messages) * CAN_POST_MESSAGES) | @@ -48,6 +49,7 @@ DialogParticipantStatus DialogParticipantStatus::Administrator(bool is_anonymous (static_cast(can_restrict_members) * CAN_RESTRICT_MEMBERS) | (static_cast(can_pin_messages) * CAN_PIN_MESSAGES_ADMIN) | (static_cast(can_promote_members) * CAN_PROMOTE_MEMBERS) | + (static_cast(can_manage_calls) * CAN_MANAGE_CALLS) | (static_cast(is_anonymous) * IS_ANONYMOUS); if (flags == 0 || flags == CAN_BE_EDITED) { return Member(); @@ -90,14 +92,14 @@ DialogParticipantStatus DialogParticipantStatus::Banned(int32 banned_until_date) } DialogParticipantStatus DialogParticipantStatus::GroupAdministrator(bool is_creator) { - return Administrator(false, string(), is_creator, true, false, false, true, true, true, true, false); + return Administrator(false, string(), is_creator, true, false, false, true, true, true, true, false, false); } DialogParticipantStatus DialogParticipantStatus::ChannelAdministrator(bool is_creator, bool is_megagroup) { if (is_megagroup) { - return Administrator(false, string(), is_creator, true, false, false, true, true, true, true, false); + return Administrator(false, string(), is_creator, true, false, false, true, true, true, true, false, false); } else { - return Administrator(false, string(), is_creator, false, true, true, true, false, true, false, false); + return Administrator(false, string(), is_creator, false, true, true, true, false, true, false, false, false); } } @@ -115,7 +117,7 @@ tl_object_ptr DialogParticipantStatus::get_chat_member return td_api::make_object( rank_, can_be_edited(), can_change_info_and_settings(), can_post_messages(), can_edit_messages(), can_delete_messages(), can_invite_users(), can_restrict_members(), can_pin_messages(), can_promote_members(), - is_anonymous()); + can_manage_calls(), is_anonymous()); case Type::Member: return td_api::make_object(); case Type::Restricted: @@ -157,6 +159,9 @@ tl_object_ptr DialogParticipantStatus::get_chat_a if (can_promote_members()) { flags |= telegram_api::chatAdminRights::ADD_ADMINS_MASK; } + if (can_manage_calls()) { + flags |= telegram_api::chatAdminRights::MANAGE_CALL_MASK; + } if (is_anonymous()) { flags |= telegram_api::chatAdminRights::ANONYMOUS_MASK; } @@ -314,6 +319,9 @@ StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipant if (status.can_promote_members()) { string_builder << "(promote)"; } + if (status.can_manage_calls()) { + string_builder << "(call)"; + } if (!status.rank_.empty()) { string_builder << " [" << status.rank_ << "]"; } @@ -396,7 +404,7 @@ DialogParticipantStatus get_dialog_participant_status(const tl_object_ptris_anonymous_, st->custom_title_, true /*st->can_be_edited_*/, st->can_change_info_, st->can_post_messages_, st->can_edit_messages_, st->can_delete_messages_, st->can_invite_users_, - st->can_restrict_members_, st->can_pin_messages_, st->can_promote_members_); + st->can_restrict_members_, st->can_pin_messages_, st->can_promote_members_, st->can_manage_calls_); } case td_api::chatMemberStatusMember::ID: return DialogParticipantStatus::Member(); @@ -437,10 +445,12 @@ DialogParticipantStatus get_dialog_participant_status(bool can_be_edited, bool can_restrict_members = (admin_rights->flags_ & telegram_api::chatAdminRights::BAN_USERS_MASK) != 0; bool can_pin_messages = (admin_rights->flags_ & telegram_api::chatAdminRights::PIN_MESSAGES_MASK) != 0; bool can_promote_members = (admin_rights->flags_ & telegram_api::chatAdminRights::ADD_ADMINS_MASK) != 0; + bool can_manage_calls = (admin_rights->flags_ & telegram_api::chatAdminRights::MANAGE_CALL_MASK) != 0; bool is_anonymous = (admin_rights->flags_ & telegram_api::chatAdminRights::ANONYMOUS_MASK) != 0; - return DialogParticipantStatus::Administrator( - is_anonymous, std::move(rank), can_be_edited, can_change_info, can_post_messages, can_edit_messages, - can_delete_messages, can_invite_users, can_restrict_members, can_pin_messages, can_promote_members); + return DialogParticipantStatus::Administrator(is_anonymous, std::move(rank), can_be_edited, can_change_info, + can_post_messages, can_edit_messages, can_delete_messages, + can_invite_users, can_restrict_members, can_pin_messages, + can_promote_members, can_manage_calls); } DialogParticipantStatus get_dialog_participant_status( diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h index 9681d5fff..028aeb4c4 100644 --- a/td/telegram/DialogParticipant.h +++ b/td/telegram/DialogParticipant.h @@ -118,6 +118,7 @@ class DialogParticipantStatus { static constexpr uint32 CAN_RESTRICT_MEMBERS = 1 << 6; static constexpr uint32 CAN_PIN_MESSAGES_ADMIN = 1 << 7; static constexpr uint32 CAN_PROMOTE_MEMBERS = 1 << 8; + static constexpr uint32 CAN_MANAGE_CALLS = 1 << 9; static constexpr uint32 CAN_BE_EDITED = 1 << 15; @@ -143,7 +144,7 @@ class DialogParticipantStatus { static constexpr uint32 ALL_ADMINISTRATOR_RIGHTS = CAN_CHANGE_INFO_AND_SETTINGS_ADMIN | CAN_POST_MESSAGES | CAN_EDIT_MESSAGES | CAN_DELETE_MESSAGES | - CAN_INVITE_USERS_ADMIN | CAN_RESTRICT_MEMBERS | CAN_PIN_MESSAGES_ADMIN | CAN_PROMOTE_MEMBERS; + CAN_INVITE_USERS_ADMIN | CAN_RESTRICT_MEMBERS | CAN_PIN_MESSAGES_ADMIN | CAN_PROMOTE_MEMBERS | CAN_MANAGE_CALLS; static constexpr uint32 ALL_ADMIN_PERMISSION_RIGHTS = CAN_CHANGE_INFO_AND_SETTINGS_BANNED | CAN_INVITE_USERS_BANNED | CAN_PIN_MESSAGES_BANNED; @@ -171,7 +172,7 @@ class DialogParticipantStatus { static DialogParticipantStatus Administrator(bool is_anonymous, string rank, bool can_be_edited, bool can_change_info, bool can_post_messages, bool can_edit_messages, bool can_delete_messages, bool can_invite_users, bool can_restrict_members, bool can_pin_messages, - bool can_promote_members); + bool can_promote_members, bool can_manage_calls); static DialogParticipantStatus Member(); @@ -237,6 +238,10 @@ class DialogParticipantStatus { return (flags_ & CAN_PROMOTE_MEMBERS) != 0; } + bool can_manage_calls() const { + return (flags_ & CAN_MANAGE_CALLS) != 0; + } + bool can_be_edited() const { return (flags_ & CAN_BE_EDITED) != 0; } diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 3121eb6d5..d7c032afc 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3835,25 +3835,25 @@ class CliClient final : public Actor { status = td_api::make_object("", false, false); } else if (status_str == "anon") { status = td_api::make_object("anon", true, true, true, true, true, true, - true, true, true, true); + true, true, true, false, true); } else if (status_str == "anonadmin") { status = td_api::make_object("anon", false, false, false, false, false, - false, false, false, false, true); + false, false, false, false, false, true); } else if (status_str == "addadmin") { status = td_api::make_object("anon", false, false, false, false, false, - false, false, false, true, false); + false, false, false, true, false, false); } else if (status_str == "admin") { status = td_api::make_object("", true, true, true, true, true, true, - true, true, true, false); + true, true, true, false, false); } else if (status_str == "adminq") { status = td_api::make_object("title", true, true, true, true, true, true, - true, true, true, false); + true, true, true, false, false); } else if (status_str == "minadmin") { status = td_api::make_object("", true, true, false, false, false, false, - false, false, false, false); + false, false, false, false, false); } else if (status_str == "unadmin") { status = td_api::make_object("", true, false, false, false, false, false, - false, false, false, false); + false, false, false, false, false); } else if (status_str == "rest") { status = td_api::make_object( true, static_cast(120 + std::time(nullptr)), From 8663c78702f67324540551a48c95ab3dbe7ab57d Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 24 Nov 2020 10:44:06 +0300 Subject: [PATCH 7/8] Add InputGroupCallId. --- CMakeLists.txt | 2 ++ td/telegram/InputGroupCallId.cpp | 25 +++++++++++++++ td/telegram/InputGroupCallId.h | 54 ++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 td/telegram/InputGroupCallId.cpp create mode 100644 td/telegram/InputGroupCallId.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a2434394c..9e5253e85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,6 +322,7 @@ set(TDLIB_SOURCE td/telegram/HashtagHints.cpp td/telegram/InlineQueriesManager.cpp td/telegram/InputDialogId.cpp + td/telegram/InputGroupCallId.cpp td/telegram/InputMessageText.cpp td/telegram/JsonValue.cpp td/telegram/LanguagePackManager.cpp @@ -494,6 +495,7 @@ set(TDLIB_SOURCE td/telegram/HashtagHints.h td/telegram/InlineQueriesManager.h td/telegram/InputDialogId.h + td/telegram/InputGroupCallId.h td/telegram/InputMessageText.h td/telegram/JsonValue.h td/telegram/LanguagePackManager.h diff --git a/td/telegram/InputGroupCallId.cpp b/td/telegram/InputGroupCallId.cpp new file mode 100644 index 000000000..b50b039d7 --- /dev/null +++ b/td/telegram/InputGroupCallId.cpp @@ -0,0 +1,25 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#include "td/telegram/InputGroupCallId.h" + +#include "td/utils/logging.h" + +namespace td { + +InputGroupCallId::InputGroupCallId(const tl_object_ptr &input_group_call) + : group_call_id(input_group_call->id_), access_hash(input_group_call->access_hash_) { +} + +tl_object_ptr InputGroupCallId::get_input_group_call() const { + return make_tl_object(group_call_id, access_hash); +} + +StringBuilder &operator<<(StringBuilder &string_builder, InputGroupCallId input_group_call_id) { + return string_builder << "input group call " << input_group_call_id.group_call_id; +} + +} // namespace td diff --git a/td/telegram/InputGroupCallId.h b/td/telegram/InputGroupCallId.h new file mode 100644 index 000000000..a1db1a5bb --- /dev/null +++ b/td/telegram/InputGroupCallId.h @@ -0,0 +1,54 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#pragma once + +#include "td/telegram/telegram_api.h" + +#include "td/utils/common.h" +#include "td/utils/StringBuilder.h" + +namespace td { + +class InputGroupCallId { + int64 group_call_id = 0; + int64 access_hash = 0; + + public: + InputGroupCallId() = default; + + explicit InputGroupCallId(const tl_object_ptr &input_group_call); + + bool operator==(const InputGroupCallId &other) const { + return group_call_id == other.group_call_id && access_hash == other.access_hash; + } + + bool operator!=(const InputGroupCallId &other) const { + return !(*this == other); + } + + bool is_valid() const { + return group_call_id != 0; + } + + tl_object_ptr get_input_group_call() const; + + template + void store(StorerT &storer) const { + storer.store_long(group_call_id); + storer.store_long(access_hash); + } + + template + void parse(ParserT &parser) { + group_call_id = parser.fetch_long(); + access_hash = parser.fetch_long(); + } + + friend StringBuilder &operator<<(StringBuilder &string_builder, InputGroupCallId input_group_call_id); +}; + +} // namespace td From ce4054c5d440dd0678559cfdc747660db0d13957 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 24 Nov 2020 14:33:16 +0300 Subject: [PATCH 8/8] Add messageGroupCall and messageInviteToGroupCall. --- td/generate/scheme/td_api.tl | 6 ++ td/generate/scheme/td_api.tlo | Bin 185420 -> 185548 bytes td/telegram/DialogAction.cpp | 2 + td/telegram/MessageContent.cpp | 135 ++++++++++++++++++++++++++++- td/telegram/MessageContentType.cpp | 12 +++ td/telegram/MessageContentType.h | 4 +- td/telegram/MessagesManager.cpp | 4 + 7 files changed, 161 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 70928b050..93f303939 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1627,6 +1627,12 @@ messageInvoice title:string description:string photo:photo currency:string total //@description A message with information about an ended call @is_video True, if the call was a video call @discard_reason Reason why the call was discarded @duration Call duration, in seconds messageCall is_video:Bool discard_reason:CallDiscardReason duration:int32 = MessageContent; +//@description A message with information about a group call +messageGroupCall = MessageContent; + +//@description A message with information about an invite to a group call +messageInviteToGroupCall = MessageContent; + //@description A newly created basic group @title Title of the basic group @member_user_ids User identifiers of members in the basic group messageBasicGroupChatCreate title:string member_user_ids:vector = MessageContent; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index d3b24a8f09e3762d8c236db89de7827710fd18da..98e28653a62d7cbd1f244115e9ba131dab25429d 100644 GIT binary patch delta 1246 zcmX@Jg8R%$?hQL6MZM+E6!H0{78fU`r#k27m89mCFz8I4$Rxh`iR2V7st{sSfUp+0G1^RTuw@c~ za6bSgI6-FKJSODBG`Z11d$P|xsP-ITn5GHBj3p5D93qS=5-{})Kv3k&ro&;|b`b0? z7ZIqA$rqLwKs3yO2~9sB0yD%y6rUj_Kv}3>QN|hwOGb=Q1@27d$rBH1PuBsueEJkI zn6D3rA$f##^1(~~(=Ehd-rph)b63q%sJnP1V4gFOU^GwxIUnR55V$JG6=PY{=)|21 zi42#_8>^r&5f|A?8ewhMBlQnz5lC-92L0&Mp#wy2rgJzqG(PF((J;R**VS)PdZM92Fow z2!Q;;v*4Gt1XQnQURh>IYDhi-Ggu+?a?vfa=@=l*6s_3s4qp!{mTT z(5MNKhdHf5p3wqg{T{d&$ZwN(OoIB`{ZcibEYwCf)9$&Uj@pD>#)-UwD#He!IPj$}ED@n~OVbGd9kx6{>6Uiy!j6Rzy4Hw^M z0jZjN^hVCorwpvaj`hr_n*AlOwd zB2XQZFDx;DXqW>Nntnh8W{8C-K0``?vQWLEj5QFJj2NQ|+?mXiCmz(Et^;)W^eJL6 zPahCN@(AnXgO~iLTZqGazeOD8u9~M%ckxKTJZB)mXrKaeKFB*Da8-^g#C5m>jc7VEUeK zjK0&KN--{nm@`2dX5t2E#s-Mk78ynz2p~cTDa;)p@bRe)0hes7@1kd^$^jvS1q~2TX#7%oUi> zGzCTri0w8CFxP^-HhIS+s7H?|z#{*R0;35;t%@Q(`%)BPI(iggp|S_ga_9wRkL}RZ zuAl@{>!Aco8%LC2y1pnec0g=wP=< static void store(const MessageContent *content, StorerT &storer) { @@ -978,6 +1008,24 @@ static void store(const MessageContent *content, StorerT &storer) { store(m->distance, storer); break; } + case MessageContentType::GroupCall: { + auto m = static_cast(content); + bool has_duration = m->duration >= 0; + BEGIN_STORE_FLAGS(); + STORE_FLAG(has_duration); + END_STORE_FLAGS(); + store(m->group_call_id, storer); + if (has_duration) { + store(m->duration, storer); + } + break; + } + case MessageContentType::InviteToGroupCall: { + auto m = static_cast(content); + store(m->group_call_id, storer); + store(m->user_id, storer); + break; + } default: UNREACHABLE(); } @@ -1352,6 +1400,26 @@ static void parse(unique_ptr &content, ParserT &parser) { content = std::move(m); break; } + case MessageContentType::GroupCall: { + auto m = make_unique(); + bool has_duration; + BEGIN_PARSE_FLAGS(); + PARSE_FLAG(has_duration); + END_PARSE_FLAGS(); + parse(m->group_call_id, parser); + if (has_duration) { + parse(m->duration, parser); + } + content = std::move(m); + break; + } + case MessageContentType::InviteToGroupCall: { + auto m = make_unique(); + parse(m->group_call_id, parser); + parse(m->user_id, parser); + content = std::move(m); + break; + } default: LOG(FATAL) << "Have unknown message content type " << static_cast(content_type); } @@ -2048,6 +2116,8 @@ bool can_have_input_media(const Td *td, const MessageContent *content) { case MessageContentType::PassportDataSent: case MessageContentType::PassportDataReceived: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: return false; case MessageContentType::Animation: case MessageContentType::Audio: @@ -2161,6 +2231,8 @@ SecretInputMedia get_secret_input_media(const MessageContent *content, Td *td, case MessageContentType::PassportDataSent: case MessageContentType::PassportDataReceived: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: break; default: UNREACHABLE(); @@ -2351,6 +2423,8 @@ static tl_object_ptr get_input_media_impl( case MessageContentType::PassportDataSent: case MessageContentType::PassportDataReceived: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: break; default: UNREACHABLE(); @@ -2474,6 +2548,8 @@ void delete_message_content_thumbnail(MessageContent *content, Td *td) { case MessageContentType::PassportDataReceived: case MessageContentType::Poll: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: break; default: UNREACHABLE(); @@ -2598,6 +2674,8 @@ static int32 get_message_content_media_index_mask(const MessageContent *content, case MessageContentType::Poll: case MessageContentType::Dice: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: return 0; default: UNREACHABLE(); @@ -3219,6 +3297,22 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo } break; } + case MessageContentType::GroupCall: { + auto old_ = static_cast(old_content); + auto new_ = static_cast(new_content); + if (old_->group_call_id != new_->group_call_id || old_->duration != new_->duration) { + need_update = true; + } + break; + } + case MessageContentType::InviteToGroupCall: { + auto old_ = static_cast(old_content); + auto new_ = static_cast(new_content); + if (old_->group_call_id != new_->group_call_id || old_->user_id != new_->user_id) { + need_update = true; + } + break; + } case MessageContentType::Unsupported: { auto old_ = static_cast(old_content); auto new_ = static_cast(new_content); @@ -3352,6 +3446,8 @@ bool merge_message_content_file_id(Td *td, MessageContent *message_content, File case MessageContentType::Poll: case MessageContentType::Dice: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: LOG(ERROR) << "Receive new file " << new_file_id << " in a sent message of the type " << content_type; break; default: @@ -4245,6 +4341,8 @@ unique_ptr dup_message_content(Td *td, DialogId dialog_id, const case MessageContentType::PassportDataSent: case MessageContentType::PassportDataReceived: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: return nullptr; default: UNREACHABLE(); @@ -4439,6 +4537,28 @@ unique_ptr get_action_message_content(Td *td, tl_object_ptr(traveler_id, watcher_id, distance); } + case telegram_api::messageActionGroupCall::ID: { + auto group_call = move_tl_object_as(action); + int32 duration = -1; + if ((group_call->flags_ & telegram_api::messageActionGroupCall::DURATION_MASK) != 0) { + duration = group_call->duration_; + if (duration < 0) { + LOG(ERROR) << "Receive invalid " << oneline(to_string(group_call)); + break; + } + } + return make_unique(InputGroupCallId(group_call->call_), duration); + } + case telegram_api::messageActionInviteToGroupCall::ID: { + auto invite_to_group_call = move_tl_object_as(action); + UserId user_id(invite_to_group_call->user_id_); + if (!user_id.is_valid()) { + LOG(ERROR) << "Receive messageActionInviteToGroupCall with invalid " << user_id << " in " << owner_dialog_id; + break; + } + + return make_unique(InputGroupCallId(invite_to_group_call->call_), user_id); + } default: UNREACHABLE(); } @@ -4648,6 +4768,10 @@ tl_object_ptr get_message_content_object(const MessageCo td->messages_manager_->get_message_sender_object(m->traveler_dialog_id), td->messages_manager_->get_message_sender_object(m->watcher_dialog_id), m->distance); } + case MessageContentType::GroupCall: + return make_tl_object(); + case MessageContentType::InviteToGroupCall: + return make_tl_object(); default: UNREACHABLE(); return nullptr; @@ -4960,6 +5084,8 @@ string get_message_content_search_text(const Td *td, const MessageContent *conte case MessageContentType::PassportDataReceived: case MessageContentType::Dice: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: return string(); default: UNREACHABLE(); @@ -5159,6 +5285,13 @@ void add_message_content_dependencies(Dependencies &dependencies, const MessageC add_message_sender_dependencies(dependencies, content->watcher_dialog_id); break; } + case MessageContentType::GroupCall: + break; + case MessageContentType::InviteToGroupCall: { + auto content = static_cast(message_content); + dependencies.user_ids.insert(content->user_id); + break; + } default: UNREACHABLE(); break; diff --git a/td/telegram/MessageContentType.cpp b/td/telegram/MessageContentType.cpp index 193e553eb..e375b939f 100644 --- a/td/telegram/MessageContentType.cpp +++ b/td/telegram/MessageContentType.cpp @@ -98,6 +98,10 @@ StringBuilder &operator<<(StringBuilder &string_builder, MessageContentType cont return string_builder << "Dice"; case MessageContentType::ProximityAlertTriggered: return string_builder << "ProximityAlertTriggered"; + case MessageContentType::GroupCall: + return string_builder << "GroupCall"; + case MessageContentType::InviteToGroupCall: + return string_builder << "InviteToGroupCall"; default: UNREACHABLE(); return string_builder; @@ -150,6 +154,8 @@ bool is_allowed_media_group_content(MessageContentType content_type) { case MessageContentType::Poll: case MessageContentType::Dice: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: return false; default: UNREACHABLE(); @@ -210,6 +216,8 @@ bool is_secret_message_content(int32 ttl, MessageContentType content_type) { case MessageContentType::Poll: case MessageContentType::Dice: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: return false; default: UNREACHABLE(); @@ -263,6 +271,8 @@ bool is_service_message_content(MessageContentType content_type) { case MessageContentType::PassportDataSent: case MessageContentType::PassportDataReceived: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: return true; default: UNREACHABLE(); @@ -316,6 +326,8 @@ bool can_have_message_content_caption(MessageContentType content_type) { case MessageContentType::Poll: case MessageContentType::Dice: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: return false; default: UNREACHABLE(); diff --git a/td/telegram/MessageContentType.h b/td/telegram/MessageContentType.h index d8dc3c507..57aa4688a 100644 --- a/td/telegram/MessageContentType.h +++ b/td/telegram/MessageContentType.h @@ -57,7 +57,9 @@ enum class MessageContentType : int32 { PassportDataReceived, Poll, Dice, - ProximityAlertTriggered + ProximityAlertTriggered, + GroupCall, + InviteToGroupCall }; StringBuilder &operator<<(StringBuilder &string_builder, MessageContentType content_type); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index c156ee2af..e5503e4f8 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -22561,6 +22561,8 @@ Status MessagesManager::can_send_message_content(DialogId dialog_id, const Messa case MessageContentType::PassportDataSent: case MessageContentType::PassportDataReceived: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: UNREACHABLE(); } return Status::OK(); @@ -24122,6 +24124,8 @@ bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, boo case MessageContentType::PassportDataSent: case MessageContentType::PassportDataReceived: case MessageContentType::ProximityAlertTriggered: + case MessageContentType::GroupCall: + case MessageContentType::InviteToGroupCall: return false; default: UNREACHABLE();