Support businessRecipients.excluded_chat_ids.
This commit is contained in:
parent
49372ab4c2
commit
9913390bfe
@ -595,12 +595,13 @@ businessLocation location:location address:string = BusinessLocation;
|
|||||||
|
|
||||||
//@description Describes private chats chosen for automatic interaction with a business
|
//@description Describes private chats chosen for automatic interaction with a business
|
||||||
//@chat_ids Identifiers of selected private chats
|
//@chat_ids Identifiers of selected private chats
|
||||||
|
//@excluded_chat_ids Identifiers of private chats that are always excluded; for businessConnectedBot only
|
||||||
//@select_existing_chats True, if all existing private chats are selected
|
//@select_existing_chats True, if all existing private chats are selected
|
||||||
//@select_new_chats True, if all new private chats are selected
|
//@select_new_chats True, if all new private chats are selected
|
||||||
//@select_contacts True, if all private chats with contacts are selected
|
//@select_contacts True, if all private chats with contacts are selected
|
||||||
//@select_non_contacts True, if all private chats with non-contacts are selected
|
//@select_non_contacts True, if all private chats with non-contacts are selected
|
||||||
//@exclude_selected If true, then all private chats except the selected are chosen. Otherwise, only the selected chats are chosen
|
//@exclude_selected If true, then all private chats except the selected are chosen. Otherwise, only the selected chats are chosen
|
||||||
businessRecipients chat_ids:vector<int53> select_existing_chats:Bool select_new_chats:Bool select_contacts:Bool select_non_contacts:Bool exclude_selected:Bool = BusinessRecipients;
|
businessRecipients chat_ids:vector<int53> excluded_chat_ids:vector<int53> select_existing_chats:Bool select_new_chats:Bool select_contacts:Bool select_non_contacts:Bool exclude_selected:Bool = BusinessRecipients;
|
||||||
|
|
||||||
//@description Describes settings for messages that are automatically sent by a Telegram Business account when it is away
|
//@description Describes settings for messages that are automatically sent by a Telegram Business account when it is away
|
||||||
//@shortcut_id Unique quick reply shortcut identifier for the away messages
|
//@shortcut_id Unique quick reply shortcut identifier for the away messages
|
||||||
|
@ -23,7 +23,7 @@ BusinessAwayMessage::BusinessAwayMessage(td_api::object_ptr<td_api::businessAway
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shortcut_id_ = QuickReplyShortcutId(away_message->shortcut_id_);
|
shortcut_id_ = QuickReplyShortcutId(away_message->shortcut_id_);
|
||||||
recipients_ = BusinessRecipients(std::move(away_message->recipients_));
|
recipients_ = BusinessRecipients(std::move(away_message->recipients_), false);
|
||||||
schedule_ = BusinessAwayMessageSchedule(std::move(away_message->schedule_));
|
schedule_ = BusinessAwayMessageSchedule(std::move(away_message->schedule_));
|
||||||
offline_only_ = away_message->offline_only_;
|
offline_only_ = away_message->offline_only_;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ BusinessConnectedBot::BusinessConnectedBot(td_api::object_ptr<td_api::businessCo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user_id_ = UserId(connected_bot->bot_user_id_);
|
user_id_ = UserId(connected_bot->bot_user_id_);
|
||||||
recipients_ = BusinessRecipients(std::move(connected_bot->recipients_));
|
recipients_ = BusinessRecipients(std::move(connected_bot->recipients_), true);
|
||||||
can_reply_ = connected_bot->can_reply_;
|
can_reply_ = connected_bot->can_reply_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ BusinessGreetingMessage::BusinessGreetingMessage(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shortcut_id_ = QuickReplyShortcutId(greeting_message->shortcut_id_);
|
shortcut_id_ = QuickReplyShortcutId(greeting_message->shortcut_id_);
|
||||||
recipients_ = BusinessRecipients(std::move(greeting_message->recipients_));
|
recipients_ = BusinessRecipients(std::move(greeting_message->recipients_), false);
|
||||||
inactivity_days_ = inactivity_days;
|
inactivity_days_ = inactivity_days;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,15 +27,17 @@ BusinessRecipients::BusinessRecipients(telegram_api::object_ptr<telegram_api::bu
|
|||||||
|
|
||||||
BusinessRecipients::BusinessRecipients(telegram_api::object_ptr<telegram_api::businessBotRecipients> recipients)
|
BusinessRecipients::BusinessRecipients(telegram_api::object_ptr<telegram_api::businessBotRecipients> recipients)
|
||||||
: user_ids_(UserId::get_user_ids(recipients->users_))
|
: user_ids_(UserId::get_user_ids(recipients->users_))
|
||||||
|
, excluded_user_ids_(UserId::get_user_ids(recipients->exclude_users_))
|
||||||
, existing_chats_(recipients->existing_chats_)
|
, existing_chats_(recipients->existing_chats_)
|
||||||
, new_chats_(recipients->new_chats_)
|
, new_chats_(recipients->new_chats_)
|
||||||
, contacts_(recipients->contacts_)
|
, contacts_(recipients->contacts_)
|
||||||
, non_contacts_(recipients->non_contacts_)
|
, non_contacts_(recipients->non_contacts_)
|
||||||
, exclude_selected_(recipients->exclude_selected_) {
|
, exclude_selected_(recipients->exclude_selected_) {
|
||||||
td::remove_if(user_ids_, [](UserId user_id) { return !user_id.is_valid(); });
|
td::remove_if(user_ids_, [](UserId user_id) { return !user_id.is_valid(); });
|
||||||
|
td::remove_if(excluded_user_ids_, [](UserId user_id) { return !user_id.is_valid(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
BusinessRecipients::BusinessRecipients(td_api::object_ptr<td_api::businessRecipients> recipients) {
|
BusinessRecipients::BusinessRecipients(td_api::object_ptr<td_api::businessRecipients> recipients, bool allow_excluded) {
|
||||||
if (recipients == nullptr) {
|
if (recipients == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -45,6 +47,18 @@ BusinessRecipients::BusinessRecipients(td_api::object_ptr<td_api::businessRecipi
|
|||||||
user_ids_.push_back(dialog_id.get_user_id());
|
user_ids_.push_back(dialog_id.get_user_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (allow_excluded) {
|
||||||
|
for (auto chat_id : recipients->excluded_chat_ids_) {
|
||||||
|
DialogId dialog_id(chat_id);
|
||||||
|
if (dialog_id.get_type() == DialogType::User) {
|
||||||
|
excluded_user_ids_.push_back(dialog_id.get_user_id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (recipients->exclude_selected_) {
|
||||||
|
append(user_ids_, std::move(excluded_user_ids_));
|
||||||
|
reset_to_empty(excluded_user_ids_);
|
||||||
|
}
|
||||||
|
}
|
||||||
existing_chats_ = recipients->select_existing_chats_;
|
existing_chats_ = recipients->select_existing_chats_;
|
||||||
new_chats_ = recipients->select_new_chats_;
|
new_chats_ = recipients->select_new_chats_;
|
||||||
contacts_ = recipients->select_contacts_;
|
contacts_ = recipients->select_contacts_;
|
||||||
@ -60,8 +74,16 @@ td_api::object_ptr<td_api::businessRecipients> BusinessRecipients::get_business_
|
|||||||
CHECK(td->dialog_manager_->have_dialog_force(dialog_id, "get_business_recipients_object"));
|
CHECK(td->dialog_manager_->have_dialog_force(dialog_id, "get_business_recipients_object"));
|
||||||
chat_ids.push_back(td->dialog_manager_->get_chat_id_object(dialog_id, "businessRecipients"));
|
chat_ids.push_back(td->dialog_manager_->get_chat_id_object(dialog_id, "businessRecipients"));
|
||||||
}
|
}
|
||||||
return td_api::make_object<td_api::businessRecipients>(std::move(chat_ids), existing_chats_, new_chats_, contacts_,
|
vector<int64> excluded_chat_ids;
|
||||||
non_contacts_, exclude_selected_);
|
for (auto user_id : excluded_user_ids_) {
|
||||||
|
DialogId dialog_id(user_id);
|
||||||
|
td->dialog_manager_->force_create_dialog(dialog_id, "get_business_recipients_object", true);
|
||||||
|
CHECK(td->dialog_manager_->have_dialog_force(dialog_id, "get_business_recipients_object"));
|
||||||
|
excluded_chat_ids.push_back(td->dialog_manager_->get_chat_id_object(dialog_id, "businessRecipients"));
|
||||||
|
}
|
||||||
|
return td_api::make_object<td_api::businessRecipients>(std::move(chat_ids), std::move(excluded_chat_ids),
|
||||||
|
existing_chats_, new_chats_, contacts_, non_contacts_,
|
||||||
|
exclude_selected_);
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram_api::object_ptr<telegram_api::inputBusinessRecipients> BusinessRecipients::get_input_business_recipients(
|
telegram_api::object_ptr<telegram_api::inputBusinessRecipients> BusinessRecipients::get_input_business_recipients(
|
||||||
@ -101,19 +123,19 @@ telegram_api::object_ptr<telegram_api::inputBusinessBotRecipients>
|
|||||||
BusinessRecipients::get_input_business_bot_recipients(Td *td) const {
|
BusinessRecipients::get_input_business_bot_recipients(Td *td) const {
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
if (existing_chats_) {
|
if (existing_chats_) {
|
||||||
flags |= telegram_api::inputBusinessRecipients::EXISTING_CHATS_MASK;
|
flags |= telegram_api::inputBusinessBotRecipients::EXISTING_CHATS_MASK;
|
||||||
}
|
}
|
||||||
if (new_chats_) {
|
if (new_chats_) {
|
||||||
flags |= telegram_api::inputBusinessRecipients::NEW_CHATS_MASK;
|
flags |= telegram_api::inputBusinessBotRecipients::NEW_CHATS_MASK;
|
||||||
}
|
}
|
||||||
if (contacts_) {
|
if (contacts_) {
|
||||||
flags |= telegram_api::inputBusinessRecipients::CONTACTS_MASK;
|
flags |= telegram_api::inputBusinessBotRecipients::CONTACTS_MASK;
|
||||||
}
|
}
|
||||||
if (non_contacts_) {
|
if (non_contacts_) {
|
||||||
flags |= telegram_api::inputBusinessRecipients::NON_CONTACTS_MASK;
|
flags |= telegram_api::inputBusinessBotRecipients::NON_CONTACTS_MASK;
|
||||||
}
|
}
|
||||||
if (exclude_selected_) {
|
if (exclude_selected_) {
|
||||||
flags |= telegram_api::inputBusinessRecipients::EXCLUDE_SELECTED_MASK;
|
flags |= telegram_api::inputBusinessBotRecipients::EXCLUDE_SELECTED_MASK;
|
||||||
}
|
}
|
||||||
vector<telegram_api::object_ptr<telegram_api::InputUser>> input_users;
|
vector<telegram_api::object_ptr<telegram_api::InputUser>> input_users;
|
||||||
for (auto user_id : user_ids_) {
|
for (auto user_id : user_ids_) {
|
||||||
@ -123,16 +145,27 @@ BusinessRecipients::get_input_business_bot_recipients(Td *td) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!input_users.empty()) {
|
if (!input_users.empty()) {
|
||||||
flags |= telegram_api::inputBusinessRecipients::USERS_MASK;
|
flags |= telegram_api::inputBusinessBotRecipients::USERS_MASK;
|
||||||
|
}
|
||||||
|
vector<telegram_api::object_ptr<telegram_api::InputUser>> excluded_input_users;
|
||||||
|
for (auto user_id : excluded_user_ids_) {
|
||||||
|
auto r_input_user = td->contacts_manager_->get_input_user(user_id);
|
||||||
|
if (r_input_user.is_ok()) {
|
||||||
|
excluded_input_users.push_back(r_input_user.move_as_ok());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!excluded_input_users.empty()) {
|
||||||
|
flags |= telegram_api::inputBusinessBotRecipients::EXCLUDE_USERS_MASK;
|
||||||
}
|
}
|
||||||
return telegram_api::make_object<telegram_api::inputBusinessBotRecipients>(
|
return telegram_api::make_object<telegram_api::inputBusinessBotRecipients>(
|
||||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||||
std::move(input_users), Auto());
|
std::move(input_users), std::move(excluded_input_users));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const BusinessRecipients &lhs, const BusinessRecipients &rhs) {
|
bool operator==(const BusinessRecipients &lhs, const BusinessRecipients &rhs) {
|
||||||
return lhs.user_ids_ == rhs.user_ids_ && lhs.existing_chats_ == rhs.existing_chats_ &&
|
return lhs.user_ids_ == rhs.user_ids_ && lhs.excluded_user_ids_ == rhs.excluded_user_ids_ &&
|
||||||
lhs.new_chats_ == rhs.new_chats_ && lhs.contacts_ == rhs.contacts_ && lhs.non_contacts_ == rhs.non_contacts_ &&
|
lhs.existing_chats_ == rhs.existing_chats_ && lhs.new_chats_ == rhs.new_chats_ &&
|
||||||
|
lhs.contacts_ == rhs.contacts_ && lhs.non_contacts_ == rhs.non_contacts_ &&
|
||||||
lhs.exclude_selected_ == rhs.exclude_selected_;
|
lhs.exclude_selected_ == rhs.exclude_selected_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class BusinessRecipients {
|
|||||||
|
|
||||||
explicit BusinessRecipients(telegram_api::object_ptr<telegram_api::businessBotRecipients> recipients);
|
explicit BusinessRecipients(telegram_api::object_ptr<telegram_api::businessBotRecipients> recipients);
|
||||||
|
|
||||||
explicit BusinessRecipients(td_api::object_ptr<td_api::businessRecipients> recipients);
|
BusinessRecipients(td_api::object_ptr<td_api::businessRecipients> recipients, bool allow_excluded);
|
||||||
|
|
||||||
td_api::object_ptr<td_api::businessRecipients> get_business_recipients_object(Td *td) const;
|
td_api::object_ptr<td_api::businessRecipients> get_business_recipients_object(Td *td) const;
|
||||||
|
|
||||||
@ -41,6 +41,7 @@ class BusinessRecipients {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
vector<UserId> user_ids_;
|
vector<UserId> user_ids_;
|
||||||
|
vector<UserId> excluded_user_ids_;
|
||||||
bool existing_chats_ = false;
|
bool existing_chats_ = false;
|
||||||
bool new_chats_ = false;
|
bool new_chats_ = false;
|
||||||
bool contacts_ = false;
|
bool contacts_ = false;
|
||||||
|
@ -16,6 +16,7 @@ namespace td {
|
|||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void BusinessRecipients::store(StorerT &storer) const {
|
void BusinessRecipients::store(StorerT &storer) const {
|
||||||
bool has_user_ids = !user_ids_.empty();
|
bool has_user_ids = !user_ids_.empty();
|
||||||
|
bool has_excluded_user_ids = !excluded_user_ids_.empty();
|
||||||
BEGIN_STORE_FLAGS();
|
BEGIN_STORE_FLAGS();
|
||||||
STORE_FLAG(existing_chats_);
|
STORE_FLAG(existing_chats_);
|
||||||
STORE_FLAG(new_chats_);
|
STORE_FLAG(new_chats_);
|
||||||
@ -23,15 +24,20 @@ void BusinessRecipients::store(StorerT &storer) const {
|
|||||||
STORE_FLAG(non_contacts_);
|
STORE_FLAG(non_contacts_);
|
||||||
STORE_FLAG(exclude_selected_);
|
STORE_FLAG(exclude_selected_);
|
||||||
STORE_FLAG(has_user_ids);
|
STORE_FLAG(has_user_ids);
|
||||||
|
STORE_FLAG(has_excluded_user_ids);
|
||||||
END_STORE_FLAGS();
|
END_STORE_FLAGS();
|
||||||
if (has_user_ids) {
|
if (has_user_ids) {
|
||||||
td::store(user_ids_, storer);
|
td::store(user_ids_, storer);
|
||||||
}
|
}
|
||||||
|
if (has_excluded_user_ids) {
|
||||||
|
td::store(excluded_user_ids_, storer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
void BusinessRecipients::parse(ParserT &parser) {
|
void BusinessRecipients::parse(ParserT &parser) {
|
||||||
bool has_user_ids;
|
bool has_user_ids;
|
||||||
|
bool has_excluded_user_ids;
|
||||||
BEGIN_PARSE_FLAGS();
|
BEGIN_PARSE_FLAGS();
|
||||||
PARSE_FLAG(existing_chats_);
|
PARSE_FLAG(existing_chats_);
|
||||||
PARSE_FLAG(new_chats_);
|
PARSE_FLAG(new_chats_);
|
||||||
@ -39,10 +45,14 @@ void BusinessRecipients::parse(ParserT &parser) {
|
|||||||
PARSE_FLAG(non_contacts_);
|
PARSE_FLAG(non_contacts_);
|
||||||
PARSE_FLAG(exclude_selected_);
|
PARSE_FLAG(exclude_selected_);
|
||||||
PARSE_FLAG(has_user_ids);
|
PARSE_FLAG(has_user_ids);
|
||||||
|
PARSE_FLAG(has_excluded_user_ids);
|
||||||
END_PARSE_FLAGS();
|
END_PARSE_FLAGS();
|
||||||
if (has_user_ids) {
|
if (has_user_ids) {
|
||||||
td::parse(user_ids_, parser);
|
td::parse(user_ids_, parser);
|
||||||
}
|
}
|
||||||
|
if (has_excluded_user_ids) {
|
||||||
|
td::parse(excluded_user_ids_, parser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -585,8 +585,8 @@ class CliClient final : public Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
td_api::object_ptr<td_api::businessRecipients> as_business_recipients(string chat_ids) const {
|
td_api::object_ptr<td_api::businessRecipients> as_business_recipients(string chat_ids) const {
|
||||||
return td_api::make_object<td_api::businessRecipients>(as_chat_ids(chat_ids), rand_bool(), rand_bool(), rand_bool(),
|
return td_api::make_object<td_api::businessRecipients>(as_chat_ids(chat_ids), Auto(), rand_bool(), rand_bool(),
|
||||||
rand_bool(), rand_bool());
|
rand_bool(), rand_bool(), rand_bool());
|
||||||
}
|
}
|
||||||
|
|
||||||
static td_api::object_ptr<td_api::StickerFormat> as_sticker_format(string sticker_format) {
|
static td_api::object_ptr<td_api::StickerFormat> as_sticker_format(string sticker_format) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user