Add support for location-based supergroups in getCreatedPublicChats.
GitOrigin-RevId: b328d62a998dc2e2b83d9721e001f9feee129d4e
This commit is contained in:
parent
918f6a0cfd
commit
892a091998
@ -611,6 +611,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/PollManager.h
|
td/telegram/PollManager.h
|
||||||
td/telegram/PrivacyManager.h
|
td/telegram/PrivacyManager.h
|
||||||
td/telegram/PtsManager.h
|
td/telegram/PtsManager.h
|
||||||
|
td/telegram/PublicDialogType.h
|
||||||
td/telegram/QueryCombiner.h
|
td/telegram/QueryCombiner.h
|
||||||
td/telegram/ReplyMarkup.h
|
td/telegram/ReplyMarkup.h
|
||||||
td/telegram/RequestActor.h
|
td/telegram/RequestActor.h
|
||||||
|
@ -274,6 +274,7 @@ function split_file($file, $chunks, $undo) {
|
|||||||
'get_erase_logevent_promise|parse_time|store_time' => 'logevent/LogEventHelper',
|
'get_erase_logevent_promise|parse_time|store_time' => 'logevent/LogEventHelper',
|
||||||
'messages_manager[_(-][^.]|MessagesManager' => 'MessagesManager',
|
'messages_manager[_(-][^.]|MessagesManager' => 'MessagesManager',
|
||||||
'notification_manager[_(-][^.]|NotificationManager|notifications[)]' => 'NotificationManager',
|
'notification_manager[_(-][^.]|NotificationManager|notifications[)]' => 'NotificationManager',
|
||||||
|
'PublicDialogType|get_public_dialog_type' => 'PublicDialogType',
|
||||||
'SecretChatActor' => 'SecretChatActor',
|
'SecretChatActor' => 'SecretChatActor',
|
||||||
'secret_chats_manager[_(-][^.]|SecretChatsManager' => 'SecretChatsManager',
|
'secret_chats_manager[_(-][^.]|SecretChatsManager' => 'SecretChatsManager',
|
||||||
'stickers_manager[_(-][^.]|StickersManager' => 'StickersManager',
|
'stickers_manager[_(-][^.]|StickersManager' => 'StickersManager',
|
||||||
|
@ -667,6 +667,15 @@ chatInviteLink invite_link:string = ChatInviteLink;
|
|||||||
chatInviteLinkInfo chat_id:int53 type:ChatType title:string photo:chatPhoto member_count:int32 member_user_ids:vector<int32> is_public:Bool = ChatInviteLinkInfo;
|
chatInviteLinkInfo chat_id:int53 type:ChatType title:string photo:chatPhoto member_count:int32 member_user_ids:vector<int32> is_public:Bool = ChatInviteLinkInfo;
|
||||||
|
|
||||||
|
|
||||||
|
//@class PublicChatType @description Describes a type of public chats
|
||||||
|
|
||||||
|
//@description The chat is public, because it has username
|
||||||
|
publicChatTypeHasUsername = PublicChatType;
|
||||||
|
|
||||||
|
//@description The chat is public, because it is a location-based supergroup
|
||||||
|
publicChatTypeIsLocationBased = PublicChatType;
|
||||||
|
|
||||||
|
|
||||||
//@class ChatActionBar @description Describes actions which should be possible to do through a chat action bar
|
//@class ChatActionBar @description Describes actions which should be possible to do through a chat action bar
|
||||||
|
|
||||||
//@description The chat can be reported as spam using the method reportChat with the reason chatReportReasonSpam
|
//@description The chat can be reported as spam using the method reportChat with the reason chatReportReasonSpam
|
||||||
@ -3115,8 +3124,8 @@ clearRecentlyFoundChats = Ok;
|
|||||||
//@description Checks whether a username can be set for a chat @chat_id Chat identifier; should be identifier of a supergroup chat, or a channel chat, or a private chat with self, or zero if chat is being created @username Username to be checked
|
//@description Checks whether a username can be set for a chat @chat_id Chat identifier; should be identifier of a supergroup chat, or a channel chat, or a private chat with self, or zero if chat is being created @username Username to be checked
|
||||||
checkChatUsername chat_id:int53 username:string = CheckChatUsernameResult;
|
checkChatUsername chat_id:int53 username:string = CheckChatUsernameResult;
|
||||||
|
|
||||||
//@description Returns a list of public chats with username created by the user
|
//@description Returns a list of public chats of the specified type, owned by the user @type Type of the public chats to return
|
||||||
getCreatedPublicChats = Chats;
|
getCreatedPublicChats type:PublicChatType = Chats;
|
||||||
|
|
||||||
//@description Returns a list of basic group and supergroup chats, which can be used as a discussion group for a channel. Basic group chats need to be first upgraded to supergroups before they can be set as a discussion group
|
//@description Returns a list of basic group and supergroup chats, which can be used as a discussion group for a channel. Basic group chats need to be first upgraded to supergroups before they can be set as a discussion group
|
||||||
getSuitableDiscussionChats = Chats;
|
getSuitableDiscussionChats = Chats;
|
||||||
|
Binary file not shown.
@ -1969,13 +1969,20 @@ class MigrateChatQuery : public Td::ResultHandler {
|
|||||||
|
|
||||||
class GetCreatedPublicChannelsQuery : public Td::ResultHandler {
|
class GetCreatedPublicChannelsQuery : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<Unit> promise_;
|
||||||
|
PublicDialogType type_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GetCreatedPublicChannelsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit GetCreatedPublicChannelsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send() {
|
void send(PublicDialogType type) {
|
||||||
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_getAdminedPublicChannels())));
|
type_ = type;
|
||||||
|
int32 flags = 0;
|
||||||
|
if (type_ == PublicDialogType::IsLocationBased) {
|
||||||
|
flags |= telegram_api::channels_getAdminedPublicChannels::BY_LOCATION_MASK;
|
||||||
|
}
|
||||||
|
send_query(G()->net_query_creator().create(
|
||||||
|
create_storer(telegram_api::channels_getAdminedPublicChannels(flags, false /*ignored*/, false /*ignored*/))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_result(uint64 id, BufferSlice packet) override {
|
void on_result(uint64 id, BufferSlice packet) override {
|
||||||
@ -1990,13 +1997,13 @@ class GetCreatedPublicChannelsQuery : public Td::ResultHandler {
|
|||||||
switch (constructor_id) {
|
switch (constructor_id) {
|
||||||
case telegram_api::messages_chats::ID: {
|
case telegram_api::messages_chats::ID: {
|
||||||
auto chats = move_tl_object_as<telegram_api::messages_chats>(chats_ptr);
|
auto chats = move_tl_object_as<telegram_api::messages_chats>(chats_ptr);
|
||||||
td->contacts_manager_->on_get_created_public_channels(std::move(chats->chats_));
|
td->contacts_manager_->on_get_created_public_channels(type_, std::move(chats->chats_));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case telegram_api::messages_chatsSlice::ID: {
|
case telegram_api::messages_chatsSlice::ID: {
|
||||||
auto chats = move_tl_object_as<telegram_api::messages_chatsSlice>(chats_ptr);
|
auto chats = move_tl_object_as<telegram_api::messages_chatsSlice>(chats_ptr);
|
||||||
LOG(ERROR) << "Receive chatsSlice in result of GetCreatedPublicChannelsQuery";
|
LOG(ERROR) << "Receive chatsSlice in result of GetCreatedPublicChannelsQuery";
|
||||||
td->contacts_manager_->on_get_created_public_channels(std::move(chats->chats_));
|
td->contacts_manager_->on_get_created_public_channels(type_, std::move(chats->chats_));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -5780,23 +5787,26 @@ vector<DialogId> ContactsManager::get_dialog_ids(vector<tl_object_ptr<telegram_a
|
|||||||
return dialog_ids;
|
return dialog_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<DialogId> ContactsManager::get_created_public_dialogs(Promise<Unit> &&promise) {
|
vector<DialogId> ContactsManager::get_created_public_dialogs(PublicDialogType type, Promise<Unit> &&promise) {
|
||||||
if (created_public_channels_inited_) {
|
int32 index = static_cast<int32>(type);
|
||||||
|
if (created_public_channels_inited_[index]) {
|
||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
return transform(created_public_channels_, [&](ChannelId channel_id) {
|
return transform(created_public_channels_[index], [&](ChannelId channel_id) {
|
||||||
DialogId dialog_id(channel_id);
|
DialogId dialog_id(channel_id);
|
||||||
td_->messages_manager_->force_create_dialog(dialog_id, "get_created_public_dialogs");
|
td_->messages_manager_->force_create_dialog(dialog_id, "get_created_public_dialogs");
|
||||||
return dialog_id;
|
return dialog_id;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->create_handler<GetCreatedPublicChannelsQuery>(std::move(promise))->send();
|
td_->create_handler<GetCreatedPublicChannelsQuery>(std::move(promise))->send(type);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::on_get_created_public_channels(vector<tl_object_ptr<telegram_api::Chat>> &&chats) {
|
void ContactsManager::on_get_created_public_channels(PublicDialogType type,
|
||||||
created_public_channels_inited_ = true;
|
vector<tl_object_ptr<telegram_api::Chat>> &&chats) {
|
||||||
created_public_channels_ = get_channel_ids(std::move(chats), "on_get_created_public_channels");
|
int32 index = static_cast<int32>(type);
|
||||||
|
created_public_channels_[index] = get_channel_ids(std::move(chats), "on_get_created_public_channels");
|
||||||
|
created_public_channels_inited_[index] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<DialogId> ContactsManager::get_dialogs_for_discussion(Promise<Unit> &&promise) {
|
vector<DialogId> ContactsManager::get_dialogs_for_discussion(Promise<Unit> &&promise) {
|
||||||
@ -7736,12 +7746,12 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c->is_username_changed) {
|
if (c->is_username_changed) {
|
||||||
if (c->status.is_creator() && created_public_channels_inited_) {
|
if (c->status.is_creator() && created_public_channels_inited_[0]) {
|
||||||
if (c->username.empty()) {
|
if (c->username.empty()) {
|
||||||
td::remove(created_public_channels_, channel_id);
|
td::remove(created_public_channels_[0], channel_id);
|
||||||
} else {
|
} else {
|
||||||
if (!td::contains(created_public_channels_, channel_id)) {
|
if (!td::contains(created_public_channels_[0], channel_id)) {
|
||||||
created_public_channels_.push_back(channel_id);
|
created_public_channels_[0].push_back(channel_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10183,14 +10193,19 @@ void ContactsManager::on_update_channel_title(Channel *c, ChannelId channel_id,
|
|||||||
void ContactsManager::on_update_channel_status(Channel *c, ChannelId channel_id, DialogParticipantStatus &&status) {
|
void ContactsManager::on_update_channel_status(Channel *c, ChannelId channel_id, DialogParticipantStatus &&status) {
|
||||||
if (c->status != status) {
|
if (c->status != status) {
|
||||||
LOG(INFO) << "Update " << channel_id << " status from " << c->status << " to " << status;
|
LOG(INFO) << "Update " << channel_id << " status from " << c->status << " to " << status;
|
||||||
bool reget_channel_full = c->status.is_creator() != status.is_creator();
|
bool is_ownership_transferred = c->status.is_creator() != status.is_creator();
|
||||||
bool drop_invite_link =
|
bool drop_invite_link =
|
||||||
c->status.is_administrator() != status.is_administrator() || c->status.is_member() != status.is_member();
|
c->status.is_administrator() != status.is_administrator() || c->status.is_member() != status.is_member();
|
||||||
c->status = status;
|
c->status = status;
|
||||||
c->is_status_changed = true;
|
c->is_status_changed = true;
|
||||||
c->is_changed = true;
|
c->is_changed = true;
|
||||||
invalidate_channel_full(channel_id, drop_invite_link);
|
invalidate_channel_full(channel_id, drop_invite_link);
|
||||||
if (reget_channel_full) {
|
if (is_ownership_transferred) {
|
||||||
|
for (size_t i = 0; i < 2; i++) {
|
||||||
|
created_public_channels_inited_[i] = false;
|
||||||
|
created_public_channels_[i].clear();
|
||||||
|
}
|
||||||
|
|
||||||
auto input_channel = get_input_channel(channel_id);
|
auto input_channel = get_input_channel(channel_id);
|
||||||
if (input_channel != nullptr) {
|
if (input_channel != nullptr) {
|
||||||
send_get_channel_full_query(channel_id, std::move(input_channel), Auto(), "update channel creator");
|
send_get_channel_full_query(channel_id, std::move(input_channel), Auto(), "update channel creator");
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "td/telegram/Location.h"
|
#include "td/telegram/Location.h"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
#include "td/telegram/Photo.h"
|
#include "td/telegram/Photo.h"
|
||||||
|
#include "td/telegram/PublicDialogType.h"
|
||||||
#include "td/telegram/QueryCombiner.h"
|
#include "td/telegram/QueryCombiner.h"
|
||||||
#include "td/telegram/SecretChatId.h"
|
#include "td/telegram/SecretChatId.h"
|
||||||
#include "td/telegram/StickerSetId.h"
|
#include "td/telegram/StickerSetId.h"
|
||||||
@ -218,7 +219,7 @@ class ContactsManager : public Actor {
|
|||||||
|
|
||||||
void invalidate_invite_link_info(const string &invite_link);
|
void invalidate_invite_link_info(const string &invite_link);
|
||||||
|
|
||||||
void on_get_created_public_channels(vector<tl_object_ptr<telegram_api::Chat>> &&chats);
|
void on_get_created_public_channels(PublicDialogType type, vector<tl_object_ptr<telegram_api::Chat>> &&chats);
|
||||||
|
|
||||||
void on_get_dialogs_for_discussion(vector<tl_object_ptr<telegram_api::Chat>> &&chats);
|
void on_get_dialogs_for_discussion(vector<tl_object_ptr<telegram_api::Chat>> &&chats);
|
||||||
|
|
||||||
@ -363,7 +364,7 @@ class ContactsManager : public Actor {
|
|||||||
|
|
||||||
ChannelId migrate_chat_to_megagroup(ChatId chat_id, Promise<Unit> &promise);
|
ChannelId migrate_chat_to_megagroup(ChatId chat_id, Promise<Unit> &promise);
|
||||||
|
|
||||||
vector<DialogId> get_created_public_dialogs(Promise<Unit> &&promise);
|
vector<DialogId> get_created_public_dialogs(PublicDialogType type, Promise<Unit> &&promise);
|
||||||
|
|
||||||
vector<DialogId> get_dialogs_for_discussion(Promise<Unit> &&promise);
|
vector<DialogId> get_dialogs_for_discussion(Promise<Unit> &&promise);
|
||||||
|
|
||||||
@ -1306,8 +1307,8 @@ class ContactsManager : public Actor {
|
|||||||
std::unordered_map<ChannelId, string, ChannelIdHash> channel_invite_links_; // in-memory cache for invite links
|
std::unordered_map<ChannelId, string, ChannelIdHash> channel_invite_links_; // in-memory cache for invite links
|
||||||
std::unordered_map<string, unique_ptr<InviteLinkInfo>> invite_link_infos_;
|
std::unordered_map<string, unique_ptr<InviteLinkInfo>> invite_link_infos_;
|
||||||
|
|
||||||
bool created_public_channels_inited_ = false;
|
bool created_public_channels_inited_[2] = {false, false};
|
||||||
vector<ChannelId> created_public_channels_;
|
vector<ChannelId> created_public_channels_[2];
|
||||||
|
|
||||||
bool dialogs_for_discussion_inited_ = false;
|
bool dialogs_for_discussion_inited_ = false;
|
||||||
vector<DialogId> dialogs_for_discussion_;
|
vector<DialogId> dialogs_for_discussion_;
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
#include "td/telegram/PhotoSizeSource.h"
|
#include "td/telegram/PhotoSizeSource.h"
|
||||||
#include "td/telegram/PollManager.h"
|
#include "td/telegram/PollManager.h"
|
||||||
#include "td/telegram/PrivacyManager.h"
|
#include "td/telegram/PrivacyManager.h"
|
||||||
|
#include "td/telegram/PublicDialogType.h"
|
||||||
#include "td/telegram/RequestActor.h"
|
#include "td/telegram/RequestActor.h"
|
||||||
#include "td/telegram/SecretChatId.h"
|
#include "td/telegram/SecretChatId.h"
|
||||||
#include "td/telegram/SecretChatsManager.h"
|
#include "td/telegram/SecretChatsManager.h"
|
||||||
@ -1031,9 +1032,10 @@ class GetGroupsInCommonRequest : public RequestActor<> {
|
|||||||
|
|
||||||
class GetCreatedPublicChatsRequest : public RequestActor<> {
|
class GetCreatedPublicChatsRequest : public RequestActor<> {
|
||||||
vector<DialogId> dialog_ids_;
|
vector<DialogId> dialog_ids_;
|
||||||
|
PublicDialogType type_;
|
||||||
|
|
||||||
void do_run(Promise<Unit> &&promise) override {
|
void do_run(Promise<Unit> &&promise) override {
|
||||||
dialog_ids_ = td->contacts_manager_->get_created_public_dialogs(std::move(promise));
|
dialog_ids_ = td->contacts_manager_->get_created_public_dialogs(type_, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_send_result() override {
|
void do_send_result() override {
|
||||||
@ -1041,7 +1043,8 @@ class GetCreatedPublicChatsRequest : public RequestActor<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GetCreatedPublicChatsRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
GetCreatedPublicChatsRequest(ActorShared<Td> td, uint64 request_id, PublicDialogType type)
|
||||||
|
: RequestActor(std::move(td), request_id), type_(type) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5498,7 +5501,7 @@ void Td::on_request(uint64 id, td_api::checkChatUsername &request) {
|
|||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::getCreatedPublicChats &request) {
|
void Td::on_request(uint64 id, const td_api::getCreatedPublicChats &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_NO_ARGS_REQUEST(GetCreatedPublicChatsRequest);
|
CREATE_REQUEST(GetCreatedPublicChatsRequest, get_public_dialog_type(request.type_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::getSuitableDiscussionChats &request) {
|
void Td::on_request(uint64 id, const td_api::getSuitableDiscussionChats &request) {
|
||||||
|
@ -3275,6 +3275,9 @@ class CliClient final : public Actor {
|
|||||||
send_request(td_api::make_object<td_api::deleteSupergroup>(as_supergroup_id(args)));
|
send_request(td_api::make_object<td_api::deleteSupergroup>(as_supergroup_id(args)));
|
||||||
} else if (op == "gcpc") {
|
} else if (op == "gcpc") {
|
||||||
send_request(td_api::make_object<td_api::getCreatedPublicChats>());
|
send_request(td_api::make_object<td_api::getCreatedPublicChats>());
|
||||||
|
} else if (op == "gcpcl") {
|
||||||
|
send_request(td_api::make_object<td_api::getCreatedPublicChats>(
|
||||||
|
td_api::make_object<td_api::publicChatTypeIsLocationBased>()));
|
||||||
} else if (op == "gsdc") {
|
} else if (op == "gsdc") {
|
||||||
send_request(td_api::make_object<td_api::getSuitableDiscussionChats>());
|
send_request(td_api::make_object<td_api::getSuitableDiscussionChats>());
|
||||||
} else if (op == "cpc") {
|
} else if (op == "cpc") {
|
||||||
|
Loading…
Reference in New Issue
Block a user