diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 6414081b3..145e2e97b 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -938,6 +938,9 @@ chatActionBarReportSpam can_unarchive:Bool = ChatActionBar; //@description The chat is a location-based supergroup, which can be reported as having unrelated location using the method reportChat with the reason chatReportReasonUnrelatedLocation chatActionBarReportUnrelatedLocation = ChatActionBar; +//@description The chat is a recently created group chat, to which new members can be invited +chatActionBarInviteMembers = ChatActionBar; + //@description The chat is a private or secret chat, which can be reported using the method reportChat, or the other user can be blocked using the method blockUser, or the other user can be added to the contact list using the method addContact //@can_unarchive If true, the chat was automatically archived and can be moved back to the main chat list using addChatToList simultaneously with setting chat notification settings to default using setChatNotificationSettings //@distance If non-negative, the current user was found by the peer through searchChatsNearby and this is the distance between the users diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 8477a16f2..37f89fc40 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 5d285e3e7..813482085 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -5349,6 +5349,7 @@ void MessagesManager::Dialog::store(StorerT &storer) const { STORE_FLAG(has_active_group_call); STORE_FLAG(is_group_call_empty); STORE_FLAG(has_active_group_call_id); + STORE_FLAG(can_invite_members); END_STORE_FLAGS(); } @@ -5524,6 +5525,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) { PARSE_FLAG(has_active_group_call); PARSE_FLAG(is_group_call_empty); PARSE_FLAG(has_active_group_call_id); + PARSE_FLAG(can_invite_members); END_PARSE_FLAGS(); } else { is_folder_id_inited = false; @@ -5542,6 +5544,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) { is_is_blocked_inited = false; has_active_group_call = false; is_group_call_empty = false; + can_invite_members = false; } parse(last_new_message_id, parser); @@ -7939,7 +7942,7 @@ void MessagesManager::hide_dialog_action_bar(Dialog *d) { return; } if (!d->can_report_spam && !d->can_add_contact && !d->can_block_user && !d->can_share_phone_number && - !d->can_report_location && !d->can_unarchive && d->distance < 0) { + !d->can_report_location && !d->can_unarchive && d->distance < 0 && !d->can_invite_members) { return; } @@ -7950,6 +7953,7 @@ void MessagesManager::hide_dialog_action_bar(Dialog *d) { d->can_report_location = false; d->can_unarchive = false; d->distance = -1; + d->can_invite_members = false; send_update_chat_action_bar(d); } @@ -7979,7 +7983,7 @@ void MessagesManager::remove_dialog_action_bar(DialogId dialog_id, Promise } if (!d->can_report_spam && !d->can_add_contact && !d->can_block_user && !d->can_share_phone_number && - !d->can_report_location && !d->can_unarchive && d->distance < 0) { + !d->can_report_location && !d->can_unarchive && d->distance < 0 && !d->can_invite_members) { return promise.set_value(Unit()); } @@ -8213,9 +8217,11 @@ void MessagesManager::on_get_peer_settings(DialogId dialog_id, auto can_unarchive = (peer_settings->flags_ & telegram_api::peerSettings::AUTOARCHIVED_MASK) != 0; auto distance = (peer_settings->flags_ & telegram_api::peerSettings::GEO_DISTANCE_MASK) != 0 ? peer_settings->geo_distance_ : -1; + auto can_invite_members = (peer_settings->flags_ & telegram_api::peerSettings::INVITE_MEMBERS_MASK) != 0; if (d->can_report_spam == can_report_spam && d->can_add_contact == can_add_contact && d->can_block_user == can_block_user && d->can_share_phone_number == can_share_phone_number && - d->can_report_location == can_report_location && d->can_unarchive == can_unarchive && d->distance == distance) { + d->can_report_location == can_report_location && d->can_unarchive == can_unarchive && d->distance == distance && + d->can_invite_members == can_invite_members) { if (!d->know_action_bar || !d->know_can_report_spam) { d->know_can_report_spam = true; d->know_action_bar = true; @@ -8233,6 +8239,7 @@ void MessagesManager::on_get_peer_settings(DialogId dialog_id, d->can_report_location = can_report_location; d->can_unarchive = can_unarchive; d->distance = distance < 0 ? -1 : distance; + d->can_invite_members = can_invite_members; fix_dialog_action_bar(d); @@ -8255,10 +8262,28 @@ void MessagesManager::fix_dialog_action_bar(Dialog *d) { if (dialog_type != DialogType::Channel) { LOG(ERROR) << "Receive can_report_location in " << d->dialog_id; d->can_report_location = false; + } else if (d->can_report_spam || d->can_add_contact || d->can_block_user || d->can_share_phone_number || + d->can_unarchive || d->can_invite_members) { + LOG(ERROR) << "Receive action bar " << d->can_report_spam << "/" << d->can_add_contact << "/" << d->can_block_user + << "/" << d->can_share_phone_number << "/" << d->can_report_location << "/" << d->can_unarchive << "/" + << d->can_invite_members; + d->can_report_spam = false; + d->can_add_contact = false; + d->can_block_user = false; + d->can_share_phone_number = false; + d->can_unarchive = false; + d->can_invite_members = false; + CHECK(d->distance == -1); + } + } + if (d->can_invite_members) { + if (dialog_type != DialogType::Chat && (dialog_type != DialogType::Channel || is_broadcast_channel(d->dialog_id))) { + LOG(ERROR) << "Receive can_invite_members in " << d->dialog_id; + d->can_invite_members = false; } else if (d->can_report_spam || d->can_add_contact || d->can_block_user || d->can_share_phone_number || d->can_unarchive) { LOG(ERROR) << "Receive action bar " << d->can_report_spam << "/" << d->can_add_contact << "/" << d->can_block_user - << "/" << d->can_share_phone_number << "/" << d->can_report_location << "/" << d->can_unarchive; + << "/" << d->can_share_phone_number << "/" << d->can_unarchive << "/" << d->can_invite_members; d->can_report_spam = false; d->can_add_contact = false; d->can_block_user = false; @@ -8290,6 +8315,7 @@ void MessagesManager::fix_dialog_action_bar(Dialog *d) { } if (d->can_share_phone_number) { CHECK(!d->can_report_location); + CHECK(!d->can_invite_members); if (dialog_type != DialogType::User) { LOG(ERROR) << "Receive can_share_phone_number in " << d->dialog_id; d->can_share_phone_number = false; @@ -8304,6 +8330,7 @@ void MessagesManager::fix_dialog_action_bar(Dialog *d) { } if (d->can_block_user) { CHECK(!d->can_report_location); + CHECK(!d->can_invite_members); CHECK(!d->can_share_phone_number); if (dialog_type != DialogType::User) { LOG(ERROR) << "Receive can_block_user in " << d->dialog_id; @@ -8317,6 +8344,7 @@ void MessagesManager::fix_dialog_action_bar(Dialog *d) { } if (d->can_add_contact) { CHECK(!d->can_report_location); + CHECK(!d->can_invite_members); CHECK(!d->can_share_phone_number); if (dialog_type != DialogType::User) { LOG(ERROR) << "Receive can_add_contact in " << d->dialog_id; @@ -19546,9 +19574,14 @@ td_api::object_ptr MessagesManager::get_chat_action_bar_o if (d->can_report_location) { CHECK(d->dialog_id.get_type() == DialogType::Channel); - CHECK(!d->can_share_phone_number && !d->can_block_user && !d->can_add_contact && !d->can_report_spam); + CHECK(!d->can_share_phone_number && !d->can_block_user && !d->can_add_contact && !d->can_report_spam && + !d->can_invite_members); return td_api::make_object(); } + if (d->can_invite_members) { + CHECK(!d->can_share_phone_number && !d->can_block_user && !d->can_add_contact && !d->can_report_spam); + return td_api::make_object(); + } if (d->can_share_phone_number) { CHECK(d->dialog_id.get_type() == DialogType::User); CHECK(!d->can_block_user && !d->can_add_contact && !d->can_report_spam); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 0758bf38b..f61fcb15c 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1216,6 +1216,7 @@ class MessagesManager : public Actor { bool can_report_location = false; bool can_unarchive = false; bool hide_distance = false; + bool can_invite_members = false; bool is_opened = false;