2018-09-29 02:29:57 +02:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2018-09-29 02:29:57 +02:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2022-04-11 19:01:44 +02:00
|
|
|
#include "td/telegram/NotificationSound.h"
|
2018-09-29 02:29:57 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2019-02-12 17:48:52 +01:00
|
|
|
#include "td/utils/Status.h"
|
2018-09-29 02:29:57 +02:00
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class DialogNotificationSettings {
|
|
|
|
public:
|
|
|
|
int32 mute_until = 0;
|
2022-04-11 19:01:44 +02:00
|
|
|
unique_ptr<NotificationSound> sound;
|
2023-06-27 18:09:43 +02:00
|
|
|
unique_ptr<NotificationSound> story_sound;
|
2018-09-29 02:29:57 +02:00
|
|
|
bool show_preview = true;
|
2023-06-12 19:09:23 +02:00
|
|
|
bool mute_stories = false;
|
2023-06-27 18:09:43 +02:00
|
|
|
bool hide_story_sender = false;
|
2018-09-29 02:29:57 +02:00
|
|
|
bool silent_send_message = false;
|
|
|
|
bool use_default_mute_until = true;
|
|
|
|
bool use_default_show_preview = true;
|
2023-06-12 19:09:23 +02:00
|
|
|
bool use_default_mute_stories = true;
|
2023-06-27 18:09:43 +02:00
|
|
|
bool use_default_hide_story_sender = true;
|
2018-09-29 02:29:57 +02:00
|
|
|
bool is_use_default_fixed = true;
|
2019-02-18 00:41:53 +01:00
|
|
|
bool is_secret_chat_show_preview_fixed = false;
|
2018-09-29 02:29:57 +02:00
|
|
|
bool is_synchronized = false;
|
|
|
|
|
2019-01-10 01:47:33 +01:00
|
|
|
// local settings
|
2019-01-10 18:54:46 +01:00
|
|
|
bool use_default_disable_pinned_message_notifications = true;
|
|
|
|
bool disable_pinned_message_notifications = false;
|
|
|
|
bool use_default_disable_mention_notifications = true;
|
|
|
|
bool disable_mention_notifications = false;
|
2019-01-10 01:47:33 +01:00
|
|
|
|
2018-09-29 02:29:57 +02:00
|
|
|
DialogNotificationSettings() = default;
|
|
|
|
|
2022-04-11 19:01:44 +02:00
|
|
|
DialogNotificationSettings(bool use_default_mute_until, int32 mute_until, unique_ptr<NotificationSound> &&sound,
|
2023-06-12 19:09:23 +02:00
|
|
|
bool use_default_show_preview, bool show_preview, bool use_default_mute_stories,
|
2023-06-27 18:09:43 +02:00
|
|
|
bool mute_stories, unique_ptr<NotificationSound> &&story_sound,
|
|
|
|
bool use_default_hide_story_sender, bool hide_story_sender, bool silent_send_message,
|
2019-01-10 18:54:46 +01:00
|
|
|
bool use_default_disable_pinned_message_notifications,
|
|
|
|
bool disable_pinned_message_notifications, bool use_default_disable_mention_notifications,
|
|
|
|
bool disable_mention_notifications)
|
2018-09-29 02:29:57 +02:00
|
|
|
: mute_until(mute_until)
|
|
|
|
, sound(std::move(sound))
|
2023-06-27 18:09:43 +02:00
|
|
|
, story_sound(std::move(story_sound))
|
2018-09-29 02:29:57 +02:00
|
|
|
, show_preview(show_preview)
|
2023-06-12 19:09:23 +02:00
|
|
|
, mute_stories(mute_stories)
|
2023-06-27 18:09:43 +02:00
|
|
|
, hide_story_sender(hide_story_sender)
|
2018-09-29 02:29:57 +02:00
|
|
|
, silent_send_message(silent_send_message)
|
|
|
|
, use_default_mute_until(use_default_mute_until)
|
|
|
|
, use_default_show_preview(use_default_show_preview)
|
2023-06-12 19:09:23 +02:00
|
|
|
, use_default_mute_stories(use_default_mute_stories)
|
2023-06-27 18:09:43 +02:00
|
|
|
, use_default_hide_story_sender(use_default_hide_story_sender)
|
2019-01-10 01:47:33 +01:00
|
|
|
, is_synchronized(true)
|
2019-01-10 18:54:46 +01:00
|
|
|
, use_default_disable_pinned_message_notifications(use_default_disable_pinned_message_notifications)
|
|
|
|
, disable_pinned_message_notifications(disable_pinned_message_notifications)
|
|
|
|
, use_default_disable_mention_notifications(use_default_disable_mention_notifications)
|
|
|
|
, disable_mention_notifications(disable_mention_notifications) {
|
2018-09-29 02:29:57 +02:00
|
|
|
}
|
2023-06-12 15:29:35 +02:00
|
|
|
|
|
|
|
telegram_api::object_ptr<telegram_api::inputPeerNotifySettings> get_input_peer_notify_settings() const;
|
2018-09-29 02:29:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const DialogNotificationSettings ¬ification_settings);
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::chatNotificationSettings> get_chat_notification_settings_object(
|
|
|
|
const DialogNotificationSettings *notification_settings);
|
|
|
|
|
2019-02-01 13:47:27 +01:00
|
|
|
Result<DialogNotificationSettings> get_dialog_notification_settings(
|
2022-12-06 14:18:11 +01:00
|
|
|
td_api::object_ptr<td_api::chatNotificationSettings> &¬ification_settings,
|
|
|
|
const DialogNotificationSettings *old_settings);
|
2019-02-01 13:47:27 +01:00
|
|
|
|
2019-01-10 01:47:33 +01:00
|
|
|
DialogNotificationSettings get_dialog_notification_settings(tl_object_ptr<telegram_api::peerNotifySettings> &&settings,
|
2022-12-06 13:23:11 +01:00
|
|
|
const DialogNotificationSettings *old_settings);
|
2018-09-29 02:29:57 +02:00
|
|
|
|
2019-03-05 15:15:17 +01:00
|
|
|
bool are_default_dialog_notification_settings(const DialogNotificationSettings &settings, bool compare_sound);
|
|
|
|
|
2022-12-06 14:34:17 +01:00
|
|
|
struct NeedUpdateDialogNotificationSettings {
|
|
|
|
bool need_update_server = false;
|
|
|
|
bool need_update_local = false;
|
|
|
|
bool are_changed = false;
|
|
|
|
};
|
|
|
|
NeedUpdateDialogNotificationSettings need_update_dialog_notification_settings(
|
|
|
|
const DialogNotificationSettings *current_settings, const DialogNotificationSettings &new_settings);
|
|
|
|
|
2018-09-29 02:29:57 +02:00
|
|
|
} // namespace td
|