Add td_api::getArchiveChatListSettings.

This commit is contained in:
levlam 2023-07-14 14:54:35 +03:00
parent fa1e7a1eab
commit e067160876
7 changed files with 117 additions and 0 deletions

View File

@ -369,6 +369,7 @@ set(TDLIB_SOURCE
td/telegram/Game.cpp
td/telegram/GameManager.cpp
td/telegram/Global.cpp
td/telegram/GlobalPrivacySettings.cpp
td/telegram/GroupCallManager.cpp
td/telegram/GroupCallParticipant.cpp
td/telegram/GroupCallParticipantOrder.cpp
@ -634,6 +635,7 @@ set(TDLIB_SOURCE
td/telegram/GameManager.h
td/telegram/GitCommitHash.h
td/telegram/Global.h
td/telegram/GlobalPrivacySettings.h
td/telegram/GroupCallId.h
td/telegram/GroupCallManager.h
td/telegram/GroupCallParticipant.h

View File

@ -1409,6 +1409,12 @@ recommendedChatFolder folder:chatFolder description:string = RecommendedChatFold
//@description Contains a list of recommended chat folders @chat_folders List of recommended chat folders
recommendedChatFolders chat_folders:vector<recommendedChatFolder> = RecommendedChatFolders;
//@description Contains settings for automatic moving of chats to and from the Archive chat lists
//@archive_and_mute_new_chats_from_unknown_users True, if new chats from non-contacts will be automatically archived and muted. Can be set to true only if the option "can_archive_and_mute_new_chats_from_unknown_users" is true
//@keep_unmuted_chats_archived True, if unmuted chats will be kept in the Archive chat list when they get a new message
//@keep_chats_from_shareable_folders_archived True, if unmuted chats added via a shareable folder will be kept in the Archive chat list when they get a new message. Ignored if keep_unmuted_chats_archived == true
archiveChatListSettings archive_and_mute_new_chats_from_unknown_users:Bool keep_unmuted_chats_archived:Bool keep_chats_from_shareable_folders_archived:Bool = ArchiveChatListSettings;
//@class ChatList @description Describes a list of chats
@ -7074,6 +7080,9 @@ getChatFolderNewChats chat_folder_id:int32 = Chats;
//@description Process new chats added to a shareable chat folder by its owner @chat_folder_id Chat folder identifier @added_chat_ids Identifiers of the new chats, which are added to the chat folder. The chats are automatically joined if they aren't joined yet
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 the chat title. Supported only for basic groups, supergroups and channels. Requires can_change_info administrator right
//@chat_id Chat identifier

View File

@ -0,0 +1,62 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// 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/GlobalPrivacySettings.h"
#include "td/telegram/Global.h"
#include "td/telegram/net/NetQueryCreator.h"
#include "td/telegram/Td.h"
#include "td/utils/buffer.h"
#include "td/utils/Status.h"
namespace td {
class GetGlobalPrivacySettingsQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::archiveChatListSettings>> promise_;
public:
explicit GetGlobalPrivacySettingsQuery(Promise<td_api::object_ptr<td_api::archiveChatListSettings>> &&promise)
: promise_(std::move(promise)) {
}
void send() {
send_query(G()->net_query_creator().create(telegram_api::account_getGlobalPrivacySettings()));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_getGlobalPrivacySettings>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto settings = GlobalPrivacySettings(result_ptr.move_as_ok());
promise_.set_value(settings.get_archive_chat_list_settings_object());
}
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_) {
}
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_,
keep_archived_unmuted_, keep_archived_folders_);
}
void GlobalPrivacySettings::get_global_privacy_settings(
Td *td, Promise<td_api::object_ptr<td_api::archiveChatListSettings>> &&promise) {
td->create_handler<GetGlobalPrivacySettingsQuery>(std::move(promise))->send();
}
} // namespace td

View File

@ -0,0 +1,33 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// 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/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/common.h"
#include "td/utils/Promise.h"
namespace td {
class Td;
class GlobalPrivacySettings {
bool archive_and_mute_new_noncontact_peers_ = false;
bool keep_archived_unmuted_ = false;
bool keep_archived_folders_ = false;
public:
explicit GlobalPrivacySettings(telegram_api::object_ptr<telegram_api::globalPrivacySettings> &&settings);
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);
};
} // namespace td

View File

@ -60,6 +60,7 @@
#include "td/telegram/FullMessageId.h"
#include "td/telegram/GameManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/GlobalPrivacySettings.h"
#include "td/telegram/GroupCallId.h"
#include "td/telegram/GroupCallManager.h"
#include "td/telegram/HashtagHints.h"
@ -6343,6 +6344,12 @@ void Td::on_request(uint64 id, const td_api::processChatFolderNewChats &request)
DialogFilterId(request.chat_folder_id_), DialogId::get_dialog_ids(request.added_chat_ids_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getArchiveChatListSettings &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
GlobalPrivacySettings::get_global_privacy_settings(this, std::move(promise));
}
void Td::on_request(uint64 id, td_api::setChatTitle &request) {
CLEAN_INPUT_STRING(request.title_);
CREATE_OK_REQUEST_PROMISE();

View File

@ -972,6 +972,8 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::processChatFolderNewChats &request);
void on_request(uint64 id, const td_api::getArchiveChatListSettings &request);
void on_request(uint64 id, td_api::setChatTitle &request);
void on_request(uint64 id, const td_api::setChatPhoto &request);

View File

@ -4952,6 +4952,8 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::getRecommendedChatFolders>());
} else if (op == "gcfdin") {
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 == "sct") {
ChatId chat_id;
string title;