Add DialogNotificationSettings::get_input_peer_notify_settings.

This commit is contained in:
levlam 2023-06-12 16:29:35 +03:00
parent 96fef663bb
commit 9a8262f146
3 changed files with 22 additions and 17 deletions

View File

@ -12,6 +12,25 @@
namespace td {
telegram_api::object_ptr<telegram_api::inputPeerNotifySettings>
DialogNotificationSettings::get_input_peer_notify_settings() const {
int32 flags = 0;
if (!use_default_mute_until) {
flags |= telegram_api::inputPeerNotifySettings::MUTE_UNTIL_MASK;
}
if (sound != nullptr) {
flags |= telegram_api::inputPeerNotifySettings::SOUND_MASK;
}
if (!use_default_show_preview) {
flags |= telegram_api::inputPeerNotifySettings::SHOW_PREVIEWS_MASK;
}
if (silent_send_message) {
flags |= telegram_api::inputPeerNotifySettings::SILENT_MASK;
}
return telegram_api::make_object<telegram_api::inputPeerNotifySettings>(
flags, show_preview, silent_send_message, mute_until, get_input_notification_sound(sound), false, false, nullptr);
}
StringBuilder &operator<<(StringBuilder &string_builder, const DialogNotificationSettings &notification_settings) {
return string_builder << "[" << notification_settings.mute_until << ", " << notification_settings.sound << ", "
<< notification_settings.show_preview << ", " << notification_settings.silent_send_message

View File

@ -53,6 +53,8 @@ class DialogNotificationSettings {
, use_default_disable_mention_notifications(use_default_disable_mention_notifications)
, disable_mention_notifications(disable_mention_notifications) {
}
telegram_api::object_ptr<telegram_api::inputPeerNotifySettings> get_input_peer_notify_settings() const;
};
StringBuilder &operator<<(StringBuilder &string_builder, const DialogNotificationSettings &notification_settings);

View File

@ -334,24 +334,8 @@ class UpdateDialogNotifySettingsQuery final : public Td::ResultHandler {
return on_error(Status::Error(500, "Can't update chat notification settings"));
}
int32 flags = 0;
if (!new_settings.use_default_mute_until) {
flags |= telegram_api::inputPeerNotifySettings::MUTE_UNTIL_MASK;
}
if (new_settings.sound != nullptr) {
flags |= telegram_api::inputPeerNotifySettings::SOUND_MASK;
}
if (!new_settings.use_default_show_preview) {
flags |= telegram_api::inputPeerNotifySettings::SHOW_PREVIEWS_MASK;
}
if (new_settings.silent_send_message) {
flags |= telegram_api::inputPeerNotifySettings::SILENT_MASK;
}
send_query(G()->net_query_creator().create(telegram_api::account_updateNotifySettings(
std::move(input_notify_peer),
make_tl_object<telegram_api::inputPeerNotifySettings>(
flags, new_settings.show_preview, new_settings.silent_send_message, new_settings.mute_until,
get_input_notification_sound(new_settings.sound), false, false, nullptr))));
std::move(input_notify_peer), new_settings.get_input_peer_notify_settings())));
}
void on_result(BufferSlice packet) final {