Add separate BusinessBotManageBar.
This commit is contained in:
parent
e7ff4688fc
commit
7aad37608f
@ -304,6 +304,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/BotMenuButton.cpp
|
||||
td/telegram/BusinessAwayMessage.cpp
|
||||
td/telegram/BusinessAwayMessageSchedule.cpp
|
||||
td/telegram/BusinessBotManageBar.cpp
|
||||
td/telegram/BusinessConnectedBot.cpp
|
||||
td/telegram/BusinessConnectionManager.cpp
|
||||
td/telegram/BusinessGreetingMessage.cpp
|
||||
@ -597,6 +598,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/BotMenuButton.h
|
||||
td/telegram/BusinessAwayMessage.h
|
||||
td/telegram/BusinessAwayMessageSchedule.h
|
||||
td/telegram/BusinessBotManageBar.h
|
||||
td/telegram/BusinessConnectedBot.h
|
||||
td/telegram/BusinessConnectionId.h
|
||||
td/telegram/BusinessConnectionManager.h
|
||||
|
@ -1782,6 +1782,14 @@ savedMessagesTag tag:ReactionType label:string count:int32 = SavedMessagesTag;
|
||||
savedMessagesTags tags:vector<savedMessagesTag> = SavedMessagesTags;
|
||||
|
||||
|
||||
//@description Contains information about a business bot that manages the chat
|
||||
//@bot_user_id User identifier of the bot
|
||||
//@manage_url URL to be opened to manage the bot
|
||||
//@is_bot_paused True, if the bot is paused. Use toggleBusinessConnectedBotChatIsPaused to change the value of the field
|
||||
//@can_bot_reply True, if the bot can reply
|
||||
businessBotManageBar bot_user_id:int53 manage_url:string is_bot_paused:Bool can_bot_reply:Bool = BusinessBotManageBar;
|
||||
|
||||
|
||||
//@description Describes a video chat
|
||||
//@group_call_id Group call identifier of an active video chat; 0 if none. Full information about the video chat can be received through the method getGroupCall
|
||||
//@has_participants True, if the video chat has participants
|
||||
@ -1825,12 +1833,13 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
|
||||
//@background Background set for the chat; may be null if none
|
||||
//@theme_name If non-empty, name of a theme, set for the chat
|
||||
//@action_bar Information about actions which must be possible to do through the chat action bar; may be null if none
|
||||
//@business_bot_manage_bar Information about bar for managing a business bot in the chat; may be null if none
|
||||
//@video_chat Information about video chat of the chat
|
||||
//@pending_join_requests Information about pending join requests; may be null if none
|
||||
//@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
|
||||
//@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 accent_color_id:int32 background_custom_emoji_id:int64 profile_accent_color_id:int32 profile_background_custom_emoji_id:int64 permissions:chatPermissions last_message:message positions:vector<chatPosition> chat_lists:vector<ChatList> message_sender_id:MessageSender block_list:BlockList has_protected_content:Bool is_translatable:Bool is_marked_as_unread:Bool view_as_topics: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 emoji_status:emojiStatus 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 accent_color_id:int32 background_custom_emoji_id:int64 profile_accent_color_id:int32 profile_background_custom_emoji_id:int64 permissions:chatPermissions last_message:message positions:vector<chatPosition> chat_lists:vector<ChatList> message_sender_id:MessageSender block_list:BlockList has_protected_content:Bool is_translatable:Bool is_marked_as_unread:Bool view_as_topics: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 emoji_status:emojiStatus background:chatBackground theme_name:string action_bar:ChatActionBar business_bot_manage_bar:businessBotManageBar 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
|
||||
chats total_count:int32 chat_ids:vector<int53> = Chats;
|
||||
@ -1882,13 +1891,6 @@ chatActionBarSharePhoneNumber = ChatActionBar;
|
||||
//@request_date Point in time (Unix timestamp) when the join request was sent
|
||||
chatActionBarJoinRequest title:string is_channel:Bool request_date:int32 = ChatActionBar;
|
||||
|
||||
//@description The chat is a private chat administered by a business bot
|
||||
//@bot_user_id User identifier of the bot
|
||||
//@manage_url URL to be opened to manage the bot
|
||||
//@is_bot_paused True, if the bot is paused. Use toggleBusinessConnectedBotChatIsPaused to change the value of the field
|
||||
//@can_bot_reply True, if the bot can reply
|
||||
chatActionBarManageBusinessBot bot_user_id:int53 manage_url:string is_bot_paused:Bool can_bot_reply:Bool = ChatActionBar;
|
||||
|
||||
|
||||
//@class KeyboardButtonType @description Describes a keyboard button type
|
||||
|
||||
@ -6788,6 +6790,9 @@ updateChatReadOutbox chat_id:int53 last_read_outbox_message_id:int53 = Update;
|
||||
//@description The chat action bar was changed @chat_id Chat identifier @action_bar The new value of the action bar; may be null
|
||||
updateChatActionBar chat_id:int53 action_bar:ChatActionBar = Update;
|
||||
|
||||
//@description The bar for managing business bot was changed in a chat @chat_id Chat identifier @business_bot_manage_bar The new value of the business bot manage bar; may be null
|
||||
updateChatBusinessBotManageBar chat_id:int53 business_bot_manage_bar:businessBotManageBar = Update;
|
||||
|
||||
//@description The chat available reactions were changed @chat_id Chat identifier @available_reactions The new reactions, available in the chat
|
||||
updateChatAvailableReactions chat_id:int53 available_reactions:ChatAvailableReactions = Update;
|
||||
|
||||
|
94
td/telegram/BusinessBotManageBar.cpp
Normal file
94
td/telegram/BusinessBotManageBar.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// 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/BusinessBotManageBar.h"
|
||||
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
unique_ptr<BusinessBotManageBar> BusinessBotManageBar::create(bool is_business_bot_paused, bool can_business_bot_reply,
|
||||
UserId business_bot_user_id,
|
||||
string business_bot_manage_url) {
|
||||
auto action_bar = make_unique<BusinessBotManageBar>();
|
||||
action_bar->is_business_bot_paused_ = is_business_bot_paused;
|
||||
action_bar->can_business_bot_reply_ = can_business_bot_reply;
|
||||
action_bar->business_bot_user_id_ = business_bot_user_id;
|
||||
action_bar->business_bot_manage_url_ = std::move(business_bot_manage_url);
|
||||
if (action_bar->is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
return action_bar;
|
||||
}
|
||||
|
||||
bool BusinessBotManageBar::is_empty() const {
|
||||
return !business_bot_user_id_.is_valid();
|
||||
}
|
||||
|
||||
void BusinessBotManageBar::fix(DialogId dialog_id) {
|
||||
bool is_valid = business_bot_user_id_.is_valid()
|
||||
? dialog_id.get_type() == DialogType::User && !business_bot_manage_url_.empty()
|
||||
: business_bot_manage_url_.empty() && !is_business_bot_paused_ && !can_business_bot_reply_;
|
||||
if (!is_valid) {
|
||||
LOG(ERROR) << "Receive business bot " << business_bot_user_id_ << " in " << dialog_id << " with manage URL "
|
||||
<< business_bot_manage_url_;
|
||||
*this = {};
|
||||
}
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::businessBotManageBar> BusinessBotManageBar::get_business_bot_manage_bar_object(
|
||||
Td *td) const {
|
||||
if (is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::businessBotManageBar>(
|
||||
td->user_manager_->get_user_id_object(business_bot_user_id_, "businessBotManageBar"), business_bot_manage_url_,
|
||||
is_business_bot_paused_, can_business_bot_reply_);
|
||||
}
|
||||
|
||||
bool BusinessBotManageBar::on_user_deleted() {
|
||||
if (is_empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*this = {};
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BusinessBotManageBar::set_business_bot_is_paused(bool is_paused) {
|
||||
if (!business_bot_user_id_.is_valid() || is_business_bot_paused_ == is_paused) {
|
||||
return false;
|
||||
}
|
||||
is_business_bot_paused_ = is_paused;
|
||||
return true;
|
||||
}
|
||||
|
||||
void BusinessBotManageBar::add_dependencies(Dependencies &dependencies) const {
|
||||
dependencies.add(business_bot_user_id_);
|
||||
}
|
||||
|
||||
bool operator==(const unique_ptr<BusinessBotManageBar> &lhs, const unique_ptr<BusinessBotManageBar> &rhs) {
|
||||
if (lhs == nullptr) {
|
||||
return rhs == nullptr;
|
||||
}
|
||||
if (rhs == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return lhs->business_bot_user_id_ == rhs->business_bot_user_id_ &&
|
||||
lhs->business_bot_manage_url_ == rhs->business_bot_manage_url_ &&
|
||||
lhs->is_business_bot_paused_ == rhs->is_business_bot_paused_ &&
|
||||
lhs->can_business_bot_reply_ == rhs->can_business_bot_reply_;
|
||||
}
|
||||
|
||||
bool operator!=(const unique_ptr<BusinessBotManageBar> &lhs, const unique_ptr<BusinessBotManageBar> &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
} // namespace td
|
86
td/telegram/BusinessBotManageBar.h
Normal file
86
td/telegram/BusinessBotManageBar.h
Normal file
@ -0,0 +1,86 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// 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/DialogId.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
class Dependencies;
|
||||
class Td;
|
||||
|
||||
class BusinessBotManageBar {
|
||||
UserId business_bot_user_id_;
|
||||
string business_bot_manage_url_;
|
||||
bool is_business_bot_paused_ = false;
|
||||
bool can_business_bot_reply_ = false;
|
||||
|
||||
friend bool operator==(const unique_ptr<BusinessBotManageBar> &lhs, const unique_ptr<BusinessBotManageBar> &rhs);
|
||||
|
||||
public:
|
||||
static unique_ptr<BusinessBotManageBar> create(bool is_business_bot_paused, bool can_business_bot_reply,
|
||||
UserId business_bot_user_id, string business_bot_manage_url);
|
||||
|
||||
bool is_empty() const;
|
||||
|
||||
void fix(DialogId dialog_id);
|
||||
|
||||
td_api::object_ptr<td_api::businessBotManageBar> get_business_bot_manage_bar_object(Td *td) const;
|
||||
|
||||
bool on_user_deleted();
|
||||
|
||||
bool set_business_bot_is_paused(bool is_paused);
|
||||
|
||||
void add_dependencies(Dependencies &dependencies) const;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
bool has_business_bot_user_id = business_bot_user_id_.is_valid();
|
||||
bool has_business_bot_manage_url = !business_bot_manage_url_.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(is_business_bot_paused_);
|
||||
STORE_FLAG(can_business_bot_reply_);
|
||||
STORE_FLAG(has_business_bot_user_id);
|
||||
STORE_FLAG(has_business_bot_manage_url);
|
||||
END_STORE_FLAGS();
|
||||
if (has_business_bot_user_id) {
|
||||
td::store(business_bot_user_id_, storer);
|
||||
}
|
||||
if (has_business_bot_manage_url) {
|
||||
td::store(business_bot_manage_url_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser) {
|
||||
bool has_business_bot_user_id;
|
||||
bool has_business_bot_manage_url;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(is_business_bot_paused_);
|
||||
PARSE_FLAG(can_business_bot_reply_);
|
||||
PARSE_FLAG(has_business_bot_user_id);
|
||||
PARSE_FLAG(has_business_bot_manage_url);
|
||||
END_PARSE_FLAGS();
|
||||
if (has_business_bot_user_id) {
|
||||
td::parse(business_bot_user_id_, parser);
|
||||
}
|
||||
if (has_business_bot_manage_url) {
|
||||
td::parse(business_bot_manage_url_, parser);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bool operator==(const unique_ptr<BusinessBotManageBar> &lhs, const unique_ptr<BusinessBotManageBar> &rhs);
|
||||
|
||||
bool operator!=(const unique_ptr<BusinessBotManageBar> &lhs, const unique_ptr<BusinessBotManageBar> &rhs);
|
||||
|
||||
} // namespace td
|
@ -7,7 +7,6 @@
|
||||
#include "td/telegram/DialogActionBar.h"
|
||||
|
||||
#include "td/telegram/ChatManager.h"
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserManager.h"
|
||||
|
||||
@ -19,9 +18,7 @@ unique_ptr<DialogActionBar> DialogActionBar::create(bool can_report_spam, bool c
|
||||
bool can_share_phone_number, bool can_report_location,
|
||||
bool can_unarchive, int32 distance, bool can_invite_members,
|
||||
string join_request_dialog_title, bool is_join_request_broadcast,
|
||||
int32 join_request_date, bool is_business_bot_paused,
|
||||
bool can_business_bot_reply, UserId business_bot_user_id,
|
||||
string business_bot_manage_url) {
|
||||
int32 join_request_date) {
|
||||
auto action_bar = make_unique<DialogActionBar>();
|
||||
action_bar->can_report_spam_ = can_report_spam;
|
||||
action_bar->can_add_contact_ = can_add_contact;
|
||||
@ -34,10 +31,6 @@ unique_ptr<DialogActionBar> DialogActionBar::create(bool can_report_spam, bool c
|
||||
action_bar->join_request_dialog_title_ = std::move(join_request_dialog_title);
|
||||
action_bar->is_join_request_broadcast_ = is_join_request_broadcast;
|
||||
action_bar->join_request_date_ = join_request_date;
|
||||
action_bar->is_business_bot_paused_ = is_business_bot_paused;
|
||||
action_bar->can_business_bot_reply_ = can_business_bot_reply;
|
||||
action_bar->business_bot_user_id_ = business_bot_user_id;
|
||||
action_bar->business_bot_manage_url_ = std::move(business_bot_manage_url);
|
||||
if (action_bar->is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -46,8 +39,7 @@ unique_ptr<DialogActionBar> DialogActionBar::create(bool can_report_spam, bool c
|
||||
|
||||
bool DialogActionBar::is_empty() const {
|
||||
return !can_report_spam_ && !can_add_contact_ && !can_block_user_ && !can_share_phone_number_ &&
|
||||
!can_report_location_ && !can_invite_members_ && join_request_dialog_title_.empty() &&
|
||||
!business_bot_user_id_.is_valid();
|
||||
!can_report_location_ && !can_invite_members_ && join_request_dialog_title_.empty();
|
||||
}
|
||||
|
||||
void DialogActionBar::fix(Td *td, DialogId dialog_id, bool is_dialog_blocked, FolderId folder_id) {
|
||||
@ -57,22 +49,6 @@ void DialogActionBar::fix(Td *td, DialogId dialog_id, bool is_dialog_blocked, Fo
|
||||
distance_ = -1;
|
||||
}
|
||||
|
||||
if (business_bot_user_id_.is_valid()) {
|
||||
if (dialog_type != DialogType::User || business_bot_manage_url_.empty()) {
|
||||
LOG(ERROR) << "Receive business bot " << business_bot_user_id_ << " in " << dialog_id << " with manage URL "
|
||||
<< business_bot_manage_url_;
|
||||
business_bot_user_id_ = {};
|
||||
business_bot_manage_url_ = {};
|
||||
is_business_bot_paused_ = false;
|
||||
can_business_bot_reply_ = false;
|
||||
}
|
||||
} else if (!business_bot_manage_url_.empty() || is_business_bot_paused_ || can_business_bot_reply_) {
|
||||
LOG(ERROR) << "Receive business bot " << business_bot_user_id_ << " in " << dialog_id << " with manage URL "
|
||||
<< business_bot_manage_url_;
|
||||
business_bot_manage_url_ = {};
|
||||
is_business_bot_paused_ = false;
|
||||
can_business_bot_reply_ = false;
|
||||
}
|
||||
if (!join_request_dialog_title_.empty()) {
|
||||
if (dialog_type != DialogType::User || join_request_date_ <= 0) {
|
||||
LOG(ERROR) << "Receive join_request_date = " << join_request_date_ << " in " << dialog_id;
|
||||
@ -204,7 +180,7 @@ void DialogActionBar::fix(Td *td, DialogId dialog_id, bool is_dialog_blocked, Fo
|
||||
}
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::ChatActionBar> DialogActionBar::get_chat_action_bar_object(Td *td, DialogType dialog_type,
|
||||
td_api::object_ptr<td_api::ChatActionBar> DialogActionBar::get_chat_action_bar_object(DialogType dialog_type,
|
||||
bool hide_unarchive) const {
|
||||
if (!join_request_dialog_title_.empty()) {
|
||||
CHECK(dialog_type == DialogType::User);
|
||||
@ -248,12 +224,6 @@ td_api::object_ptr<td_api::ChatActionBar> DialogActionBar::get_chat_action_bar_o
|
||||
if (can_report_spam_) {
|
||||
return td_api::make_object<td_api::chatActionBarReportSpam>(can_unarchive_);
|
||||
}
|
||||
if (business_bot_user_id_.is_valid()) {
|
||||
CHECK(dialog_type == DialogType::User);
|
||||
return td_api::make_object<td_api::chatActionBarManageBusinessBot>(
|
||||
td->user_manager_->get_user_id_object(business_bot_user_id_, "chatActionBarManageBusinessBot"),
|
||||
business_bot_manage_url_, is_business_bot_paused_, can_business_bot_reply_);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -282,15 +252,11 @@ bool DialogActionBar::on_user_contact_added() {
|
||||
}
|
||||
|
||||
bool DialogActionBar::on_user_deleted() {
|
||||
if (!business_bot_user_id_.is_valid() && join_request_dialog_title_.empty() && !can_share_phone_number_ &&
|
||||
!can_block_user_ && !can_add_contact_ && distance_ < 0) {
|
||||
if (join_request_dialog_title_.empty() && !can_share_phone_number_ && !can_block_user_ && !can_add_contact_ &&
|
||||
distance_ < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
business_bot_user_id_ = {};
|
||||
business_bot_manage_url_.clear();
|
||||
is_business_bot_paused_ = false;
|
||||
can_business_bot_reply_ = false;
|
||||
join_request_dialog_title_.clear();
|
||||
is_join_request_broadcast_ = false;
|
||||
join_request_date_ = 0;
|
||||
@ -310,18 +276,6 @@ bool DialogActionBar::on_outgoing_message() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DialogActionBar::set_business_bot_is_paused(bool is_paused) {
|
||||
if (!business_bot_user_id_.is_valid() || is_business_bot_paused_ == is_paused) {
|
||||
return false;
|
||||
}
|
||||
is_business_bot_paused_ = is_paused;
|
||||
return true;
|
||||
}
|
||||
|
||||
void DialogActionBar::add_dependencies(Dependencies &dependencies) const {
|
||||
dependencies.add(business_bot_user_id_);
|
||||
}
|
||||
|
||||
bool operator==(const unique_ptr<DialogActionBar> &lhs, const unique_ptr<DialogActionBar> &rhs) {
|
||||
if (lhs == nullptr) {
|
||||
return rhs == nullptr;
|
||||
@ -335,11 +289,7 @@ bool operator==(const unique_ptr<DialogActionBar> &lhs, const unique_ptr<DialogA
|
||||
lhs->distance_ == rhs->distance_ && lhs->can_invite_members_ == rhs->can_invite_members_ &&
|
||||
lhs->join_request_dialog_title_ == rhs->join_request_dialog_title_ &&
|
||||
lhs->is_join_request_broadcast_ == lhs->is_join_request_broadcast_ &&
|
||||
lhs->join_request_date_ == rhs->join_request_date_ &&
|
||||
lhs->business_bot_user_id_ == rhs->business_bot_user_id_ &&
|
||||
lhs->business_bot_manage_url_ == rhs->business_bot_manage_url_ &&
|
||||
lhs->is_business_bot_paused_ == rhs->is_business_bot_paused_ &&
|
||||
lhs->can_business_bot_reply_ == rhs->can_business_bot_reply_;
|
||||
lhs->join_request_date_ == rhs->join_request_date_;
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -15,15 +15,12 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class Dependencies;
|
||||
class Td;
|
||||
|
||||
class DialogActionBar {
|
||||
int32 distance_ = -1; // distance to the peer
|
||||
int32 join_request_date_ = 0;
|
||||
string join_request_dialog_title_;
|
||||
UserId business_bot_user_id_;
|
||||
string business_bot_manage_url_;
|
||||
|
||||
bool can_report_spam_ = false;
|
||||
bool can_add_contact_ = false;
|
||||
@ -33,8 +30,6 @@ class DialogActionBar {
|
||||
bool can_unarchive_ = false;
|
||||
bool can_invite_members_ = false;
|
||||
bool is_join_request_broadcast_ = false;
|
||||
bool is_business_bot_paused_ = false;
|
||||
bool can_business_bot_reply_ = false;
|
||||
|
||||
friend bool operator==(const unique_ptr<DialogActionBar> &lhs, const unique_ptr<DialogActionBar> &rhs);
|
||||
|
||||
@ -42,9 +37,7 @@ class DialogActionBar {
|
||||
static unique_ptr<DialogActionBar> create(bool can_report_spam, bool can_add_contact, bool can_block_user,
|
||||
bool can_share_phone_number, bool can_report_location, bool can_unarchive,
|
||||
int32 distance, bool can_invite_members, string join_request_dialog_title,
|
||||
bool is_join_request_broadcast, int32 join_request_date,
|
||||
bool is_business_bot_paused, bool can_business_bot_reply,
|
||||
UserId business_bot_user_id, string business_bot_manage_url);
|
||||
bool is_join_request_broadcast, int32 join_request_date);
|
||||
|
||||
bool is_empty() const;
|
||||
|
||||
@ -56,7 +49,7 @@ class DialogActionBar {
|
||||
return can_unarchive_;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::ChatActionBar> get_chat_action_bar_object(Td *td, DialogType dialog_type,
|
||||
td_api::object_ptr<td_api::ChatActionBar> get_chat_action_bar_object(DialogType dialog_type,
|
||||
bool hide_unarchive) const;
|
||||
|
||||
void fix(Td *td, DialogId dialog_id, bool is_dialog_blocked, FolderId folder_id);
|
||||
@ -69,16 +62,10 @@ class DialogActionBar {
|
||||
|
||||
bool on_outgoing_message();
|
||||
|
||||
bool set_business_bot_is_paused(bool is_paused);
|
||||
|
||||
void add_dependencies(Dependencies &dependencies) const;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
bool has_distance = distance_ >= 0;
|
||||
bool has_join_request = !join_request_dialog_title_.empty();
|
||||
bool has_business_bot_user_id = business_bot_user_id_.is_valid();
|
||||
bool has_business_bot_manage_url = !business_bot_manage_url_.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(can_report_spam_);
|
||||
STORE_FLAG(can_add_contact_);
|
||||
@ -90,10 +77,6 @@ class DialogActionBar {
|
||||
STORE_FLAG(has_distance);
|
||||
STORE_FLAG(is_join_request_broadcast_);
|
||||
STORE_FLAG(has_join_request);
|
||||
STORE_FLAG(is_business_bot_paused_);
|
||||
STORE_FLAG(can_business_bot_reply_);
|
||||
STORE_FLAG(has_business_bot_user_id);
|
||||
STORE_FLAG(has_business_bot_manage_url);
|
||||
END_STORE_FLAGS();
|
||||
if (has_distance) {
|
||||
td::store(distance_, storer);
|
||||
@ -102,20 +85,12 @@ class DialogActionBar {
|
||||
td::store(join_request_dialog_title_, storer);
|
||||
td::store(join_request_date_, storer);
|
||||
}
|
||||
if (has_business_bot_user_id) {
|
||||
td::store(business_bot_user_id_, storer);
|
||||
}
|
||||
if (has_business_bot_manage_url) {
|
||||
td::store(business_bot_manage_url_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser) {
|
||||
bool has_distance;
|
||||
bool has_join_request;
|
||||
bool has_business_bot_user_id;
|
||||
bool has_business_bot_manage_url;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(can_report_spam_);
|
||||
PARSE_FLAG(can_add_contact_);
|
||||
@ -127,10 +102,6 @@ class DialogActionBar {
|
||||
PARSE_FLAG(has_distance);
|
||||
PARSE_FLAG(is_join_request_broadcast_);
|
||||
PARSE_FLAG(has_join_request);
|
||||
PARSE_FLAG(is_business_bot_paused_);
|
||||
PARSE_FLAG(can_business_bot_reply_);
|
||||
PARSE_FLAG(has_business_bot_user_id);
|
||||
PARSE_FLAG(has_business_bot_manage_url);
|
||||
END_PARSE_FLAGS();
|
||||
if (has_distance) {
|
||||
td::parse(distance_, parser);
|
||||
@ -139,12 +110,6 @@ class DialogActionBar {
|
||||
td::parse(join_request_dialog_title_, parser);
|
||||
td::parse(join_request_date_, parser);
|
||||
}
|
||||
if (has_business_bot_user_id) {
|
||||
td::parse(business_bot_user_id_, parser);
|
||||
}
|
||||
if (has_business_bot_manage_url) {
|
||||
td::parse(business_bot_manage_url_, parser);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/BackgroundInfo.hpp"
|
||||
#include "td/telegram/BlockListId.h"
|
||||
#include "td/telegram/BusinessBotManageBar.h"
|
||||
#include "td/telegram/ChainId.h"
|
||||
#include "td/telegram/ChannelType.h"
|
||||
#include "td/telegram/ChatManager.h"
|
||||
@ -4719,6 +4720,7 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
|
||||
bool has_available_reactions = !available_reactions.empty();
|
||||
bool has_history_generation = history_generation != 0;
|
||||
bool has_background = background_info.is_valid();
|
||||
bool has_business_bot_manage_bar = business_bot_manage_bar != nullptr;
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_draft_message);
|
||||
STORE_FLAG(has_last_database_message);
|
||||
@ -4812,6 +4814,7 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
|
||||
STORE_FLAG(is_view_as_messages_inited);
|
||||
STORE_FLAG(is_forum);
|
||||
STORE_FLAG(is_saved_messages_view_as_messages_inited);
|
||||
STORE_FLAG(has_business_bot_manage_bar);
|
||||
END_STORE_FLAGS();
|
||||
}
|
||||
|
||||
@ -4930,6 +4933,9 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
|
||||
if (has_background) {
|
||||
store(background_info, storer);
|
||||
}
|
||||
if (has_business_bot_manage_bar) {
|
||||
store(business_bot_manage_bar, storer);
|
||||
}
|
||||
}
|
||||
|
||||
// do not forget to resolve dialog dependencies including dependencies of last_message
|
||||
@ -4981,6 +4987,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
|
||||
bool has_available_reactions = false;
|
||||
bool has_history_generation = false;
|
||||
bool has_background = false;
|
||||
bool has_business_bot_manage_bar = false;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_draft_message);
|
||||
PARSE_FLAG(has_last_database_message);
|
||||
@ -5089,6 +5096,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
|
||||
PARSE_FLAG(is_view_as_messages_inited);
|
||||
PARSE_FLAG(is_forum);
|
||||
PARSE_FLAG(is_saved_messages_view_as_messages_inited);
|
||||
PARSE_FLAG(has_business_bot_manage_bar);
|
||||
END_PARSE_FLAGS();
|
||||
} else {
|
||||
need_repair_action_bar = false;
|
||||
@ -5260,14 +5268,16 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
|
||||
if (has_background) {
|
||||
parse(background_info, parser);
|
||||
}
|
||||
if (has_business_bot_manage_bar) {
|
||||
parse(business_bot_manage_bar, parser);
|
||||
}
|
||||
|
||||
(void)legacy_know_can_report_spam;
|
||||
if (know_action_bar && !has_action_bar) {
|
||||
action_bar =
|
||||
DialogActionBar::create(action_bar_can_report_spam, action_bar_can_add_contact, action_bar_can_block_user,
|
||||
action_bar_can_share_phone_number, action_bar_can_report_location,
|
||||
action_bar_can_unarchive, has_outgoing_messages ? -1 : action_bar_distance,
|
||||
action_bar_can_invite_members, string(), false, 0, false, false, UserId(), string());
|
||||
action_bar = DialogActionBar::create(
|
||||
action_bar_can_report_spam, action_bar_can_add_contact, action_bar_can_block_user,
|
||||
action_bar_can_share_phone_number, action_bar_can_report_location, action_bar_can_unarchive,
|
||||
has_outgoing_messages ? -1 : action_bar_distance, action_bar_can_invite_members, string(), false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7956,17 +7966,25 @@ void MessagesManager::on_get_peer_settings(DialogId dialog_id,
|
||||
return;
|
||||
}
|
||||
|
||||
auto business_bot_manage_bar = BusinessBotManageBar::create(
|
||||
peer_settings->business_bot_paused_, peer_settings->business_bot_can_reply_,
|
||||
UserId(peer_settings->business_bot_id_), std::move(peer_settings->business_bot_manage_url_));
|
||||
fix_dialog_business_bot_manage_bar(dialog_id, business_bot_manage_bar.get());
|
||||
if (d->business_bot_manage_bar != business_bot_manage_bar) {
|
||||
d->business_bot_manage_bar = std::move(business_bot_manage_bar);
|
||||
send_update_chat_business_bot_manage_bar(d);
|
||||
}
|
||||
|
||||
auto distance =
|
||||
(peer_settings->flags_ & telegram_api::peerSettings::GEO_DISTANCE_MASK) != 0 ? peer_settings->geo_distance_ : -1;
|
||||
if (distance < -1 || d->has_outgoing_messages) {
|
||||
distance = -1;
|
||||
}
|
||||
auto action_bar = DialogActionBar::create(
|
||||
peer_settings->report_spam_, peer_settings->add_contact_, peer_settings->block_contact_,
|
||||
peer_settings->share_contact_, peer_settings->report_geo_, peer_settings->autoarchived_, distance,
|
||||
peer_settings->invite_members_, peer_settings->request_chat_title_, peer_settings->request_chat_broadcast_,
|
||||
peer_settings->request_chat_date_, peer_settings->business_bot_paused_, peer_settings->business_bot_can_reply_,
|
||||
UserId(peer_settings->business_bot_id_), std::move(peer_settings->business_bot_manage_url_));
|
||||
auto action_bar =
|
||||
DialogActionBar::create(peer_settings->report_spam_, peer_settings->add_contact_, peer_settings->block_contact_,
|
||||
peer_settings->share_contact_, peer_settings->report_geo_, peer_settings->autoarchived_,
|
||||
distance, peer_settings->invite_members_, peer_settings->request_chat_title_,
|
||||
peer_settings->request_chat_broadcast_, peer_settings->request_chat_date_);
|
||||
|
||||
fix_dialog_action_bar(d, action_bar.get());
|
||||
|
||||
@ -7995,6 +8013,15 @@ void MessagesManager::fix_dialog_action_bar(const Dialog *d, DialogActionBar *ac
|
||||
action_bar->fix(td_, d->dialog_id, d->is_blocked, d->folder_id);
|
||||
}
|
||||
|
||||
void MessagesManager::fix_dialog_business_bot_manage_bar(DialogId dialog_id,
|
||||
BusinessBotManageBar *business_bot_manage_bar) {
|
||||
if (business_bot_manage_bar == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
business_bot_manage_bar->fix(dialog_id);
|
||||
}
|
||||
|
||||
Result<string> MessagesManager::get_login_button_url(MessageFullId message_full_id, int64 button_id) {
|
||||
Dialog *d = get_dialog_force(message_full_id.get_dialog_id(), "get_login_button_url");
|
||||
if (d == nullptr) {
|
||||
@ -19222,13 +19249,22 @@ td_api::object_ptr<td_api::ChatActionBar> MessagesManager::get_chat_action_bar_o
|
||||
if (user_d == nullptr || user_d->action_bar == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return user_d->action_bar->get_chat_action_bar_object(td_, DialogType::User, d->folder_id != FolderId::archive());
|
||||
return user_d->action_bar->get_chat_action_bar_object(DialogType::User, d->folder_id != FolderId::archive());
|
||||
}
|
||||
|
||||
if (d->action_bar == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return d->action_bar->get_chat_action_bar_object(td_, dialog_type, false);
|
||||
return d->action_bar->get_chat_action_bar_object(dialog_type, false);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::businessBotManageBar> MessagesManager::get_business_bot_manage_bar_object(
|
||||
const Dialog *d) const {
|
||||
CHECK(d != nullptr);
|
||||
if (d->business_bot_manage_bar == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return d->business_bot_manage_bar->get_business_bot_manage_bar_object(td_);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chatBackground> MessagesManager::get_chat_background_object(const Dialog *d) const {
|
||||
@ -19321,9 +19357,9 @@ td_api::object_ptr<td_api::chat> MessagesManager::get_chat_object(const Dialog *
|
||||
d->unread_reaction_count, get_chat_notification_settings_object(&d->notification_settings),
|
||||
std::move(available_reactions), d->message_ttl.get_message_auto_delete_time_object(),
|
||||
td_->dialog_manager_->get_dialog_emoji_status_object(d->dialog_id), get_chat_background_object(d),
|
||||
get_dialog_theme_name(d), get_chat_action_bar_object(d), get_video_chat_object(d),
|
||||
get_chat_join_requests_info_object(d), d->reply_markup_message_id.get(), std::move(draft_message),
|
||||
d->client_data);
|
||||
get_dialog_theme_name(d), get_chat_action_bar_object(d), get_business_bot_manage_bar_object(d),
|
||||
get_video_chat_object(d), get_chat_join_requests_info_object(d), d->reply_markup_message_id.get(),
|
||||
std::move(draft_message), d->client_data);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chat> MessagesManager::get_chat_object(DialogId dialog_id, const char *source) {
|
||||
@ -29003,6 +29039,23 @@ void MessagesManager::send_update_chat_action_bar(Dialog *d) {
|
||||
send_update_secret_chats_with_user_action_bar(d);
|
||||
}
|
||||
|
||||
void MessagesManager::send_update_chat_business_bot_manage_bar(Dialog *d) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return;
|
||||
}
|
||||
if (d->business_bot_manage_bar != nullptr && d->business_bot_manage_bar->is_empty()) {
|
||||
d->business_bot_manage_bar = nullptr;
|
||||
}
|
||||
|
||||
CHECK(d != nullptr);
|
||||
LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_business_bot_manage_bar";
|
||||
on_dialog_updated(d->dialog_id, "send_update_chat_business_bot_manage_bar");
|
||||
send_closure(
|
||||
G()->td(), &Td::send_update,
|
||||
td_api::make_object<td_api::updateChatBusinessBotManageBar>(
|
||||
get_chat_id_object(d->dialog_id, "updateChatBusinessBotManageBar"), get_business_bot_manage_bar_object(d)));
|
||||
}
|
||||
|
||||
void MessagesManager::send_update_chat_available_reactions(const Dialog *d) {
|
||||
CHECK(d != nullptr);
|
||||
LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_available_reactions";
|
||||
@ -30252,10 +30305,10 @@ void MessagesManager::set_dialog_is_blocked(Dialog *d, bool is_blocked, bool is_
|
||||
}
|
||||
|
||||
void MessagesManager::on_update_dialog_business_bot_is_paused(DialogId dialog_id, bool is_paused) {
|
||||
auto d = get_dialog_force(dialog_id, "on_update_dialog_is_blocked");
|
||||
auto d = get_dialog_force(dialog_id, "on_update_dialog_business_bot_is_paused");
|
||||
CHECK(d != nullptr);
|
||||
if (d->action_bar != nullptr && d->action_bar->set_business_bot_is_paused(is_paused)) {
|
||||
send_update_chat_action_bar(d);
|
||||
if (d->business_bot_manage_bar != nullptr && d->business_bot_manage_bar->set_business_bot_is_paused(is_paused)) {
|
||||
send_update_chat_business_bot_manage_bar(d);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31028,6 +31081,9 @@ void MessagesManager::on_dialog_user_is_deleted_updated(DialogId dialog_id, bool
|
||||
if (d->action_bar != nullptr && d->action_bar->on_user_deleted()) {
|
||||
send_update_chat_action_bar(d);
|
||||
}
|
||||
if (d->business_bot_manage_bar != nullptr && d->business_bot_manage_bar->on_user_deleted()) {
|
||||
send_update_chat_business_bot_manage_bar(d);
|
||||
}
|
||||
} else {
|
||||
repair_dialog_action_bar(d, "on_dialog_user_is_deleted_updated");
|
||||
}
|
||||
@ -34539,6 +34595,7 @@ MessagesManager::Dialog *MessagesManager::add_new_dialog(unique_ptr<Dialog> &&di
|
||||
failed_to_load_dialogs_.erase(dialog_id);
|
||||
|
||||
fix_dialog_action_bar(d, d->action_bar.get());
|
||||
fix_dialog_business_bot_manage_bar(dialog_id, d->business_bot_manage_bar.get());
|
||||
|
||||
send_update_new_chat(d);
|
||||
|
||||
@ -35641,8 +35698,8 @@ unique_ptr<MessagesManager::Dialog> MessagesManager::parse_dialog(DialogId dialo
|
||||
add_message_dependencies(dependencies, message.get());
|
||||
});
|
||||
add_draft_message_dependencies(dependencies, d->draft_message);
|
||||
if (d->action_bar != nullptr) {
|
||||
d->action_bar->add_dependencies(dependencies);
|
||||
if (d->business_bot_manage_bar != nullptr) {
|
||||
d->business_bot_manage_bar->add_dependencies(dependencies);
|
||||
}
|
||||
for (auto user_id : d->pending_join_request_user_ids) {
|
||||
dependencies.add(user_id);
|
||||
|
@ -105,6 +105,7 @@
|
||||
namespace td {
|
||||
|
||||
struct BinlogEvent;
|
||||
class BusinessBotManageBar;
|
||||
class Dependencies;
|
||||
class DialogActionBar;
|
||||
class DialogFilter;
|
||||
@ -1206,6 +1207,7 @@ class MessagesManager final : public Actor {
|
||||
MessageTtl message_ttl;
|
||||
unique_ptr<DraftMessage> draft_message;
|
||||
unique_ptr<DialogActionBar> action_bar;
|
||||
unique_ptr<BusinessBotManageBar> business_bot_manage_bar;
|
||||
LogEventIdWithGeneration save_draft_message_log_event_id;
|
||||
LogEventIdWithGeneration save_notification_settings_log_event_id;
|
||||
LogEventIdWithGeneration set_folder_id_log_event_id;
|
||||
@ -2357,6 +2359,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void send_update_chat_action_bar(Dialog *d);
|
||||
|
||||
void send_update_chat_business_bot_manage_bar(Dialog *d);
|
||||
|
||||
void send_update_chat_available_reactions(const Dialog *d);
|
||||
|
||||
void send_update_secret_chats_with_user_background(const Dialog *d) const;
|
||||
@ -2602,8 +2606,12 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void fix_dialog_action_bar(const Dialog *d, DialogActionBar *action_bar);
|
||||
|
||||
void fix_dialog_business_bot_manage_bar(DialogId dialog_id, BusinessBotManageBar *business_bot_manage_bar);
|
||||
|
||||
td_api::object_ptr<td_api::ChatActionBar> get_chat_action_bar_object(const Dialog *d) const;
|
||||
|
||||
td_api::object_ptr<td_api::businessBotManageBar> get_business_bot_manage_bar_object(const Dialog *d) const;
|
||||
|
||||
td_api::object_ptr<td_api::chatBackground> get_chat_background_object(const Dialog *d) const;
|
||||
|
||||
string get_dialog_theme_name(const Dialog *d) const;
|
||||
|
Loading…
Reference in New Issue
Block a user