diff --git a/Telegram/SourceFiles/data/business/data_business_info.cpp b/Telegram/SourceFiles/data/business/data_business_info.cpp index 1a1d30555..5fa0844ee 100644 --- a/Telegram/SourceFiles/data/business/data_business_info.cpp +++ b/Telegram/SourceFiles/data/business/data_business_info.cpp @@ -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 [[nodiscard]] auto RecipientsFlags( const BusinessRecipients &data, @@ -62,29 +94,17 @@ template } [[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)); } diff --git a/Telegram/SourceFiles/data/data_user.cpp b/Telegram/SourceFiles/data/data_user.cpp index 35ad558c7..a351ce678 100644 --- a/Telegram/SourceFiles/data/data_user.cpp +++ b/Telegram/SourceFiles/data/data_user.cpp @@ -62,11 +62,12 @@ using UpdateFlag = Data::PeerUpdate::Flag; return result; } -template -Data::BusinessRecipients RecipientsFromMTP( +Data::BusinessRecipients FromMTP( not_null 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, }; diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index 9fdf2c153..cd07a4e19 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -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 = 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 = 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 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 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 = 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 = BusinessAwayMessage; +businessAwayMessage#1bd9bebc shortcut_id:int schedule:BusinessAwayMessageSchedule recipients:BusinessRecipients = BusinessAwayMessage; timezone#ff9289f5 id:string name:string utc_offset:int = Timezone;