2018-09-29 02:29:57 +02:00
|
|
|
//
|
2022-01-01 01:35:39 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
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;
|
2018-09-29 02:29:57 +02:00
|
|
|
bool show_preview = true;
|
|
|
|
bool silent_send_message = false;
|
|
|
|
bool use_default_mute_until = true;
|
|
|
|
bool use_default_show_preview = true;
|
|
|
|
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,
|
2019-01-10 01:47:33 +01:00
|
|
|
bool use_default_show_preview, bool show_preview, 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))
|
|
|
|
, show_preview(show_preview)
|
|
|
|
, silent_send_message(silent_send_message)
|
|
|
|
, use_default_mute_until(use_default_mute_until)
|
|
|
|
, use_default_show_preview(use_default_show_preview)
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-29 12:40:56 +01:00
|
|
|
enum class NotificationSettingsScope : int32 { Private, Group, Channel };
|
2018-09-29 02:29:57 +02:00
|
|
|
|
|
|
|
class ScopeNotificationSettings {
|
|
|
|
public:
|
|
|
|
int32 mute_until = 0;
|
2022-04-11 19:01:44 +02:00
|
|
|
unique_ptr<NotificationSound> sound;
|
2018-09-29 02:29:57 +02:00
|
|
|
bool show_preview = true;
|
|
|
|
bool is_synchronized = false;
|
|
|
|
|
2019-01-10 01:47:33 +01:00
|
|
|
// local settings
|
2019-01-10 18:54:46 +01:00
|
|
|
bool disable_pinned_message_notifications = false;
|
|
|
|
bool disable_mention_notifications = false;
|
2019-01-10 01:47:33 +01:00
|
|
|
|
2018-09-29 02:29:57 +02:00
|
|
|
ScopeNotificationSettings() = default;
|
|
|
|
|
2022-04-11 19:01:44 +02:00
|
|
|
ScopeNotificationSettings(int32 mute_until, unique_ptr<NotificationSound> &&sound, bool show_preview,
|
2019-01-10 18:54:46 +01:00
|
|
|
bool disable_pinned_message_notifications, bool disable_mention_notifications)
|
2019-01-10 01:47:33 +01:00
|
|
|
: mute_until(mute_until)
|
|
|
|
, sound(std::move(sound))
|
|
|
|
, show_preview(show_preview)
|
|
|
|
, is_synchronized(true)
|
2019-01-10 18:54:46 +01:00
|
|
|
, disable_pinned_message_notifications(disable_pinned_message_notifications)
|
|
|
|
, disable_mention_notifications(disable_mention_notifications) {
|
2018-09-29 02:29:57 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const DialogNotificationSettings ¬ification_settings);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, NotificationSettingsScope scope);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const ScopeNotificationSettings ¬ification_settings);
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::NotificationSettingsScope> get_notification_settings_scope_object(
|
|
|
|
NotificationSettingsScope scope);
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::chatNotificationSettings> get_chat_notification_settings_object(
|
|
|
|
const DialogNotificationSettings *notification_settings);
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::scopeNotificationSettings> get_scope_notification_settings_object(
|
|
|
|
const ScopeNotificationSettings *notification_settings);
|
|
|
|
|
|
|
|
telegram_api::object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(NotificationSettingsScope scope);
|
|
|
|
|
|
|
|
NotificationSettingsScope get_notification_settings_scope(
|
|
|
|
const td_api::object_ptr<td_api::NotificationSettingsScope> &scope);
|
|
|
|
|
2019-02-01 13:47:27 +01:00
|
|
|
Result<DialogNotificationSettings> get_dialog_notification_settings(
|
|
|
|
td_api::object_ptr<td_api::chatNotificationSettings> &¬ification_settings, bool old_silent_send_message);
|
|
|
|
|
|
|
|
Result<ScopeNotificationSettings> get_scope_notification_settings(
|
|
|
|
td_api::object_ptr<td_api::scopeNotificationSettings> &¬ification_settings);
|
|
|
|
|
2019-01-10 01:47:33 +01:00
|
|
|
DialogNotificationSettings get_dialog_notification_settings(tl_object_ptr<telegram_api::peerNotifySettings> &&settings,
|
2019-01-10 18:54:46 +01:00
|
|
|
bool old_use_default_disable_pinned_message_notifications,
|
|
|
|
bool old_disable_pinned_message_notifications,
|
|
|
|
bool old_use_default_disable_mention_notifications,
|
|
|
|
bool old_disable_mention_notifications);
|
2018-09-29 02:29:57 +02:00
|
|
|
|
2019-01-10 01:47:33 +01:00
|
|
|
ScopeNotificationSettings get_scope_notification_settings(tl_object_ptr<telegram_api::peerNotifySettings> &&settings,
|
2019-01-10 18:54:46 +01:00
|
|
|
bool old_disable_pinned_message_notifications,
|
|
|
|
bool old_disable_mention_notifications);
|
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);
|
|
|
|
|
2018-09-29 02:29:57 +02:00
|
|
|
} // namespace td
|