Add td_api::setArchiveChatListSettings.
This commit is contained in:
parent
e067160876
commit
0181baf1ad
@ -7083,6 +7083,9 @@ processChatFolderNewChats chat_folder_id:int32 added_chat_ids:vector<int53> = Ok
|
||||
//@description Returns settings for automatic moving of chats to and from the Archive chat lists
|
||||
getArchiveChatListSettings = ArchiveChatListSettings;
|
||||
|
||||
//@description Changes settings for automatic moving of chats to and from the Archive chat lists @settings New settings
|
||||
setArchiveChatListSettings settings:archiveChatListSettings = Ok;
|
||||
|
||||
|
||||
//@description Changes the chat title. Supported only for basic groups, supergroups and channels. Requires can_change_info administrator right
|
||||
//@chat_id Chat identifier
|
||||
|
@ -24,7 +24,7 @@ class GetGlobalPrivacySettingsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void send() {
|
||||
send_query(G()->net_query_creator().create(telegram_api::account_getGlobalPrivacySettings()));
|
||||
send_query(G()->net_query_creator().create(telegram_api::account_getGlobalPrivacySettings(), {{"me"}}));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
@ -42,12 +42,62 @@ class GetGlobalPrivacySettingsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class SetGlobalPrivacySettingsQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit SetGlobalPrivacySettingsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(GlobalPrivacySettings settings) {
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::account_setGlobalPrivacySettings(settings.get_input_global_privacy_settings()), {{"me"}}));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::account_setGlobalPrivacySettings>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
GlobalPrivacySettings::GlobalPrivacySettings(telegram_api::object_ptr<telegram_api::globalPrivacySettings> &&settings)
|
||||
: archive_and_mute_new_noncontact_peers_(settings->archive_and_mute_new_noncontact_peers_)
|
||||
, keep_archived_unmuted_(settings->keep_archived_unmuted_)
|
||||
, keep_archived_folders_(settings->keep_archived_folders_) {
|
||||
}
|
||||
|
||||
GlobalPrivacySettings::GlobalPrivacySettings(td_api::object_ptr<td_api::archiveChatListSettings> &&settings) {
|
||||
if (settings != nullptr) {
|
||||
archive_and_mute_new_noncontact_peers_ = settings->archive_and_mute_new_chats_from_unknown_users_;
|
||||
keep_archived_unmuted_ = settings->keep_unmuted_chats_archived_;
|
||||
keep_archived_folders_ = settings->keep_chats_from_shareable_folders_archived_;
|
||||
}
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::globalPrivacySettings> GlobalPrivacySettings::get_input_global_privacy_settings()
|
||||
const {
|
||||
int32 flags = 0;
|
||||
if (archive_and_mute_new_noncontact_peers_) {
|
||||
flags |= telegram_api::globalPrivacySettings::ARCHIVE_AND_MUTE_NEW_NONCONTACT_PEERS_MASK;
|
||||
}
|
||||
if (keep_archived_unmuted_) {
|
||||
flags |= telegram_api::globalPrivacySettings::KEEP_ARCHIVED_UNMUTED_MASK;
|
||||
}
|
||||
if (keep_archived_folders_) {
|
||||
flags |= telegram_api::globalPrivacySettings::KEEP_ARCHIVED_FOLDERS_MASK;
|
||||
}
|
||||
return telegram_api::make_object<telegram_api::globalPrivacySettings>(flags, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::archiveChatListSettings> GlobalPrivacySettings::get_archive_chat_list_settings_object()
|
||||
const {
|
||||
return td_api::make_object<td_api::archiveChatListSettings>(archive_and_mute_new_noncontact_peers_,
|
||||
@ -59,4 +109,9 @@ void GlobalPrivacySettings::get_global_privacy_settings(
|
||||
td->create_handler<GetGlobalPrivacySettingsQuery>(std::move(promise))->send();
|
||||
}
|
||||
|
||||
void GlobalPrivacySettings::set_global_privacy_settings(Td *td, GlobalPrivacySettings settings,
|
||||
Promise<Unit> &&promise) {
|
||||
td->create_handler<SetGlobalPrivacySettingsQuery>(std::move(promise))->send(std::move(settings));
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -24,10 +24,16 @@ class GlobalPrivacySettings {
|
||||
public:
|
||||
explicit GlobalPrivacySettings(telegram_api::object_ptr<telegram_api::globalPrivacySettings> &&settings);
|
||||
|
||||
explicit GlobalPrivacySettings(td_api::object_ptr<td_api::archiveChatListSettings> &&settings);
|
||||
|
||||
telegram_api::object_ptr<telegram_api::globalPrivacySettings> get_input_global_privacy_settings() const;
|
||||
|
||||
td_api::object_ptr<td_api::archiveChatListSettings> get_archive_chat_list_settings_object() const;
|
||||
|
||||
static void get_global_privacy_settings(Td *td,
|
||||
Promise<td_api::object_ptr<td_api::archiveChatListSettings>> &&promise);
|
||||
|
||||
static void set_global_privacy_settings(Td *td, GlobalPrivacySettings settings, Promise<Unit> &&promise);
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
@ -6350,6 +6350,13 @@ void Td::on_request(uint64 id, const td_api::getArchiveChatListSettings &request
|
||||
GlobalPrivacySettings::get_global_privacy_settings(this, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setArchiveChatListSettings &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
GlobalPrivacySettings::set_global_privacy_settings(this, GlobalPrivacySettings(std::move(request.settings_)),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setChatTitle &request) {
|
||||
CLEAN_INPUT_STRING(request.title_);
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
|
@ -974,6 +974,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::getArchiveChatListSettings &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setArchiveChatListSettings &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setChatTitle &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::setChatPhoto &request);
|
||||
|
@ -4954,6 +4954,16 @@ class CliClient final : public Actor {
|
||||
execute(td_api::make_object<td_api::getChatFolderDefaultIconName>(as_chat_folder(args)));
|
||||
} else if (op == "gacls") {
|
||||
send_request(td_api::make_object<td_api::getArchiveChatListSettings>());
|
||||
} else if (op == "sacls") {
|
||||
bool archive_and_mute_new_chats_from_unknown_users;
|
||||
bool keep_unmuted_chats_archived;
|
||||
bool keep_chats_from_shareable_folders_archived;
|
||||
get_args(args, archive_and_mute_new_chats_from_unknown_users, keep_unmuted_chats_archived,
|
||||
keep_chats_from_shareable_folders_archived);
|
||||
auto settings = td_api::make_object<td_api::archiveChatListSettings>(
|
||||
archive_and_mute_new_chats_from_unknown_users, keep_unmuted_chats_archived,
|
||||
keep_chats_from_shareable_folders_archived);
|
||||
send_request(td_api::make_object<td_api::setArchiveChatListSettings>(std::move(settings)));
|
||||
} else if (op == "sct") {
|
||||
ChatId chat_id;
|
||||
string title;
|
||||
|
Loading…
Reference in New Issue
Block a user