Add location and can_set_location to supergroupFullInfo.

GitOrigin-RevId: 76550d71096e32cfd282f2e42a2a70176b2f5421
This commit is contained in:
levlam 2019-10-13 21:41:09 +03:00
parent af527d0c9e
commit 41662e7048
4 changed files with 34 additions and 12 deletions

View File

@ -456,13 +456,15 @@ supergroup id:int32 username:string date:int32 status:ChatMemberStatus member_co
//@can_get_members True, if members of the chat can be retrieved
//@can_set_username True, if the chat can have username
//@can_set_sticker_set True, if the supergroup sticker set can be changed
//@can_set_location True, if the supergroup location can be changed
//@can_view_statistics True, if the channel statistics is available through getChatStatisticsUrl
//@is_all_history_available True, if new chat members will have access to old messages. In public or discussion groups and both public and private channels, old messages are always available, so this option affects only private supergroups without a linked chat. The value of this field is only available for chat administrators
//@sticker_set_id Identifier of the supergroup sticker set; 0 if none
//@location Location of the supergroup; may be null
//@invite_link Invite link for this chat
//@upgraded_from_basic_group_id Identifier of the basic group from which supergroup was upgraded; 0 if none
//@upgraded_from_max_message_id Identifier of the last message in the basic group from which supergroup was upgraded; 0 if none
supergroupFullInfo description:string member_count:int32 administrator_count:int32 restricted_count:int32 banned_count:int32 linked_chat_id:int53 can_get_members:Bool can_set_username:Bool can_set_sticker_set:Bool can_view_statistics:Bool is_all_history_available:Bool sticker_set_id:int64 invite_link:string upgraded_from_basic_group_id:int32 upgraded_from_max_message_id:int53 = SupergroupFullInfo;
supergroupFullInfo description:string member_count:int32 administrator_count:int32 restricted_count:int32 banned_count:int32 linked_chat_id:int53 can_get_members:Bool can_set_username:Bool can_set_sticker_set:Bool can_set_location:Bool can_view_statistics:Bool is_all_history_available:Bool sticker_set_id:int64 location:chatLocation invite_link:string upgraded_from_basic_group_id:int32 upgraded_from_max_message_id:int53 = SupergroupFullInfo;
//@class SecretChatState @description Describes the current secret chat state

Binary file not shown.

View File

@ -3063,6 +3063,7 @@ void ContactsManager::ChannelFull::store(StorerT &storer) const {
bool has_linked_channel_id = linked_channel_id.is_valid();
bool has_migrated_from_max_message_id = migrated_from_max_message_id.is_valid();
bool has_migrated_from_chat_id = migrated_from_chat_id.is_valid();
bool has_location = !location.empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_description);
STORE_FLAG(has_administrator_count);
@ -3078,6 +3079,8 @@ void ContactsManager::ChannelFull::store(StorerT &storer) const {
STORE_FLAG(can_set_sticker_set);
STORE_FLAG(can_view_statistics);
STORE_FLAG(is_all_history_available);
STORE_FLAG(can_set_location);
STORE_FLAG(has_location);
END_STORE_FLAGS();
if (has_description) {
store(description, storer);
@ -3101,6 +3104,9 @@ void ContactsManager::ChannelFull::store(StorerT &storer) const {
if (has_linked_channel_id) {
store(linked_channel_id, storer);
}
if (has_location) {
store(location, storer);
}
if (has_migrated_from_max_message_id) {
store(migrated_from_max_message_id, storer);
}
@ -3122,6 +3128,7 @@ void ContactsManager::ChannelFull::parse(ParserT &parser) {
bool has_linked_channel_id;
bool has_migrated_from_max_message_id;
bool has_migrated_from_chat_id;
bool has_location;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_description);
PARSE_FLAG(has_administrator_count);
@ -3137,6 +3144,8 @@ void ContactsManager::ChannelFull::parse(ParserT &parser) {
PARSE_FLAG(can_set_sticker_set);
PARSE_FLAG(can_view_statistics);
PARSE_FLAG(is_all_history_available);
PARSE_FLAG(can_set_location);
PARSE_FLAG(has_location);
END_PARSE_FLAGS();
if (has_description) {
parse(description, parser);
@ -3160,6 +3169,9 @@ void ContactsManager::ChannelFull::parse(ParserT &parser) {
if (has_linked_channel_id) {
parse(linked_channel_id, parser);
}
if (has_location) {
parse(location, parser);
}
if (has_migrated_from_max_message_id) {
parse(migrated_from_max_message_id, parser);
}
@ -7678,13 +7690,15 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
(channel_full->flags_ & CHANNEL_FULL_FLAG_HAS_BANNED_COUNT) != 0 ? channel_full->kicked_count_ : 0;
auto can_get_participants = (channel_full->flags_ & CHANNEL_FULL_FLAG_CAN_GET_PARTICIPANTS) != 0;
auto can_set_username = (channel_full->flags_ & CHANNEL_FULL_FLAG_CAN_SET_USERNAME) != 0;
auto can_set_sticker_set = (channel_full->flags_ & CHANNEL_FULL_FLAG_CAN_SET_STICKERS) != 0;
auto can_set_sticker_set = (channel_full->flags_ & CHANNEL_FULL_FLAG_CAN_SET_STICKER_SET) != 0;
auto can_set_location = (channel_full->flags_ & CHANNEL_FULL_FLAG_CAN_SET_LOCATION) != 0;
auto can_view_statistics = (channel_full->flags_ & CHANNEL_FULL_FLAG_CAN_VIEW_STATISTICS) != 0;
auto is_all_history_available = (channel_full->flags_ & CHANNEL_FULL_FLAG_IS_ALL_HISTORY_HIDDEN) == 0;
StickerSetId sticker_set_id;
if (channel_full->stickerset_ != nullptr) {
sticker_set_id = td_->stickers_manager_->on_get_sticker_set(std::move(channel_full->stickerset_), true);
}
auto location = DialogLocation(std::move(channel_full->location_));
ChannelFull *channel = &channels_full_[channel_id];
channel->expires_at = Time::now() + CHANNEL_FULL_EXPIRE_TIME;
@ -7692,8 +7706,8 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
channel->administrator_count != administrator_count || channel->restricted_count != restricted_count ||
channel->banned_count != banned_count || channel->can_get_participants != can_get_participants ||
channel->can_set_username != can_set_username || channel->can_set_sticker_set != can_set_sticker_set ||
channel->can_view_statistics != can_view_statistics || channel->sticker_set_id != sticker_set_id ||
channel->is_all_history_available != is_all_history_available) {
channel->can_set_location != can_set_location || channel->can_view_statistics != can_view_statistics ||
channel->sticker_set_id != sticker_set_id || channel->location != location || channel->is_all_history_available != is_all_history_available) {
channel->description = std::move(channel_full->about_);
channel->participant_count = participant_count;
channel->administrator_count = administrator_count;
@ -7702,9 +7716,11 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
channel->can_get_participants = can_get_participants;
channel->can_set_username = can_set_username;
channel->can_set_sticker_set = can_set_sticker_set;
channel->can_set_location = can_set_location;
channel->can_view_statistics = can_view_statistics;
channel->sticker_set_id = sticker_set_id;
channel->is_all_history_available = is_all_history_available;
channel->sticker_set_id = sticker_set_id;
channel->location = std::move(location);
channel->is_changed = true;
@ -7760,9 +7776,7 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
auto linked_channel = get_channel_force(linked_channel_id);
if (linked_channel == nullptr || c->is_megagroup == linked_channel->is_megagroup ||
channel_id == linked_channel_id) {
if (linked_channel_id.is_valid()) { // TODO remove after CHANNEL_FULL_FLAG_HAS_LINKED_CHANNEL_ID fix
LOG(ERROR) << "Failed to add a link between " << channel_id << " and " << linked_channel_id;
}
LOG(ERROR) << "Failed to add a link between " << channel_id << " and " << linked_channel_id;
linked_channel_id = ChannelId();
}
}
@ -11548,8 +11562,8 @@ tl_object_ptr<td_api::supergroupFullInfo> ContactsManager::get_supergroup_full_i
channel_full->description, channel_full->participant_count, channel_full->administrator_count,
channel_full->restricted_count, channel_full->banned_count, DialogId(channel_full->linked_channel_id).get(),
channel_full->can_get_participants, channel_full->can_set_username, channel_full->can_set_sticker_set,
channel_full->can_view_statistics, channel_full->is_all_history_available, channel_full->sticker_set_id.get(),
channel_full->invite_link,
channel_full->can_set_location, channel_full->can_view_statistics, channel_full->is_all_history_available,
channel_full->sticker_set_id.get(), channel_full->location.get_chat_location_object(), channel_full->invite_link,
get_basic_group_id_object(channel_full->migrated_from_chat_id, "get_supergroup_full_info_object"),
channel_full->migrated_from_max_message_id.get());
}

View File

@ -14,6 +14,7 @@
#include "td/telegram/ChatId.h"
#include "td/telegram/Contact.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogLocation.h"
#include "td/telegram/DialogParticipant.h"
#include "td/telegram/files/FileId.h"
#include "td/telegram/files/FileSourceId.h"
@ -715,12 +716,15 @@ class ContactsManager : public Actor {
ChannelId linked_channel_id;
DialogLocation location;
MessageId migrated_from_max_message_id;
ChatId migrated_from_chat_id;
bool can_get_participants = false;
bool can_set_username = false;
bool can_set_sticker_set = false;
bool can_set_location = false;
bool can_view_statistics = false;
bool is_all_history_available = true;
@ -856,14 +860,16 @@ class ContactsManager : public Actor {
static constexpr int32 CHANNEL_FULL_FLAG_MIGRATED_FROM = 1 << 4;
static constexpr int32 CHANNEL_FULL_FLAG_HAS_PINNED_MESSAGE = 1 << 5;
static constexpr int32 CHANNEL_FULL_FLAG_CAN_SET_USERNAME = 1 << 6;
static constexpr int32 CHANNEL_FULL_FLAG_CAN_SET_STICKERS = 1 << 7;
static constexpr int32 CHANNEL_FULL_FLAG_CAN_SET_STICKER_SET = 1 << 7;
static constexpr int32 CHANNEL_FULL_FLAG_HAS_STICKER_SET = 1 << 8;
static constexpr int32 CHANNEL_FULL_FLAG_HAS_AVAILABLE_MIN_MESSAGE_ID = 1 << 9;
static constexpr int32 CHANNEL_FULL_FLAG_IS_ALL_HISTORY_HIDDEN = 1 << 10;
static constexpr int32 CHANNEL_FULL_FLAG_HAS_FOLDER_ID = 1 << 11;
static constexpr int32 CHANNEL_FULL_FLAG_CAN_VIEW_STATISTICS = 1 << 12;
static constexpr int32 CHANNEL_FULL_FLAG_HAS_ONLINE_MEMBER_COUNT = 1 << 13;
static constexpr int32 CHANNEL_FULL_FLAG_HAS_LINKED_CHANNEL_ID = 1 << 13;
static constexpr int32 CHANNEL_FULL_FLAG_HAS_LINKED_CHANNEL_ID = 1 << 14;
static constexpr int32 CHANNEL_FULL_FLAG_HAS_LOCATION = 1 << 15;
static constexpr int32 CHANNEL_FULL_FLAG_CAN_SET_LOCATION = 1 << 16;
static constexpr int32 CHAT_INVITE_FLAG_IS_CHANNEL = 1 << 0;
static constexpr int32 CHAT_INVITE_FLAG_IS_BROADCAST = 1 << 1;