Add td_api::BlockList.
This commit is contained in:
parent
f0e59da1ff
commit
3794e65b76
@ -542,6 +542,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/BackgroundInfo.h
|
td/telegram/BackgroundInfo.h
|
||||||
td/telegram/BackgroundManager.h
|
td/telegram/BackgroundManager.h
|
||||||
td/telegram/BackgroundType.h
|
td/telegram/BackgroundType.h
|
||||||
|
td/telegram/BlockListId.h
|
||||||
td/telegram/BotCommand.h
|
td/telegram/BotCommand.h
|
||||||
td/telegram/BotCommandScope.h
|
td/telegram/BotCommandScope.h
|
||||||
td/telegram/BotInfoManager.h
|
td/telegram/BotInfoManager.h
|
||||||
|
@ -746,7 +746,7 @@ botInfo short_description:string description:string photo:photo animation:animat
|
|||||||
//-If non-null and personal_photo is null, then it is the same photo as in user.profile_photo and chat.photo
|
//-If non-null and personal_photo is null, then it is the same photo as in user.profile_photo and chat.photo
|
||||||
//@public_photo User profile photo visible if the main photo is hidden by privacy settings; may be null. If null and user.profile_photo is null, then the photo is empty; otherwise, it is unknown.
|
//@public_photo User profile photo visible if the main photo is hidden by privacy settings; may be null. If null and user.profile_photo is null, then the photo is empty; otherwise, it is unknown.
|
||||||
//-If non-null and both photo and personal_photo are null, then it is the same photo as in user.profile_photo and chat.photo. This photo isn't returned in the list of user photos
|
//-If non-null and both photo and personal_photo are null, then it is the same photo as in user.profile_photo and chat.photo. This photo isn't returned in the list of user photos
|
||||||
//@is_blocked True, if the user is blocked by the current user
|
//@block_list Block list to which the user is added; may be null if none
|
||||||
//@can_be_called True, if the user can be called
|
//@can_be_called True, if the user can be called
|
||||||
//@supports_video_calls True, if a video call can be created with the user
|
//@supports_video_calls True, if a video call can be created with the user
|
||||||
//@has_private_calls True, if the user can't be called due to their privacy settings
|
//@has_private_calls True, if the user can't be called due to their privacy settings
|
||||||
@ -758,7 +758,7 @@ botInfo short_description:string description:string photo:photo animation:animat
|
|||||||
//@premium_gift_options The list of available options for gifting Telegram Premium to the user
|
//@premium_gift_options The list of available options for gifting Telegram Premium to the user
|
||||||
//@group_in_common_count Number of group chats where both the other user and the current user are a member; 0 for the current user
|
//@group_in_common_count Number of group chats where both the other user and the current user are a member; 0 for the current user
|
||||||
//@bot_info For bots, information about the bot; may be null if the user isn't a bot
|
//@bot_info For bots, information about the bot; may be null if the user isn't a bot
|
||||||
userFullInfo personal_photo:chatPhoto photo:chatPhoto public_photo:chatPhoto is_blocked:Bool can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool has_restricted_voice_and_video_note_messages:Bool has_pinned_stories:Bool need_phone_number_privacy_exception:Bool bio:formattedText premium_gift_options:vector<premiumPaymentOption> group_in_common_count:int32 bot_info:botInfo = UserFullInfo;
|
userFullInfo personal_photo:chatPhoto photo:chatPhoto public_photo:chatPhoto block_list:BlockList can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool has_restricted_voice_and_video_note_messages:Bool has_pinned_stories:Bool need_phone_number_privacy_exception:Bool bio:formattedText premium_gift_options:vector<premiumPaymentOption> group_in_common_count:int32 bot_info:botInfo = UserFullInfo;
|
||||||
|
|
||||||
//@description Represents a list of users @total_count Approximate total number of users found @user_ids A list of user identifiers
|
//@description Represents a list of users @total_count Approximate total number of users found @user_ids A list of user identifiers
|
||||||
users total_count:int32 user_ids:vector<int53> = Users;
|
users total_count:int32 user_ids:vector<int53> = Users;
|
||||||
@ -1473,10 +1473,10 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
|
|||||||
//@last_message Last message in the chat; may be null if none or unknown
|
//@last_message Last message in the chat; may be null if none or unknown
|
||||||
//@positions Positions of the chat in chat lists
|
//@positions Positions of the chat in chat lists
|
||||||
//@message_sender_id Identifier of a user or chat that is selected to send messages in the chat; may be null if the user can't change message sender
|
//@message_sender_id Identifier of a user or chat that is selected to send messages in the chat; may be null if the user can't change message sender
|
||||||
|
//@block_list Block list to which the chat is added; may be null if none
|
||||||
//@has_protected_content True, if chat content can't be saved locally, forwarded, or copied
|
//@has_protected_content True, if chat content can't be saved locally, forwarded, or copied
|
||||||
//@is_translatable True, if translation of all messages in the chat must be suggested to the user
|
//@is_translatable True, if translation of all messages in the chat must be suggested to the user
|
||||||
//@is_marked_as_unread True, if the chat is marked as unread
|
//@is_marked_as_unread True, if the chat is marked as unread
|
||||||
//@is_blocked True, if the chat is blocked by the current user and private messages from the chat can't be received
|
|
||||||
//@has_scheduled_messages True, if the chat has scheduled messages
|
//@has_scheduled_messages True, if the chat has scheduled messages
|
||||||
//@can_be_deleted_only_for_self True, if the chat messages can be deleted only for the current user while other users will continue to see the messages
|
//@can_be_deleted_only_for_self True, if the chat messages can be deleted only for the current user while other users will continue to see the messages
|
||||||
//@can_be_deleted_for_all_users True, if the chat messages can be deleted for all users
|
//@can_be_deleted_for_all_users True, if the chat messages can be deleted for all users
|
||||||
@ -1498,7 +1498,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
|
|||||||
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
|
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
|
||||||
//@draft_message A draft of a message in the chat; may be null if none
|
//@draft_message A draft of a message in the chat; may be null if none
|
||||||
//@client_data Application-specific data associated with the chat. (For example, the chat scroll position or local chat notification settings can be stored here.) Persistent if the message database is used
|
//@client_data Application-specific data associated with the chat. (For example, the chat scroll position or local chat notification settings can be stored here.) Persistent if the message database is used
|
||||||
chat id:int53 type:ChatType title:string photo:chatPhotoInfo permissions:chatPermissions last_message:message positions:vector<chatPosition> message_sender_id:MessageSender has_protected_content:Bool is_translatable:Bool is_marked_as_unread:Bool is_blocked:Bool has_scheduled_messages:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 unread_reaction_count:int32 notification_settings:chatNotificationSettings available_reactions:ChatAvailableReactions message_auto_delete_time:int32 background:chatBackground theme_name:string action_bar:ChatActionBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
|
chat id:int53 type:ChatType title:string photo:chatPhotoInfo permissions:chatPermissions last_message:message positions:vector<chatPosition> message_sender_id:MessageSender block_list:BlockList has_protected_content:Bool is_translatable:Bool is_marked_as_unread:Bool has_scheduled_messages:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 unread_reaction_count:int32 notification_settings:chatNotificationSettings available_reactions:ChatAvailableReactions message_auto_delete_time:int32 background:chatBackground theme_name:string action_bar:ChatActionBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
|
||||||
|
|
||||||
//@description Represents a list of chats @total_count Approximate total number of chats found @chat_ids List of chat identifiers
|
//@description Represents a list of chats @total_count Approximate total number of chats found @chat_ids List of chat identifiers
|
||||||
chats total_count:int32 chat_ids:vector<int53> = Chats;
|
chats total_count:int32 chat_ids:vector<int53> = Chats;
|
||||||
@ -1532,7 +1532,7 @@ chatActionBarReportUnrelatedLocation = ChatActionBar;
|
|||||||
//@description The chat is a recently created group chat to which new members can be invited
|
//@description The chat is a recently created group chat to which new members can be invited
|
||||||
chatActionBarInviteMembers = ChatActionBar;
|
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 toggleMessageSenderIsBlocked,
|
//@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 setMessageSenderBlockList,
|
||||||
//-or the other user can be added to the contact list using the method addContact. If the chat is a private chat with a user with an emoji status, then a notice about emoji status usage must be shown
|
//-or the other user can be added to the contact list using the method addContact. If the chat is a private chat with a user with an emoji status, then a notice about emoji status usage must be shown
|
||||||
//@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
|
//@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
|
//@distance If non-negative, the current user was found by the peer through searchChatsNearby and this is the distance between the users
|
||||||
@ -4994,6 +4994,15 @@ storyInfo story_id:int32 date:int32 is_for_close_friends:Bool = StoryInfo;
|
|||||||
chatActiveStories chat_id:int53 list:StoryList order:int53 max_read_story_id:int32 stories:vector<storyInfo> = ChatActiveStories;
|
chatActiveStories chat_id:int53 list:StoryList order:int53 max_read_story_id:int32 stories:vector<storyInfo> = ChatActiveStories;
|
||||||
|
|
||||||
|
|
||||||
|
//@class BlockList @description Describes a type of a block list
|
||||||
|
|
||||||
|
//@description The main block list that disallows writing messages to the current user, receiving their status and photo, viewing of stories, and some other actions
|
||||||
|
blockListMain = BlockList;
|
||||||
|
|
||||||
|
//@description The block list that disallows viewing of stories of the current user
|
||||||
|
blockListStories = BlockList;
|
||||||
|
|
||||||
|
|
||||||
//@description Contains a part of a file @data File bytes
|
//@description Contains a part of a file @data File bytes
|
||||||
filePart data:bytes = FilePart;
|
filePart data:bytes = FilePart;
|
||||||
|
|
||||||
@ -5605,8 +5614,8 @@ updateChatIsTranslatable chat_id:int53 is_translatable:Bool = Update;
|
|||||||
//@description A chat was marked as unread or was read @chat_id Chat identifier @is_marked_as_unread New value of is_marked_as_unread
|
//@description A chat was marked as unread or was read @chat_id Chat identifier @is_marked_as_unread New value of is_marked_as_unread
|
||||||
updateChatIsMarkedAsUnread chat_id:int53 is_marked_as_unread:Bool = Update;
|
updateChatIsMarkedAsUnread chat_id:int53 is_marked_as_unread:Bool = Update;
|
||||||
|
|
||||||
//@description A chat was blocked or unblocked @chat_id Chat identifier @is_blocked New value of is_blocked
|
//@description A chat was blocked or unblocked @chat_id Chat identifier @block_list Block list to which the chat is added; may be null if none
|
||||||
updateChatIsBlocked chat_id:int53 is_blocked:Bool = Update;
|
updateChatBlockList chat_id:int53 block_list:BlockList = Update;
|
||||||
|
|
||||||
//@description A chat's has_scheduled_messages field has changed @chat_id Chat identifier @has_scheduled_messages New value of has_scheduled_messages
|
//@description A chat's has_scheduled_messages field has changed @chat_id Chat identifier @has_scheduled_messages New value of has_scheduled_messages
|
||||||
updateChatHasScheduledMessages chat_id:int53 has_scheduled_messages:Bool = Update;
|
updateChatHasScheduledMessages chat_id:int53 has_scheduled_messages:Bool = Update;
|
||||||
@ -7758,8 +7767,10 @@ getGroupCallStreams group_call_id:int32 = GroupCallStreams;
|
|||||||
getGroupCallStreamSegment group_call_id:int32 time_offset:int53 scale:int32 channel_id:int32 video_quality:GroupCallVideoQuality = FilePart;
|
getGroupCallStreamSegment group_call_id:int32 time_offset:int53 scale:int32 channel_id:int32 video_quality:GroupCallVideoQuality = FilePart;
|
||||||
|
|
||||||
|
|
||||||
//@description Changes the block state of a message sender. Currently, only users and supergroup chats can be blocked @sender_id Identifier of a message sender to block/unblock @is_blocked New value of is_blocked
|
//@description Changes the block list of a message sender. Currently, only users and supergroup chats can be blocked
|
||||||
toggleMessageSenderIsBlocked sender_id:MessageSender is_blocked:Bool = Ok;
|
//@sender_id Identifier of a message sender to block/unblock
|
||||||
|
//@block_list New block list for the message sender; pass null to unblock the message sender
|
||||||
|
setMessageSenderBlockList sender_id:MessageSender block_list:BlockList = Ok;
|
||||||
|
|
||||||
//@description Blocks an original sender of a message in the Replies chat
|
//@description Blocks an original sender of a message in the Replies chat
|
||||||
//@message_id The identifier of an incoming message in the Replies chat
|
//@message_id The identifier of an incoming message in the Replies chat
|
||||||
|
99
td/telegram/BlockListId.h
Normal file
99
td/telegram/BlockListId.h
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
//
|
||||||
|
// 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/utils/common.h"
|
||||||
|
#include "td/utils/HashTableUtils.h"
|
||||||
|
#include "td/utils/StringBuilder.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
class BlockListId {
|
||||||
|
enum class Type : int32 { None = -1, Main, Stories };
|
||||||
|
Type type_ = Type::None;
|
||||||
|
|
||||||
|
friend struct BlockListIdHash;
|
||||||
|
|
||||||
|
explicit BlockListId(Type type) : type_(type) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
BlockListId() = default;
|
||||||
|
|
||||||
|
BlockListId(bool is_blocked, bool is_blocked_for_stories)
|
||||||
|
: type_(is_blocked ? Type::Main : (is_blocked_for_stories ? Type::Stories : Type::None)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit BlockListId(const td_api::object_ptr<td_api::BlockList> &block_list) {
|
||||||
|
if (block_list == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (block_list->get_id()) {
|
||||||
|
case td_api::blockListMain::ID:
|
||||||
|
type_ = Type::Main;
|
||||||
|
break;
|
||||||
|
case td_api::blockListStories::ID:
|
||||||
|
type_ = Type::Stories;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static BlockListId main() {
|
||||||
|
return BlockListId(Type::Main);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BlockListId stories() {
|
||||||
|
return BlockListId(Type::Stories);
|
||||||
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::BlockList> get_block_list_object() const {
|
||||||
|
switch (type_) {
|
||||||
|
case Type::None:
|
||||||
|
return nullptr;
|
||||||
|
case Type::Main:
|
||||||
|
return td_api::make_object<td_api::blockListMain>();
|
||||||
|
case Type::Stories:
|
||||||
|
return td_api::make_object<td_api::blockListStories>();
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_valid() const {
|
||||||
|
return type_ == Type::Main || type_ == Type::Stories;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const BlockListId &other) const {
|
||||||
|
return type_ == other.type_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const BlockListId &other) const {
|
||||||
|
return type_ != other.type_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BlockListIdHash {
|
||||||
|
uint32 operator()(BlockListId block_list_id) const {
|
||||||
|
return Hash<int32>()(static_cast<int32>(block_list_id.type_));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline StringBuilder &operator<<(StringBuilder &string_builder, BlockListId block_list_id) {
|
||||||
|
if (block_list_id == BlockListId::main()) {
|
||||||
|
return string_builder << "MainBlockList";
|
||||||
|
}
|
||||||
|
if (block_list_id == BlockListId::stories()) {
|
||||||
|
return string_builder << "StoriesBlockList";
|
||||||
|
}
|
||||||
|
return string_builder << "InvalidBlockList";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
@ -9,6 +9,7 @@
|
|||||||
#include "td/telegram/Account.h"
|
#include "td/telegram/Account.h"
|
||||||
#include "td/telegram/AnimationsManager.h"
|
#include "td/telegram/AnimationsManager.h"
|
||||||
#include "td/telegram/AuthManager.h"
|
#include "td/telegram/AuthManager.h"
|
||||||
|
#include "td/telegram/BlockListId.h"
|
||||||
#include "td/telegram/BotMenuButton.h"
|
#include "td/telegram/BotMenuButton.h"
|
||||||
#include "td/telegram/ChannelParticipantFilter.h"
|
#include "td/telegram/ChannelParticipantFilter.h"
|
||||||
#include "td/telegram/ConfigManager.h"
|
#include "td/telegram/ConfigManager.h"
|
||||||
@ -19222,10 +19223,11 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
|
|||||||
bio_object = get_formatted_text_object(bio, true, 0);
|
bio_object = get_formatted_text_object(bio, true, 0);
|
||||||
}
|
}
|
||||||
auto voice_messages_forbidden = is_premium ? user_full->voice_messages_forbidden : false;
|
auto voice_messages_forbidden = is_premium ? user_full->voice_messages_forbidden : false;
|
||||||
return make_tl_object<td_api::userFullInfo>(
|
auto block_list_id = BlockListId(user_full->is_blocked, user_full->is_blocked_for_stories);
|
||||||
|
return td_api::make_object<td_api::userFullInfo>(
|
||||||
get_chat_photo_object(td_->file_manager_.get(), user_full->personal_photo),
|
get_chat_photo_object(td_->file_manager_.get(), user_full->personal_photo),
|
||||||
get_chat_photo_object(td_->file_manager_.get(), user_full->photo),
|
get_chat_photo_object(td_->file_manager_.get(), user_full->photo),
|
||||||
get_chat_photo_object(td_->file_manager_.get(), user_full->fallback_photo), user_full->is_blocked,
|
get_chat_photo_object(td_->file_manager_.get(), user_full->fallback_photo), block_list_id.get_block_list_object(),
|
||||||
user_full->can_be_called, user_full->supports_video_calls, user_full->has_private_calls,
|
user_full->can_be_called, user_full->supports_video_calls, user_full->has_private_calls,
|
||||||
!user_full->private_forward_name.empty(), voice_messages_forbidden, user_full->has_pinned_stories,
|
!user_full->private_forward_name.empty(), voice_messages_forbidden, user_full->has_pinned_stories,
|
||||||
user_full->need_phone_number_privacy_exception, std::move(bio_object),
|
user_full->need_phone_number_privacy_exception, std::move(bio_object),
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "td/telegram/Account.h"
|
#include "td/telegram/Account.h"
|
||||||
#include "td/telegram/AuthManager.h"
|
#include "td/telegram/AuthManager.h"
|
||||||
#include "td/telegram/BackgroundInfo.hpp"
|
#include "td/telegram/BackgroundInfo.hpp"
|
||||||
|
#include "td/telegram/BlockListId.h"
|
||||||
#include "td/telegram/ChainId.h"
|
#include "td/telegram/ChainId.h"
|
||||||
#include "td/telegram/ChannelType.h"
|
#include "td/telegram/ChannelType.h"
|
||||||
#include "td/telegram/ChatId.h"
|
#include "td/telegram/ChatId.h"
|
||||||
@ -1617,28 +1618,29 @@ class ToggleDialogTranslationsQuery final : public Td::ResultHandler {
|
|||||||
class ToggleDialogIsBlockedQuery final : public Td::ResultHandler {
|
class ToggleDialogIsBlockedQuery final : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<Unit> promise_;
|
||||||
DialogId dialog_id_;
|
DialogId dialog_id_;
|
||||||
bool is_blocked_;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ToggleDialogIsBlockedQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit ToggleDialogIsBlockedQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(DialogId dialog_id, bool is_blocked) {
|
void send(DialogId dialog_id, bool is_blocked, bool is_blocked_for_stories) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
is_blocked_ = is_blocked;
|
|
||||||
|
|
||||||
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Know);
|
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Know);
|
||||||
CHECK(input_peer != nullptr && input_peer->get_id() != telegram_api::inputPeerEmpty::ID);
|
CHECK(input_peer != nullptr && input_peer->get_id() != telegram_api::inputPeerEmpty::ID);
|
||||||
|
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
|
if (is_blocked_for_stories) {
|
||||||
|
flags |= telegram_api::contacts_block::MY_STORIES_FROM_MASK;
|
||||||
|
}
|
||||||
vector<ChainId> chain_ids{{dialog_id, MessageContentType::Photo}, {dialog_id, MessageContentType::Text}};
|
vector<ChainId> chain_ids{{dialog_id, MessageContentType::Photo}, {dialog_id, MessageContentType::Text}};
|
||||||
auto query = is_blocked ? G()->net_query_creator().create(
|
auto query =
|
||||||
telegram_api::contacts_block(flags, false /*ignored*/, std::move(input_peer)),
|
is_blocked || is_blocked_for_stories
|
||||||
std::move(chain_ids))
|
? G()->net_query_creator().create(
|
||||||
: G()->net_query_creator().create(
|
telegram_api::contacts_block(flags, false /*ignored*/, std::move(input_peer)), std::move(chain_ids))
|
||||||
telegram_api::contacts_unblock(flags, false /*ignored*/, std::move(input_peer)),
|
: G()->net_query_creator().create(
|
||||||
std::move(chain_ids));
|
telegram_api::contacts_unblock(flags, false /*ignored*/, std::move(input_peer)),
|
||||||
|
std::move(chain_ids));
|
||||||
send_query(std::move(query));
|
send_query(std::move(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1661,7 +1663,6 @@ class ToggleDialogIsBlockedQuery final : public Td::ResultHandler {
|
|||||||
LOG(ERROR) << "Receive error for ToggleDialogIsBlockedQuery: " << status;
|
LOG(ERROR) << "Receive error for ToggleDialogIsBlockedQuery: " << status;
|
||||||
}
|
}
|
||||||
if (!G()->close_flag()) {
|
if (!G()->close_flag()) {
|
||||||
td_->messages_manager_->on_update_dialog_is_blocked(dialog_id_, !is_blocked_, false);
|
|
||||||
td_->messages_manager_->get_dialog_info_full(dialog_id_, Auto(), "ToggleDialogIsBlockedQuery");
|
td_->messages_manager_->get_dialog_info_full(dialog_id_, Auto(), "ToggleDialogIsBlockedQuery");
|
||||||
td_->messages_manager_->reget_dialog_action_bar(dialog_id_, "ToggleDialogIsBlockedQuery");
|
td_->messages_manager_->reget_dialog_action_bar(dialog_id_, "ToggleDialogIsBlockedQuery");
|
||||||
}
|
}
|
||||||
@ -19547,13 +19548,17 @@ void MessagesManager::toggle_dialog_is_translatable_on_server(DialogId dialog_id
|
|||||||
->send(dialog_id, is_translatable);
|
->send(dialog_id, is_translatable);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status MessagesManager::toggle_message_sender_is_blocked(const td_api::object_ptr<td_api::MessageSender> &sender,
|
Status MessagesManager::set_message_sender_block_list(const td_api::object_ptr<td_api::MessageSender> &sender,
|
||||||
bool is_blocked) {
|
const td_api::object_ptr<td_api::BlockList> &block_list) {
|
||||||
TRY_RESULT(dialog_id, get_message_sender_dialog_id(td_, sender, true, false));
|
TRY_RESULT(dialog_id, get_message_sender_dialog_id(td_, sender, true, false));
|
||||||
|
BlockListId block_list_id(block_list);
|
||||||
|
bool is_blocked = block_list_id == BlockListId::main();
|
||||||
|
bool is_blocked_for_stories = block_list_id == BlockListId::stories();
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
if (dialog_id == get_my_dialog_id()) {
|
if (dialog_id == get_my_dialog_id()) {
|
||||||
return Status::Error(400, is_blocked ? Slice("Can't block self") : Slice("Can't unblock self"));
|
return Status::Error(
|
||||||
|
400, is_blocked || is_blocked_for_stories ? Slice("Can't block self") : Slice("Can't unblock self"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
@ -19563,8 +19568,7 @@ Status MessagesManager::toggle_message_sender_is_blocked(const td_api::object_pt
|
|||||||
break;
|
break;
|
||||||
case DialogType::SecretChat: {
|
case DialogType::SecretChat: {
|
||||||
auto user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
auto user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
|
||||||
if (!user_id.is_valid() ||
|
if (!user_id.is_valid() || !td_->contacts_manager_->have_user_force(user_id, "set_message_sender_block_list")) {
|
||||||
!td_->contacts_manager_->have_user_force(user_id, "toggle_message_sender_is_blocked")) {
|
|
||||||
return Status::Error(400, "The secret chat can't be blocked");
|
return Status::Error(400, "The secret chat can't be blocked");
|
||||||
}
|
}
|
||||||
dialog_id = DialogId(user_id);
|
dialog_id = DialogId(user_id);
|
||||||
@ -19575,22 +19579,21 @@ Status MessagesManager::toggle_message_sender_is_blocked(const td_api::object_pt
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog *d = get_dialog_force(dialog_id, "toggle_message_sender_is_blocked");
|
Dialog *d = get_dialog_force(dialog_id, "set_message_sender_block_list");
|
||||||
if (!have_input_peer(dialog_id, AccessRights::Know)) {
|
if (!have_input_peer(dialog_id, AccessRights::Know)) {
|
||||||
return Status::Error(400, "Message sender isn't accessible");
|
return Status::Error(400, "Message sender isn't accessible");
|
||||||
}
|
}
|
||||||
if (d != nullptr) {
|
if (d != nullptr) {
|
||||||
if (is_blocked == d->is_blocked) {
|
if (is_blocked == d->is_blocked && is_blocked_for_stories == d->is_blocked_for_stories) {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
set_dialog_is_blocked(d, is_blocked, is_blocked ? false : d->is_blocked_for_stories);
|
set_dialog_is_blocked(d, is_blocked, is_blocked_for_stories);
|
||||||
} else {
|
} else {
|
||||||
CHECK(dialog_id.get_type() == DialogType::User);
|
CHECK(dialog_id.get_type() == DialogType::User);
|
||||||
td_->contacts_manager_->on_update_user_is_blocked(dialog_id.get_user_id(), is_blocked,
|
td_->contacts_manager_->on_update_user_is_blocked(dialog_id.get_user_id(), is_blocked, is_blocked_for_stories);
|
||||||
is_blocked ? false : d->is_blocked_for_stories);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle_dialog_is_blocked_on_server(dialog_id, is_blocked, 0);
|
toggle_dialog_is_blocked_on_server(dialog_id, is_blocked, is_blocked_for_stories, 0);
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19598,11 +19601,13 @@ class MessagesManager::ToggleDialogIsBlockedOnServerLogEvent {
|
|||||||
public:
|
public:
|
||||||
DialogId dialog_id_;
|
DialogId dialog_id_;
|
||||||
bool is_blocked_;
|
bool is_blocked_;
|
||||||
|
bool is_blocked_for_stories_;
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void store(StorerT &storer) const {
|
void store(StorerT &storer) const {
|
||||||
BEGIN_STORE_FLAGS();
|
BEGIN_STORE_FLAGS();
|
||||||
STORE_FLAG(is_blocked_);
|
STORE_FLAG(is_blocked_);
|
||||||
|
STORE_FLAG(is_blocked_for_stories_);
|
||||||
END_STORE_FLAGS();
|
END_STORE_FLAGS();
|
||||||
|
|
||||||
td::store(dialog_id_, storer);
|
td::store(dialog_id_, storer);
|
||||||
@ -19612,25 +19617,28 @@ class MessagesManager::ToggleDialogIsBlockedOnServerLogEvent {
|
|||||||
void parse(ParserT &parser) {
|
void parse(ParserT &parser) {
|
||||||
BEGIN_PARSE_FLAGS();
|
BEGIN_PARSE_FLAGS();
|
||||||
PARSE_FLAG(is_blocked_);
|
PARSE_FLAG(is_blocked_);
|
||||||
|
PARSE_FLAG(is_blocked_for_stories_);
|
||||||
END_PARSE_FLAGS();
|
END_PARSE_FLAGS();
|
||||||
|
|
||||||
td::parse(dialog_id_, parser);
|
td::parse(dialog_id_, parser);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64 MessagesManager::save_toggle_dialog_is_blocked_on_server_log_event(DialogId dialog_id, bool is_blocked) {
|
uint64 MessagesManager::save_toggle_dialog_is_blocked_on_server_log_event(DialogId dialog_id, bool is_blocked,
|
||||||
ToggleDialogIsBlockedOnServerLogEvent log_event{dialog_id, is_blocked};
|
bool is_blocked_for_stories) {
|
||||||
|
ToggleDialogIsBlockedOnServerLogEvent log_event{dialog_id, is_blocked, is_blocked_for_stories};
|
||||||
return binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ToggleDialogIsBlockedOnServer,
|
return binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ToggleDialogIsBlockedOnServer,
|
||||||
get_log_event_storer(log_event));
|
get_log_event_storer(log_event));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::toggle_dialog_is_blocked_on_server(DialogId dialog_id, bool is_blocked, uint64 log_event_id) {
|
void MessagesManager::toggle_dialog_is_blocked_on_server(DialogId dialog_id, bool is_blocked,
|
||||||
|
bool is_blocked_for_stories, uint64 log_event_id) {
|
||||||
if (log_event_id == 0 && G()->use_message_database()) {
|
if (log_event_id == 0 && G()->use_message_database()) {
|
||||||
log_event_id = save_toggle_dialog_is_blocked_on_server_log_event(dialog_id, is_blocked);
|
log_event_id = save_toggle_dialog_is_blocked_on_server_log_event(dialog_id, is_blocked, is_blocked_for_stories);
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->create_handler<ToggleDialogIsBlockedQuery>(get_erase_log_event_promise(log_event_id))
|
td_->create_handler<ToggleDialogIsBlockedQuery>(get_erase_log_event_promise(log_event_id))
|
||||||
->send(dialog_id, is_blocked);
|
->send(dialog_id, is_blocked, is_blocked_for_stories);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status MessagesManager::toggle_dialog_silent_send_message(DialogId dialog_id, bool silent_send_message) {
|
Status MessagesManager::toggle_dialog_silent_send_message(DialogId dialog_id, bool silent_send_message) {
|
||||||
@ -20822,13 +20830,14 @@ td_api::object_ptr<td_api::chat> MessagesManager::get_chat_object(const Dialog *
|
|||||||
!need_hide_dialog_draft_message(d->dialog_id) ? get_draft_message_object(d->draft_message) : nullptr;
|
!need_hide_dialog_draft_message(d->dialog_id) ? get_draft_message_object(d->draft_message) : nullptr;
|
||||||
auto available_reactions = get_dialog_active_reactions(d).get_chat_available_reactions_object();
|
auto available_reactions = get_dialog_active_reactions(d).get_chat_available_reactions_object();
|
||||||
auto is_translatable = d->is_translatable && is_premium;
|
auto is_translatable = d->is_translatable && is_premium;
|
||||||
|
auto block_list_id = BlockListId(d->is_blocked, d->is_blocked_for_stories);
|
||||||
return make_tl_object<td_api::chat>(
|
return make_tl_object<td_api::chat>(
|
||||||
d->dialog_id.get(), get_chat_type_object(d->dialog_id), get_dialog_title(d->dialog_id),
|
d->dialog_id.get(), get_chat_type_object(d->dialog_id), get_dialog_title(d->dialog_id),
|
||||||
get_chat_photo_info_object(td_->file_manager_.get(), get_dialog_photo(d->dialog_id)),
|
get_chat_photo_info_object(td_->file_manager_.get(), get_dialog_photo(d->dialog_id)),
|
||||||
get_dialog_default_permissions(d->dialog_id).get_chat_permissions_object(),
|
get_dialog_default_permissions(d->dialog_id).get_chat_permissions_object(),
|
||||||
get_message_object(d->dialog_id, get_message(d, d->last_message_id), "get_chat_object"),
|
get_message_object(d->dialog_id, get_message(d, d->last_message_id), "get_chat_object"),
|
||||||
get_chat_positions_object(d), get_default_message_sender_object(d),
|
get_chat_positions_object(d), get_default_message_sender_object(d), block_list_id.get_block_list_object(),
|
||||||
get_dialog_has_protected_content(d->dialog_id), is_translatable, d->is_marked_as_unread, d->is_blocked,
|
get_dialog_has_protected_content(d->dialog_id), is_translatable, d->is_marked_as_unread,
|
||||||
get_dialog_has_scheduled_messages(d), can_delete.for_self_, can_delete.for_all_users_,
|
get_dialog_has_scheduled_messages(d), can_delete.for_self_, can_delete.for_all_users_,
|
||||||
can_report_dialog(d->dialog_id), d->notification_settings.silent_send_message,
|
can_report_dialog(d->dialog_id), d->notification_settings.silent_send_message,
|
||||||
d->server_unread_count + d->local_unread_count, d->last_read_inbox_message_id.get(),
|
d->server_unread_count + d->local_unread_count, d->last_read_inbox_message_id.get(),
|
||||||
@ -31765,9 +31774,10 @@ void MessagesManager::set_dialog_is_blocked(Dialog *d, bool is_blocked, bool is_
|
|||||||
|
|
||||||
LOG(INFO) << "Set " << d->dialog_id << " is_blocked to " << is_blocked << '/' << is_blocked_for_stories;
|
LOG(INFO) << "Set " << d->dialog_id << " is_blocked to " << is_blocked << '/' << is_blocked_for_stories;
|
||||||
LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_is_blocked";
|
LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in set_dialog_is_blocked";
|
||||||
|
auto block_list_id = BlockListId(d->is_blocked, d->is_blocked_for_stories);
|
||||||
send_closure(G()->td(), &Td::send_update,
|
send_closure(G()->td(), &Td::send_update,
|
||||||
td_api::make_object<td_api::updateChatIsBlocked>(get_chat_id_object(d->dialog_id, "updateChatIsBlocked"),
|
td_api::make_object<td_api::updateChatBlockList>(get_chat_id_object(d->dialog_id, "updateChatBlockList"),
|
||||||
is_blocked));
|
block_list_id.get_block_list_object()));
|
||||||
|
|
||||||
if (d->dialog_id.get_type() == DialogType::User) {
|
if (d->dialog_id.get_type() == DialogType::User) {
|
||||||
td_->contacts_manager_->on_update_user_is_blocked(d->dialog_id.get_user_id(), is_blocked, is_blocked_for_stories);
|
td_->contacts_manager_->on_update_user_is_blocked(d->dialog_id.get_user_id(), is_blocked, is_blocked_for_stories);
|
||||||
@ -39916,7 +39926,8 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle_dialog_is_blocked_on_server(dialog_id, log_event.is_blocked_, event.id_);
|
toggle_dialog_is_blocked_on_server(dialog_id, log_event.is_blocked_, log_event.is_blocked_for_stories_,
|
||||||
|
event.id_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LogEvent::HandlerType::SaveDialogDraftMessageOnServer: {
|
case LogEvent::HandlerType::SaveDialogDraftMessageOnServer: {
|
||||||
|
@ -711,8 +711,8 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
Status toggle_dialog_is_translatable(DialogId dialog_id, bool is_translatable) TD_WARN_UNUSED_RESULT;
|
Status toggle_dialog_is_translatable(DialogId dialog_id, bool is_translatable) TD_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
Status toggle_message_sender_is_blocked(const td_api::object_ptr<td_api::MessageSender> &sender,
|
Status set_message_sender_block_list(const td_api::object_ptr<td_api::MessageSender> &sender,
|
||||||
bool is_blocked) TD_WARN_UNUSED_RESULT;
|
const td_api::object_ptr<td_api::BlockList> &block_list) TD_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
Status toggle_dialog_silent_send_message(DialogId dialog_id, bool silent_send_message) TD_WARN_UNUSED_RESULT;
|
Status toggle_dialog_silent_send_message(DialogId dialog_id, bool silent_send_message) TD_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
@ -2636,7 +2636,8 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
void toggle_dialog_is_translatable_on_server(DialogId dialog_id, bool is_translatable, uint64 log_event_id);
|
void toggle_dialog_is_translatable_on_server(DialogId dialog_id, bool is_translatable, uint64 log_event_id);
|
||||||
|
|
||||||
void toggle_dialog_is_blocked_on_server(DialogId dialog_id, bool is_blocked, uint64 log_event_id);
|
void toggle_dialog_is_blocked_on_server(DialogId dialog_id, bool is_blocked, bool is_blocked_for_stories,
|
||||||
|
uint64 log_event_id);
|
||||||
|
|
||||||
void reorder_pinned_dialogs_on_server(FolderId folder_id, const vector<DialogId> &dialog_ids, uint64 log_event_id);
|
void reorder_pinned_dialogs_on_server(FolderId folder_id, const vector<DialogId> &dialog_ids, uint64 log_event_id);
|
||||||
|
|
||||||
@ -3241,7 +3242,8 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
static uint64 save_toggle_dialog_is_translatable_on_server_log_event(DialogId dialog_id, bool is_translatable);
|
static uint64 save_toggle_dialog_is_translatable_on_server_log_event(DialogId dialog_id, bool is_translatable);
|
||||||
|
|
||||||
static uint64 save_toggle_dialog_is_blocked_on_server_log_event(DialogId dialog_id, bool is_blocked);
|
static uint64 save_toggle_dialog_is_blocked_on_server_log_event(DialogId dialog_id, bool is_blocked,
|
||||||
|
bool is_blocked_for_stories);
|
||||||
|
|
||||||
static uint64 save_read_message_contents_on_server_log_event(DialogId dialog_id,
|
static uint64 save_read_message_contents_on_server_log_event(DialogId dialog_id,
|
||||||
const vector<MessageId> &message_ids);
|
const vector<MessageId> &message_ids);
|
||||||
|
@ -6424,9 +6424,9 @@ void Td::on_request(uint64 id, const td_api::toggleChatIsMarkedAsUnread &request
|
|||||||
request.is_marked_as_unread_));
|
request.is_marked_as_unread_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::toggleMessageSenderIsBlocked &request) {
|
void Td::on_request(uint64 id, const td_api::setMessageSenderBlockList &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
answer_ok_query(id, messages_manager_->toggle_message_sender_is_blocked(request.sender_id_, request.is_blocked_));
|
answer_ok_query(id, messages_manager_->set_message_sender_block_list(request.sender_id_, request.block_list_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::toggleChatDefaultDisableNotification &request) {
|
void Td::on_request(uint64 id, const td_api::toggleChatDefaultDisableNotification &request) {
|
||||||
|
@ -1001,7 +1001,7 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::toggleChatIsMarkedAsUnread &request);
|
void on_request(uint64 id, const td_api::toggleChatIsMarkedAsUnread &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::toggleMessageSenderIsBlocked &request);
|
void on_request(uint64 id, const td_api::setMessageSenderBlockList &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::toggleChatDefaultDisableNotification &request);
|
void on_request(uint64 id, const td_api::toggleChatDefaultDisableNotification &request);
|
||||||
|
|
||||||
|
@ -505,15 +505,25 @@ class CliClient final : public Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static td_api::object_ptr<td_api::StoryList> as_story_list(string story_list) {
|
static td_api::object_ptr<td_api::StoryList> as_story_list(string story_list) {
|
||||||
if (!story_list.empty() && story_list.back() == 'a') {
|
if (story_list.empty() || story_list.back() == 'e') {
|
||||||
return td_api::make_object<td_api::storyListArchive>();
|
|
||||||
}
|
|
||||||
if (!story_list.empty() && story_list.back() == 'e') {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
if (story_list.back() == 'a') {
|
||||||
|
return td_api::make_object<td_api::storyListArchive>();
|
||||||
|
}
|
||||||
return td_api::make_object<td_api::storyListMain>();
|
return td_api::make_object<td_api::storyListMain>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static td_api::object_ptr<td_api::BlockList> as_block_list(string block_list) {
|
||||||
|
if (block_list.empty()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (block_list.back() == 's') {
|
||||||
|
return td_api::make_object<td_api::blockListStories>();
|
||||||
|
}
|
||||||
|
return td_api::make_object<td_api::blockListMain>();
|
||||||
|
}
|
||||||
|
|
||||||
vector<int64> as_chat_ids(Slice chat_ids) const {
|
vector<int64> as_chat_ids(Slice chat_ids) const {
|
||||||
return transform(autosplit(chat_ids), [this](Slice str) { return as_chat_id(str); });
|
return transform(autosplit(chat_ids), [this](Slice str) { return as_chat_id(str); });
|
||||||
}
|
}
|
||||||
@ -3996,11 +4006,12 @@ class CliClient final : public Actor {
|
|||||||
bool is_translatable;
|
bool is_translatable;
|
||||||
get_args(args, chat_id, is_translatable);
|
get_args(args, chat_id, is_translatable);
|
||||||
send_request(td_api::make_object<td_api::toggleChatIsTranslatable>(chat_id, is_translatable));
|
send_request(td_api::make_object<td_api::toggleChatIsTranslatable>(chat_id, is_translatable));
|
||||||
} else if (op == "tmsib") {
|
} else if (op == "smsbl") {
|
||||||
string sender_id;
|
string sender_id;
|
||||||
bool is_blocked;
|
string block_list;
|
||||||
get_args(args, sender_id, is_blocked);
|
get_args(args, sender_id, block_list);
|
||||||
send_request(td_api::make_object<td_api::toggleMessageSenderIsBlocked>(as_message_sender(sender_id), is_blocked));
|
send_request(td_api::make_object<td_api::setMessageSenderBlockList>(as_message_sender(sender_id),
|
||||||
|
as_block_list(block_list)));
|
||||||
} else if (op == "bmsfr") {
|
} else if (op == "bmsfr") {
|
||||||
MessageId message_id;
|
MessageId message_id;
|
||||||
bool delete_message;
|
bool delete_message;
|
||||||
|
Loading…
Reference in New Issue
Block a user