Update API scheme on layer 176.

This commit is contained in:
John Preston 2024-02-26 22:01:23 +04:00
parent d05c4e0990
commit 5c11fa4f63
3 changed files with 48 additions and 23 deletions

View file

@ -29,6 +29,38 @@ namespace {
MTP_vector_from_range(list | ranges::views::transform(proj)));
}
[[nodiscard]] MTPInputBusinessRecipients ToMTP(
const BusinessRecipients &data) {
//MTP_flags(RecipientsFlags(data.recipients, Flag())),
// MTP_vector_from_range(
// (data.recipients.allButExcluded
// ? data.recipients.excluded
// : data.recipients.included).list
// | ranges::views::transform(&UserData::inputUser)),
using Flag = MTPDinputBusinessRecipients::Flag;
using Type = BusinessChatType;
const auto &chats = data.allButExcluded
? data.excluded
: data.included;
const auto flags = Flag()
| ((chats.types & Type::NewChats) ? Flag::f_new_chats : Flag())
| ((chats.types & Type::ExistingChats)
? Flag::f_existing_chats
: Flag())
| ((chats.types & Type::Contacts) ? Flag::f_contacts : Flag())
| ((chats.types & Type::NonContacts) ? Flag::f_non_contacts : Flag())
| (chats.list.empty() ? Flag() : Flag::f_users)
| (data.allButExcluded ? Flag::f_exclude_selected : Flag());
const auto &users = data.allButExcluded
? data.excluded
: data.included;
return MTP_inputBusinessRecipients(
MTP_flags(flags),
MTP_vector_from_range(users.list
| ranges::views::transform(&UserData::inputUser)));
}
template <typename Flag>
[[nodiscard]] auto RecipientsFlags(
const BusinessRecipients &data,
@ -62,29 +94,17 @@ template <typename Flag>
}
[[nodiscard]] MTPInputBusinessAwayMessage ToMTP(const AwaySettings &data) {
using Flag = MTPDinputBusinessAwayMessage::Flag;
return MTP_inputBusinessAwayMessage(
MTP_flags(RecipientsFlags(data.recipients, Flag())),
MTP_int(data.shortcutId),
ToMTP(data.schedule),
MTP_vector_from_range(
(data.recipients.allButExcluded
? data.recipients.excluded
: data.recipients.included).list
| ranges::views::transform(&UserData::inputUser)));
ToMTP(data.recipients));
}
[[nodiscard]] MTPInputBusinessGreetingMessage ToMTP(
const GreetingSettings &data) {
using Flag = MTPDinputBusinessGreetingMessage::Flag;
return MTP_inputBusinessGreetingMessage(
MTP_flags(RecipientsFlags(data.recipients, Flag())),
MTP_int(data.shortcutId),
MTP_vector_from_range(
(data.recipients.allButExcluded
? data.recipients.excluded
: data.recipients.included).list
| ranges::views::transform(&UserData::inputUser)),
ToMTP(data.recipients),
MTP_int(data.noActivityDays));
}

View file

@ -62,11 +62,12 @@ using UpdateFlag = Data::PeerUpdate::Flag;
return result;
}
template <typename T>
Data::BusinessRecipients RecipientsFromMTP(
Data::BusinessRecipients FromMTP(
not_null<Data::Session*> owner,
const T &data) {
const MTPBusinessRecipients &recipients) {
using Type = Data::BusinessChatType;
const auto &data = recipients.data();
auto result = Data::BusinessRecipients{
.allButExcluded = data.is_exclude_selected(),
};
@ -94,7 +95,7 @@ Data::BusinessRecipients RecipientsFromMTP(
}
const auto &data = message->data();
auto result = Data::AwaySettings{
.recipients = RecipientsFromMTP(owner, data),
.recipients = FromMTP(owner, data.vrecipients()),
.shortcutId = data.vshortcut_id().v,
};
data.vschedule().match([&](
@ -120,7 +121,7 @@ Data::BusinessRecipients RecipientsFromMTP(
}
const auto &data = message->data();
return Data::GreetingSettings{
.recipients = RecipientsFromMTP(owner, data),
.recipients = FromMTP(owner, data.vrecipients()),
.noActivityDays = data.vno_activity_days().v,
.shortcutId = data.vshortcut_id().v,
};

View file

@ -1671,17 +1671,21 @@ businessWorkHours#8c92b098 flags:# open_now:flags.0?true timezone_id:string week
businessLocation#ac5c1af7 flags:# geo_point:flags.0?GeoPoint address:string = BusinessLocation;
inputBusinessRecipients#6f8b32aa flags:# existing_chats:flags.0?true new_chats:flags.1?true contacts:flags.2?true non_contacts:flags.3?true exclude_selected:flags.5?true users:flags.4?Vector<InputUser> = InputBusinessRecipients;
businessRecipients#21108ff7 flags:# existing_chats:flags.0?true new_chats:flags.1?true contacts:flags.2?true non_contacts:flags.3?true exclude_selected:flags.5?true users:flags.4?Vector<long> = BusinessRecipients;
businessAwayMessageScheduleAlways#c9b9e2b9 = BusinessAwayMessageSchedule;
businessAwayMessageScheduleOutsideWorkHours#c3f2f501 = BusinessAwayMessageSchedule;
businessAwayMessageScheduleCustom#cc4d9ecc start_date:int end_date:int = BusinessAwayMessageSchedule;
inputBusinessGreetingMessage#7d4a3609 flags:# existing_chats:flags.0?true new_chats:flags.1?true contacts:flags.2?true non_contacts:flags.3?true exclude_selected:flags.5?true shortcut_id:int users:flags.4?Vector<InputUser> no_activity_days:int = InputBusinessGreetingMessage;
inputBusinessGreetingMessage#194cb3b shortcut_id:int recipients:InputBusinessRecipients no_activity_days:int = InputBusinessGreetingMessage;
businessGreetingMessage#a098d54c flags:# existing_chats:flags.0?true new_chats:flags.1?true contacts:flags.2?true non_contacts:flags.3?true exclude_selected:flags.5?true shortcut_id:int users:flags.4?Vector<long> no_activity_days:int = BusinessGreetingMessage;
businessGreetingMessage#e519abab shortcut_id:int recipients:BusinessRecipients no_activity_days:int = BusinessGreetingMessage;
inputBusinessAwayMessage#ce6fda48 flags:# existing_chats:flags.0?true new_chats:flags.1?true contacts:flags.2?true non_contacts:flags.3?true exclude_selected:flags.5?true shortcut_id:int schedule:BusinessAwayMessageSchedule users:flags.4?Vector<InputUser> = InputBusinessAwayMessage;
inputBusinessAwayMessage#edac03f4 shortcut_id:int schedule:BusinessAwayMessageSchedule recipients:InputBusinessRecipients = InputBusinessAwayMessage;
businessAwayMessage#9acd7a15 flags:# existing_chats:flags.0?true new_chats:flags.1?true contacts:flags.2?true non_contacts:flags.3?true exclude_selected:flags.5?true shortcut_id:int schedule:BusinessAwayMessageSchedule users:flags.4?Vector<long> = BusinessAwayMessage;
businessAwayMessage#1bd9bebc shortcut_id:int schedule:BusinessAwayMessageSchedule recipients:BusinessRecipients = BusinessAwayMessage;
timezone#ff9289f5 id:string name:string utc_offset:int = Timezone;