Separate scope notification settings for channels.
GitOrigin-RevId: 11d11b2ddba5381d9dcac84768d923fa367f0248
This commit is contained in:
parent
a93ec0605e
commit
f465b460ca
@ -515,9 +515,12 @@ foundMessages messages:vector<message> next_from_search_id:int64 = FoundMessages
|
||||
//@description Notification settings applied to all private and secret chats when the corresponding chat setting has a default value
|
||||
notificationSettingsScopePrivateChats = NotificationSettingsScope;
|
||||
|
||||
//@description Notification settings applied to all basic groups, supergroups and channels when the corresponding chat setting has a default value
|
||||
//@description Notification settings applied to all basic groups and supergroups when the corresponding chat setting has a default value
|
||||
notificationSettingsScopeGroupChats = NotificationSettingsScope;
|
||||
|
||||
//@description Notification settings applied to all channels when the corresponding chat setting has a default value
|
||||
notificationSettingsScopeChannelChats = NotificationSettingsScope;
|
||||
|
||||
|
||||
//@description Contains information about notification settings for a chat
|
||||
//@use_default_mute_for If true, mute_for is ignored and the value for the relevant type of chat is used instead @mute_for Time left before notifications will be unmuted, in seconds
|
||||
|
Binary file not shown.
@ -4076,7 +4076,7 @@ void MessagesManager::on_dialog_unmute_timeout_callback(void *messages_manager_p
|
||||
}
|
||||
|
||||
auto messages_manager = static_cast<MessagesManager *>(messages_manager_ptr);
|
||||
if (1 <= dialog_id_int && dialog_id_int <= 2) {
|
||||
if (1 <= dialog_id_int && dialog_id_int <= 3) {
|
||||
send_closure_later(messages_manager->actor_id(messages_manager), &MessagesManager::on_scope_unmute,
|
||||
static_cast<NotificationSettingsScope>(dialog_id_int - 1));
|
||||
} else {
|
||||
@ -5514,6 +5514,8 @@ string MessagesManager::get_notification_settings_scope_database_key(Notificatio
|
||||
return "nsfpc";
|
||||
case NotificationSettingsScope::Group:
|
||||
return "nsfgc";
|
||||
case NotificationSettingsScope::Channel:
|
||||
return "nsfcc";
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return "";
|
||||
@ -8722,7 +8724,8 @@ void MessagesManager::init() {
|
||||
|
||||
load_calls_db_state();
|
||||
|
||||
vector<NotificationSettingsScope> scopes{NotificationSettingsScope::Private, NotificationSettingsScope::Group};
|
||||
vector<NotificationSettingsScope> scopes{NotificationSettingsScope::Private, NotificationSettingsScope::Group,
|
||||
NotificationSettingsScope::Channel};
|
||||
for (auto scope : scopes) {
|
||||
auto notification_settings_string =
|
||||
G()->td_db()->get_binlog_pmc()->get(get_notification_settings_scope_database_key(scope));
|
||||
@ -8736,6 +8739,11 @@ void MessagesManager::init() {
|
||||
update_scope_notification_settings(scope, current_settings, notification_settings);
|
||||
}
|
||||
}
|
||||
if (!channels_notification_settings_.is_synchronized) {
|
||||
channels_notification_settings_ = chats_notification_settings_;
|
||||
channels_notification_settings_.is_synchronized = false;
|
||||
send_get_scope_notification_settings_query(NotificationSettingsScope::Channel, Promise<>());
|
||||
}
|
||||
G()->td_db()->get_binlog_pmc()->erase("nsfac");
|
||||
|
||||
/*
|
||||
@ -12793,14 +12801,15 @@ std::pair<bool, int32> MessagesManager::get_dialog_mute_until(DialogId dialog_id
|
||||
return {d->notification_settings.is_use_default_fixed, get_dialog_mute_until(d)};
|
||||
}
|
||||
|
||||
NotificationSettingsScope MessagesManager::get_dialog_notification_setting_scope(DialogId dialog_id) {
|
||||
NotificationSettingsScope MessagesManager::get_dialog_notification_setting_scope(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
case DialogType::SecretChat:
|
||||
return NotificationSettingsScope::Private;
|
||||
case DialogType::Chat:
|
||||
case DialogType::Channel:
|
||||
return NotificationSettingsScope::Group;
|
||||
case DialogType::Channel:
|
||||
return is_broadcast_channel(dialog_id) ? NotificationSettingsScope::Channel : NotificationSettingsScope::Group;
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -12814,8 +12823,10 @@ int32 MessagesManager::get_scope_mute_until(DialogId dialog_id) const {
|
||||
case DialogType::SecretChat:
|
||||
return users_notification_settings_.mute_until;
|
||||
case DialogType::Chat:
|
||||
case DialogType::Channel:
|
||||
return chats_notification_settings_.mute_until;
|
||||
case DialogType::Channel:
|
||||
return is_broadcast_channel(dialog_id) ? channels_notification_settings_.mute_until
|
||||
: chats_notification_settings_.mute_until;
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -12853,6 +12864,8 @@ ScopeNotificationSettings *MessagesManager::get_scope_notification_settings(Noti
|
||||
return &users_notification_settings_;
|
||||
case NotificationSettingsScope::Group:
|
||||
return &chats_notification_settings_;
|
||||
case NotificationSettingsScope::Channel:
|
||||
return &channels_notification_settings_;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
@ -12866,6 +12879,8 @@ const ScopeNotificationSettings *MessagesManager::get_scope_notification_setting
|
||||
return &users_notification_settings_;
|
||||
case NotificationSettingsScope::Group:
|
||||
return &chats_notification_settings_;
|
||||
case NotificationSettingsScope::Channel:
|
||||
return &channels_notification_settings_;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
@ -12997,6 +13012,8 @@ void MessagesManager::reset_all_notification_settings() {
|
||||
new_scope_settings);
|
||||
update_scope_notification_settings(NotificationSettingsScope::Group, &chats_notification_settings_,
|
||||
new_scope_settings);
|
||||
update_scope_notification_settings(NotificationSettingsScope::Channel, &channels_notification_settings_,
|
||||
new_scope_settings);
|
||||
|
||||
for (auto &dialog : dialogs_) {
|
||||
Dialog *d = dialog.second.get();
|
||||
@ -23194,6 +23211,9 @@ void MessagesManager::load_notification_settings() {
|
||||
if (!chats_notification_settings_.is_synchronized) {
|
||||
send_get_scope_notification_settings_query(NotificationSettingsScope::Group, Promise<>());
|
||||
}
|
||||
if (!channels_notification_settings_.is_synchronized) {
|
||||
send_get_scope_notification_settings_query(NotificationSettingsScope::Channel, Promise<>());
|
||||
}
|
||||
}
|
||||
|
||||
string MessagesManager::get_channel_pts_key(DialogId dialog_id) {
|
||||
@ -24781,7 +24801,8 @@ void MessagesManager::get_current_state(vector<td_api::object_ptr<td_api::Update
|
||||
}
|
||||
}
|
||||
|
||||
vector<NotificationSettingsScope> scopes{NotificationSettingsScope::Private, NotificationSettingsScope::Group};
|
||||
vector<NotificationSettingsScope> scopes{NotificationSettingsScope::Private, NotificationSettingsScope::Group,
|
||||
NotificationSettingsScope::Channel};
|
||||
for (auto scope : scopes) {
|
||||
auto current_settings = get_scope_notification_settings(scope);
|
||||
CHECK(current_settings != nullptr);
|
||||
|
@ -1778,7 +1778,7 @@ class MessagesManager : public Actor {
|
||||
|
||||
std::pair<bool, int32> get_dialog_mute_until(DialogId dialog_id, const Dialog *d) const;
|
||||
|
||||
static NotificationSettingsScope get_dialog_notification_setting_scope(DialogId dialog_id);
|
||||
NotificationSettingsScope get_dialog_notification_setting_scope(DialogId dialog_id) const;
|
||||
|
||||
int32 get_scope_mute_until(DialogId dialog_id) const;
|
||||
|
||||
@ -2214,6 +2214,7 @@ class MessagesManager : public Actor {
|
||||
|
||||
ScopeNotificationSettings users_notification_settings_;
|
||||
ScopeNotificationSettings chats_notification_settings_;
|
||||
ScopeNotificationSettings channels_notification_settings_;
|
||||
|
||||
std::unordered_map<NotificationGroupId, DialogId, NotificationGroupIdHash> notification_group_id_to_dialog_id_;
|
||||
|
||||
|
@ -31,6 +31,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, NotificationSettingsSco
|
||||
return string_builder << "notification settings for private chats";
|
||||
case NotificationSettingsScope::Group:
|
||||
return string_builder << "notification settings for group chats";
|
||||
case NotificationSettingsScope::Channel:
|
||||
return string_builder << "notification settings for channel chats";
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return string_builder;
|
||||
@ -51,6 +53,8 @@ td_api::object_ptr<td_api::NotificationSettingsScope> get_notification_settings_
|
||||
return td_api::make_object<td_api::notificationSettingsScopePrivateChats>();
|
||||
case NotificationSettingsScope::Group:
|
||||
return td_api::make_object<td_api::notificationSettingsScopeGroupChats>();
|
||||
case NotificationSettingsScope::Channel:
|
||||
return td_api::make_object<td_api::notificationSettingsScopeChannelChats>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
@ -85,6 +89,8 @@ telegram_api::object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(No
|
||||
return telegram_api::make_object<telegram_api::inputNotifyUsers>();
|
||||
case NotificationSettingsScope::Group:
|
||||
return telegram_api::make_object<telegram_api::inputNotifyChats>();
|
||||
case NotificationSettingsScope::Channel:
|
||||
return telegram_api::make_object<telegram_api::inputNotifyBroadcasts>();
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
@ -98,6 +104,8 @@ NotificationSettingsScope get_notification_settings_scope(
|
||||
return NotificationSettingsScope::Private;
|
||||
case td_api::notificationSettingsScopeGroupChats::ID:
|
||||
return NotificationSettingsScope::Group;
|
||||
case td_api::notificationSettingsScopeChannelChats::ID:
|
||||
return NotificationSettingsScope::Channel;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return NotificationSettingsScope::Private;
|
||||
|
@ -54,7 +54,7 @@ class DialogNotificationSettings {
|
||||
}
|
||||
};
|
||||
|
||||
enum class NotificationSettingsScope : int32 { Private, Group };
|
||||
enum class NotificationSettingsScope : int32 { Private, Group, Channel };
|
||||
|
||||
class ScopeNotificationSettings {
|
||||
public:
|
||||
|
@ -1521,6 +1521,9 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNotifySettings>
|
||||
case telegram_api::notifyChats::ID:
|
||||
return td_->messages_manager_->on_update_scope_notify_settings(NotificationSettingsScope::Group,
|
||||
std::move(update->notify_settings_));
|
||||
case telegram_api::notifyBroadcasts::ID:
|
||||
return td_->messages_manager_->on_update_scope_notify_settings(NotificationSettingsScope::Channel,
|
||||
std::move(update->notify_settings_));
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
@ -883,7 +883,10 @@ class CliClient final : public Actor {
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::NotificationSettingsScope> get_notification_settings_scope(Slice scope) const {
|
||||
if (scope == "chats" || scope == "groups" || scope == "channels" || as_bool(scope.str())) {
|
||||
if (scope == "channels" || scope == "ch") {
|
||||
return make_tl_object<td_api::notificationSettingsScopeChannelChats>();
|
||||
}
|
||||
if (scope == "chats" || scope == "groups" || as_bool(scope.str())) {
|
||||
return make_tl_object<td_api::notificationSettingsScopeGroupChats>();
|
||||
}
|
||||
return make_tl_object<td_api::notificationSettingsScopePrivateChats>();
|
||||
|
@ -21,7 +21,7 @@ class HeaderStorer {
|
||||
}
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
constexpr int32 LAYER = 86;
|
||||
constexpr int32 LAYER = 87;
|
||||
|
||||
using td::store;
|
||||
// invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = X;
|
||||
|
Loading…
Reference in New Issue
Block a user