Update layer 78: new notification settings API.
GitOrigin-RevId: affa0a97035b69e2f710b289f300139e7b41d116
This commit is contained in:
parent
8a1ca6355b
commit
d7d91bbaf3
@ -482,23 +482,24 @@ messages total_count:int32 messages:vector<message> = Messages;
|
||||
foundMessages messages:vector<message> next_from_search_id:int64 = FoundMessages;
|
||||
|
||||
|
||||
//@class NotificationSettingsScope @description Describes the types of chats for which notification settings are applied
|
||||
//@class NotificationSettingsScope @description Describes the types of chats for which scope notification settings are applied
|
||||
|
||||
//@description Notification settings applied to a particular chat @chat_id Chat identifier
|
||||
notificationSettingsScopeChat chat_id:int53 = NotificationSettingsScope;
|
||||
|
||||
//@description Notification settings applied to all private chats
|
||||
//@description Notification settings applied to all private and secret chats when corresponding chat setting has a default value
|
||||
notificationSettingsScopePrivateChats = NotificationSettingsScope;
|
||||
|
||||
//@description Notification settings applied to all basic groups and channels. (Supergroups have no common settings)
|
||||
notificationSettingsScopeBasicGroupChats = NotificationSettingsScope;
|
||||
|
||||
//@description Notification settings applied to all chats
|
||||
notificationSettingsScopeAllChats = NotificationSettingsScope;
|
||||
//@description Notification settings applied to all basic groups, supergroups and channels when corresponding chat setting has a default value
|
||||
notificationSettingsScopeGroupChats = NotificationSettingsScope;
|
||||
|
||||
|
||||
//@description Contains information about notification settings for a chat or several chats @mute_for Time left before notifications will be unmuted, in seconds @sound An audio file name for notification sounds; only applies to iOS applications @show_preview True, if message content should be displayed in notifications
|
||||
notificationSettings mute_for:int32 sound:string show_preview:Bool = NotificationSettings;
|
||||
//@description Contains information about notification settings for a chat
|
||||
//@use_default_mute_for If true, mute_for is ignored and value from a surrounding scope is used instead @mute_for Time left before notifications will be unmuted, in seconds
|
||||
//@use_default_sound If true, sound is ignored and value from a surrounding scope is used instead @sound An audio file name for notification sounds; only applies to iOS applications
|
||||
//@use_default_show_preview If true, show_preview is ignored and value from a surrounding scope is used instead @show_preview True, if message content should be displayed in notifications
|
||||
chatNotificationSettings use_default_mute_for:Bool mute_for:int32 use_default_sound:Bool sound:string use_default_show_preview:Bool show_preview:Bool = ChatNotificationSettings;
|
||||
|
||||
//@description Contains information about notification settings for several chats @mute_for Time left before notifications will be unmuted, in seconds
|
||||
//@sound An audio file name for notification sounds; only applies to iOS applications @show_preview True, if message content should be displayed in notifications
|
||||
scopeNotificationSettings mute_for:int32 sound:string show_preview:Bool = ScopeNotificationSettings;
|
||||
|
||||
|
||||
//@description Contains information about a message draft @reply_to_message_id Identifier of the message to reply to; 0 if none @input_message_text Content of the message draft; this should always be of type inputMessageText
|
||||
@ -537,7 +538,7 @@ chatTypeSecret secret_chat_id:int32 user_id:int32 = ChatType;
|
||||
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
|
||||
//@draft_message A draft of a message in the chat; may be null
|
||||
//@client_data Contains client-specific data associated with the chat. (For example, the chat position or local chat notification settings can be stored here.) Persistent if a message database is used
|
||||
chat id:int53 type:ChatType title:string photo:chatPhoto last_message:message order:int64 is_pinned:Bool can_be_reported:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:notificationSettings reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
|
||||
chat id:int53 type:ChatType title:string photo:chatPhoto last_message:message order:int64 is_pinned:Bool can_be_reported:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:chatNotificationSettings reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
|
||||
|
||||
//@description Represents a list of chats @chat_ids List of chat identifiers
|
||||
chats chat_ids:vector<int53> = Chats;
|
||||
@ -1904,8 +1905,11 @@ updateChatReadOutbox chat_id:int53 last_read_outbox_message_id:int53 = Update;
|
||||
//@description The chat unread_mention_count has changed @chat_id Chat identifier @unread_mention_count The number of unread mention messages left in the chat
|
||||
updateChatUnreadMentionCount chat_id:int53 unread_mention_count:int32 = Update;
|
||||
|
||||
//@description Notification settings for some chats were updated @scope Types of chats for which notification settings were updated @notification_settings The new notification settings
|
||||
updateNotificationSettings scope:NotificationSettingsScope notification_settings:notificationSettings = Update;
|
||||
//@description Notification settings for a chat were changed @chat_id Chat identifier @notification_settings The new notification settings
|
||||
updateChatNotificationSettings chat_id:int53 notification_settings:chatNotificationSettings = Update;
|
||||
|
||||
//@description Notification settings for some chats scope were updated @scope Types of chats for which notification settings were updated @notification_settings The new notification settings
|
||||
updateScopeNotificationSettings scope:NotificationSettingsScope notification_settings:scopeNotificationSettings = Update;
|
||||
|
||||
//@description The default chat reply markup was changed. Can occur because new messages with reply markup were received or because an old reply markup was hidden by the user
|
||||
//@chat_id Chat identifier @reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
|
||||
@ -2450,6 +2454,9 @@ setChatPhoto chat_id:int53 photo:InputFile = Ok;
|
||||
//@description Changes the draft message in a chat @chat_id Chat identifier @draft_message New draft message; may be null
|
||||
setChatDraftMessage chat_id:int53 draft_message:draftMessage = Ok;
|
||||
|
||||
//@description Changes notification settings of a chat @chat_id Chat identifier @notification_settings The new notification settings for the chat
|
||||
setChatNotificationSettings chat_id:int53 notification_settings:chatNotificationSettings = Ok;
|
||||
|
||||
//@description Changes the pinned state of a chat. You can pin up to GetOption("pinned_chat_count_max") non-secret chats and the same number of secret chats @chat_id Chat identifier @is_pinned New value of is_pinned
|
||||
toggleChatIsPinned chat_id:int53 is_pinned:Bool = Ok;
|
||||
|
||||
@ -2478,6 +2485,16 @@ searchChatMembers chat_id:int53 query:string limit:int32 = ChatMembers;
|
||||
getChatAdministrators chat_id:int53 = Users;
|
||||
|
||||
|
||||
//@description Returns the notification settings for a given scope @scope Scope for which to return the notification settings information
|
||||
getScopeNotificationSettings scope:NotificationSettingsScope = ScopeNotificationSettings;
|
||||
|
||||
//@description Changes notification settings for a given scope @scope Scope for which to change the notification settings @notification_settings The new notification settings for the given scope
|
||||
setScopeNotificationSettings scope:NotificationSettingsScope notification_settings:scopeNotificationSettings = Ok;
|
||||
|
||||
//@description Resets all notification settings to their default values. By default, all chats are unmuted, the sound is set to "default" and message previews are shown
|
||||
resetAllNotificationSettings = Ok;
|
||||
|
||||
|
||||
//@description Changes the order of pinned chats @chat_ids The new list of pinned chats
|
||||
setPinnedChats chat_ids:vector<int53> = Ok;
|
||||
|
||||
@ -2669,17 +2686,6 @@ getWebPagePreview text:formattedText = WebPage;
|
||||
getWebPageInstantView url:string force_full:Bool = WebPageInstantView;
|
||||
|
||||
|
||||
//@description Returns the notification settings for a given scope @scope Scope for which to return the notification settings information
|
||||
getNotificationSettings scope:NotificationSettingsScope = NotificationSettings;
|
||||
|
||||
//@description Changes notification settings for a given scope @scope Scope for which to change the notification settings
|
||||
//@notification_settings The new notification settings for the given scope
|
||||
setNotificationSettings scope:NotificationSettingsScope notification_settings:notificationSettings = Ok;
|
||||
|
||||
//@description Resets all notification settings to their default values. By default, the only muted chats are supergroups, the sound is set to "default" and message previews are shown
|
||||
resetAllNotificationSettings = Ok;
|
||||
|
||||
|
||||
//@description Uploads a new profile photo for the current user. If something changes, updateUser will be sent @photo Profile photo to set. inputFileId and inputFileRemote may still be unsupported
|
||||
setProfilePhoto photo:InputFile = Ok;
|
||||
|
||||
|
Binary file not shown.
@ -183,18 +183,10 @@ auth.exportedAuthorization#df969c2d id:int bytes:bytes = auth.ExportedAuthorizat
|
||||
inputNotifyPeer#b8bc5b0c peer:InputPeer = InputNotifyPeer;
|
||||
inputNotifyUsers#193b4417 = InputNotifyPeer;
|
||||
inputNotifyChats#4a95e84e = InputNotifyPeer;
|
||||
inputNotifyAll#a429b886 = InputNotifyPeer;
|
||||
|
||||
inputPeerNotifyEventsEmpty#f03064d8 = InputPeerNotifyEvents;
|
||||
inputPeerNotifyEventsAll#e86a2c74 = InputPeerNotifyEvents;
|
||||
inputPeerNotifySettings#9c3d198e flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = InputPeerNotifySettings;
|
||||
|
||||
inputPeerNotifySettings#38935eb2 flags:# show_previews:flags.0?true silent:flags.1?true mute_until:int sound:string = InputPeerNotifySettings;
|
||||
|
||||
peerNotifyEventsEmpty#add53cb3 = PeerNotifyEvents;
|
||||
peerNotifyEventsAll#6d1ded88 = PeerNotifyEvents;
|
||||
|
||||
peerNotifySettingsEmpty#70a68512 = PeerNotifySettings;
|
||||
peerNotifySettings#9acda4c0 flags:# show_previews:flags.0?true silent:flags.1?true mute_until:int sound:string = PeerNotifySettings;
|
||||
peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = PeerNotifySettings;
|
||||
|
||||
peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings;
|
||||
|
||||
@ -395,7 +387,6 @@ help.support#17c6b5f6 phone_number:string user:User = help.Support;
|
||||
notifyPeer#9fd40bd8 peer:Peer = NotifyPeer;
|
||||
notifyUsers#b4c83b4c = NotifyPeer;
|
||||
notifyChats#c007cec3 = NotifyPeer;
|
||||
notifyAll#74d07c60 = NotifyPeer;
|
||||
|
||||
sendMessageTypingAction#16bf744e = SendMessageAction;
|
||||
sendMessageCancelAction#fd5ec8f5 = SendMessageAction;
|
||||
|
Binary file not shown.
@ -6265,7 +6265,7 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
|
||||
}
|
||||
|
||||
on_update_user_links(user_id, std::move(user_full->link_->my_link_), std::move(user_full->link_->foreign_link_));
|
||||
td_->messages_manager_->on_update_notify_settings(DialogId(user_id).get(), std::move(user_full->notify_settings_));
|
||||
td_->messages_manager_->on_update_dialog_notify_settings(DialogId(user_id), std::move(user_full->notify_settings_));
|
||||
|
||||
UserFull *user = &users_full_[user_id];
|
||||
user->expires_at = Time::now() + USER_FULL_EXPIRE_TIME;
|
||||
@ -6438,7 +6438,7 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
|
||||
}
|
||||
|
||||
on_get_chat_participants(std::move(chat_full->participants_));
|
||||
td_->messages_manager_->on_update_notify_settings(DialogId(chat_id).get(), std::move(chat_full->notify_settings_));
|
||||
td_->messages_manager_->on_update_dialog_notify_settings(DialogId(chat_id), std::move(chat_full->notify_settings_));
|
||||
|
||||
update_chat_full(chat, chat_id);
|
||||
} else {
|
||||
@ -6450,8 +6450,8 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
|
||||
return;
|
||||
}
|
||||
|
||||
td_->messages_manager_->on_update_notify_settings(DialogId(channel_id).get(),
|
||||
std::move(channel_full->notify_settings_));
|
||||
td_->messages_manager_->on_update_dialog_notify_settings(DialogId(channel_id),
|
||||
std::move(channel_full->notify_settings_));
|
||||
|
||||
// Ignoring channel_full->photo
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -678,37 +678,73 @@ class DraftMessage {
|
||||
InputMessageText input_message_text;
|
||||
};
|
||||
|
||||
using NotificationSettingsScope = int64;
|
||||
constexpr NotificationSettingsScope NOTIFICATION_SETTINGS_FOR_PRIVATE_CHATS =
|
||||
std::numeric_limits<NotificationSettingsScope>::min();
|
||||
constexpr NotificationSettingsScope NOTIFICATION_SETTINGS_FOR_GROUP_CHATS =
|
||||
std::numeric_limits<NotificationSettingsScope>::min() + 1;
|
||||
constexpr NotificationSettingsScope NOTIFICATION_SETTINGS_FOR_ALL_CHATS =
|
||||
std::numeric_limits<NotificationSettingsScope>::min() + 2;
|
||||
|
||||
class NotificationSettings {
|
||||
class DialogNotificationSettings {
|
||||
public:
|
||||
int32 mute_until = 0;
|
||||
string sound = "default";
|
||||
bool show_preview = true;
|
||||
bool silent_send_message = false;
|
||||
bool use_default_mute_until = true;
|
||||
bool use_default_sound = true;
|
||||
bool use_default_show_preview = true;
|
||||
bool is_use_default_fixed = true;
|
||||
bool is_synchronized = false;
|
||||
|
||||
NotificationSettings() = default;
|
||||
DialogNotificationSettings() = default;
|
||||
|
||||
NotificationSettings(int32 mute_until, string sound, bool show_preview, bool silent_send_message)
|
||||
DialogNotificationSettings(bool use_default_mute_until, int32 mute_until, bool use_default_sound, string sound,
|
||||
bool use_default_show_preview, bool show_preview, bool silent_send_message)
|
||||
: 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_sound(use_default_sound)
|
||||
, use_default_show_preview(use_default_show_preview)
|
||||
, is_synchronized(true) {
|
||||
}
|
||||
};
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &string_builder, NotificationSettings notification_settings) {
|
||||
enum class NotificationSettingsScope { Private, Group };
|
||||
|
||||
class ScopeNotificationSettings {
|
||||
public:
|
||||
int32 mute_until = 0;
|
||||
string sound = "default";
|
||||
bool show_preview = true;
|
||||
bool is_synchronized = false;
|
||||
|
||||
ScopeNotificationSettings() = default;
|
||||
|
||||
ScopeNotificationSettings(int32 mute_until, string sound, bool show_preview)
|
||||
: mute_until(mute_until), sound(std::move(sound)), show_preview(show_preview), is_synchronized(true) {
|
||||
}
|
||||
};
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &string_builder, DialogNotificationSettings notification_settings) {
|
||||
return string_builder << "[" << notification_settings.mute_until << ", " << notification_settings.sound << ", "
|
||||
<< notification_settings.show_preview << ", " << notification_settings.silent_send_message
|
||||
<< ", " << notification_settings.is_synchronized << "]";
|
||||
<< ", " << notification_settings.use_default_mute_until << ", "
|
||||
<< notification_settings.use_default_sound << ", "
|
||||
<< notification_settings.use_default_show_preview << ", "
|
||||
<< notification_settings.is_synchronized << "]";
|
||||
}
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &string_builder, NotificationSettingsScope scope) {
|
||||
switch (scope) {
|
||||
case NotificationSettingsScope::Private:
|
||||
return string_builder << "notification settings for private chats";
|
||||
case NotificationSettingsScope::Group:
|
||||
return string_builder << "notification settings for group chats";
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return string_builder;
|
||||
}
|
||||
}
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &string_builder, ScopeNotificationSettings notification_settings) {
|
||||
return string_builder << "[" << notification_settings.mute_until << ", " << notification_settings.sound << ", "
|
||||
<< notification_settings.show_preview << ", " << notification_settings.is_synchronized << "]";
|
||||
}
|
||||
|
||||
inline constexpr size_t search_messages_filter_size() {
|
||||
@ -1214,13 +1250,23 @@ class MessagesManager : public Actor {
|
||||
static tl_object_ptr<td_api::NotificationSettingsScope> get_notification_settings_scope_object(
|
||||
NotificationSettingsScope scope);
|
||||
|
||||
static tl_object_ptr<td_api::notificationSettings> get_notification_settings_object(
|
||||
const NotificationSettings *notification_settings);
|
||||
static tl_object_ptr<td_api::chatNotificationSettings> get_chat_notification_settings_object(
|
||||
const DialogNotificationSettings *notification_settings);
|
||||
|
||||
const NotificationSettings *get_notification_settings(NotificationSettingsScope scope, Promise<Unit> &&promise);
|
||||
static tl_object_ptr<td_api::scopeNotificationSettings> get_scope_notification_settings_object(
|
||||
const ScopeNotificationSettings *notification_settings);
|
||||
|
||||
Status set_notification_settings(NotificationSettingsScope scope,
|
||||
tl_object_ptr<td_api::notificationSettings> &¬ification_settings)
|
||||
const DialogNotificationSettings *get_dialog_notification_settings(DialogId dialog_id, Promise<Unit> &&promise);
|
||||
|
||||
const ScopeNotificationSettings *get_scope_notification_settings(NotificationSettingsScope scope,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
Status set_dialog_notification_settings(DialogId dialog_id,
|
||||
tl_object_ptr<td_api::chatNotificationSettings> &¬ification_settings)
|
||||
TD_WARN_UNUSED_RESULT;
|
||||
|
||||
Status set_scope_notification_settings(NotificationSettingsScope scope,
|
||||
tl_object_ptr<td_api::scopeNotificationSettings> &¬ification_settings)
|
||||
TD_WARN_UNUSED_RESULT;
|
||||
|
||||
void reset_all_notification_settings();
|
||||
@ -1290,16 +1336,18 @@ class MessagesManager : public Actor {
|
||||
|
||||
static SearchMessagesFilter get_search_messages_filter(const tl_object_ptr<td_api::SearchMessagesFilter> &filter);
|
||||
|
||||
tl_object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(NotificationSettingsScope scope) const;
|
||||
tl_object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(DialogId dialogId) const;
|
||||
|
||||
NotificationSettingsScope get_notification_settings_scope(
|
||||
tl_object_ptr<telegram_api::NotifyPeer> &¬ify_peer_ptr) const;
|
||||
static tl_object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(NotificationSettingsScope scope);
|
||||
|
||||
NotificationSettingsScope get_notification_settings_scope(
|
||||
const tl_object_ptr<td_api::NotificationSettingsScope> &scope) const;
|
||||
static NotificationSettingsScope get_notification_settings_scope(
|
||||
const tl_object_ptr<td_api::NotificationSettingsScope> &scope);
|
||||
|
||||
void on_update_notify_settings(NotificationSettingsScope scope,
|
||||
tl_object_ptr<telegram_api::PeerNotifySettings> &&peer_notify_settings);
|
||||
void on_update_dialog_notify_settings(DialogId dialog_id,
|
||||
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings);
|
||||
|
||||
void on_update_scope_notify_settings(NotificationSettingsScope scope,
|
||||
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings);
|
||||
|
||||
bool get_dialog_report_spam_state(DialogId dialog_id, Promise<Unit> &&promise);
|
||||
|
||||
@ -1525,7 +1573,7 @@ class MessagesManager : public Actor {
|
||||
MessageId last_read_inbox_message_id;
|
||||
MessageId last_read_outbox_message_id;
|
||||
MessageId reply_markup_message_id;
|
||||
NotificationSettings notification_settings;
|
||||
DialogNotificationSettings notification_settings;
|
||||
unique_ptr<DraftMessage> draft_message;
|
||||
uint64 save_draft_message_logevent_id = 0;
|
||||
uint64 save_draft_message_logevent_id_generation = 0;
|
||||
@ -2188,13 +2236,21 @@ class MessagesManager : public Actor {
|
||||
|
||||
static string get_notification_settings_scope_database_key(NotificationSettingsScope scope);
|
||||
|
||||
bool update_notification_settings(NotificationSettingsScope scope, NotificationSettings *current_settings,
|
||||
const NotificationSettings &new_settings);
|
||||
bool update_dialog_notification_settings(DialogId dialog_id, DialogNotificationSettings *current_settings,
|
||||
const DialogNotificationSettings &new_settings);
|
||||
|
||||
void update_dialog_unmute_timeout(Dialog *d, int32 old_mute_until, int32 new_mute_until);
|
||||
bool update_scope_notification_settings(NotificationSettingsScope scope, ScopeNotificationSettings *current_settings,
|
||||
const ScopeNotificationSettings &new_settings);
|
||||
|
||||
void update_dialog_unmute_timeout(Dialog *d, bool old_use_default, int32 old_mute_until, bool new_use_default,
|
||||
int32 new_mute_until);
|
||||
|
||||
void update_scope_unmute_timeout(NotificationSettingsScope scope, int32 old_mute_until, int32 new_mute_until);
|
||||
|
||||
void on_dialog_unmute(DialogId dialog_id);
|
||||
|
||||
void on_scope_unmute(NotificationSettingsScope scope);
|
||||
|
||||
void on_send_dialog_action_timeout(DialogId dialog_id);
|
||||
|
||||
void on_active_dialog_action_timeout(DialogId dialog_id);
|
||||
@ -2273,12 +2329,21 @@ class MessagesManager : public Actor {
|
||||
void on_get_dialog_message_by_date_from_database(DialogId dialog_id, int32 date, int64 random_id,
|
||||
Result<BufferSlice> result, Promise<Unit> promise);
|
||||
|
||||
static NotificationSettings get_notification_settings(
|
||||
tl_object_ptr<telegram_api::PeerNotifySettings> &¬ification_settings);
|
||||
static DialogNotificationSettings get_dialog_notification_settings(
|
||||
tl_object_ptr<telegram_api::peerNotifySettings> &&settings);
|
||||
|
||||
const NotificationSettings *get_dialog_notification_settings(const Dialog *d, DialogId dialog_id) const;
|
||||
static ScopeNotificationSettings get_scope_notification_settings(
|
||||
tl_object_ptr<telegram_api::peerNotifySettings> &&settings);
|
||||
|
||||
NotificationSettings *get_notification_settings(NotificationSettingsScope scope, bool force);
|
||||
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);
|
||||
|
||||
int32 get_scope_mute_until(DialogId dialog_id) const;
|
||||
|
||||
DialogNotificationSettings *get_dialog_notification_settings(DialogId dialog_id, bool force);
|
||||
|
||||
ScopeNotificationSettings *get_scope_notification_settings(NotificationSettingsScope scope);
|
||||
|
||||
static unique_ptr<DraftMessage> get_draft_message(ContactsManager *contacts_manager,
|
||||
tl_object_ptr<telegram_api::DraftMessage> &&draft_message_ptr);
|
||||
@ -2690,9 +2755,8 @@ class MessagesManager : public Actor {
|
||||
|
||||
std::unordered_map<DialogId, std::vector<ActiveDialogAction>, DialogIdHash> active_dialog_actions_;
|
||||
|
||||
NotificationSettings users_notification_settings_;
|
||||
NotificationSettings chats_notification_settings_;
|
||||
NotificationSettings dialogs_notification_settings_;
|
||||
ScopeNotificationSettings users_notification_settings_;
|
||||
ScopeNotificationSettings chats_notification_settings_;
|
||||
|
||||
bool have_postponed_unread_message_count_update_ = false;
|
||||
bool is_unread_count_inited_ = false;
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "td/utils/base64.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
GetSecureValue::GetSecureValue(ActorShared<> parent, std::string password, SecureValueType type,
|
||||
|
@ -2690,22 +2690,22 @@ class GetUserProfilePhotosRequest : public RequestActor<> {
|
||||
}
|
||||
};
|
||||
|
||||
class GetNotificationSettingsRequest : public RequestActor<> {
|
||||
class GetScopeNotificationSettingsRequest : public RequestActor<> {
|
||||
NotificationSettingsScope scope_;
|
||||
|
||||
const NotificationSettings *notification_settings_ = nullptr;
|
||||
const ScopeNotificationSettings *notification_settings_ = nullptr;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) override {
|
||||
notification_settings_ = td->messages_manager_->get_notification_settings(scope_, std::move(promise));
|
||||
notification_settings_ = td->messages_manager_->get_scope_notification_settings(scope_, std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() override {
|
||||
CHECK(notification_settings_ != nullptr);
|
||||
send_result(td->messages_manager_->get_notification_settings_object(notification_settings_));
|
||||
send_result(td->messages_manager_->get_scope_notification_settings_object(notification_settings_));
|
||||
}
|
||||
|
||||
public:
|
||||
GetNotificationSettingsRequest(ActorShared<Td> td, uint64 request_id, NotificationSettingsScope scope)
|
||||
GetScopeNotificationSettingsRequest(ActorShared<Td> td, uint64 request_id, NotificationSettingsScope scope)
|
||||
: RequestActor(std::move(td), request_id), scope_(scope) {
|
||||
}
|
||||
};
|
||||
@ -3878,6 +3878,7 @@ void Td::request(uint64 id, tl_object_ptr<td_api::Function> function) {
|
||||
return send_error_raw(id, 400, "Request is empty");
|
||||
}
|
||||
|
||||
VLOG(td_requests) << "Receive request " << id << ": " << to_string(function);
|
||||
switch (state_) {
|
||||
case State::WaitParameters: {
|
||||
switch (function->get_id()) {
|
||||
@ -3934,7 +3935,6 @@ void Td::request(uint64 id, tl_object_ptr<td_api::Function> function) {
|
||||
break;
|
||||
}
|
||||
|
||||
VLOG(td_requests) << "Receive request " << id << ": " << to_string(function);
|
||||
downcast_call(*function, [this, id](auto &request) { this->on_request(id, request); });
|
||||
}
|
||||
|
||||
@ -6534,10 +6534,13 @@ void Td::on_request(uint64 id, td_api::removeSavedAnimation &request) {
|
||||
CREATE_REQUEST(RemoveSavedAnimationRequest, std::move(request.animation_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getNotificationSettings &request) {
|
||||
void Td::on_request(uint64 id, const td_api::getScopeNotificationSettings &request) {
|
||||
CHECK_AUTH();
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST(GetNotificationSettingsRequest, messages_manager_->get_notification_settings_scope(request.scope_));
|
||||
if (request.scope_ == nullptr) {
|
||||
return send_error_raw(id, 400, "Scope must not be empty");
|
||||
}
|
||||
CREATE_REQUEST(GetScopeNotificationSettingsRequest, MessagesManager::get_notification_settings_scope(request.scope_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getChatReportSpamState &request) {
|
||||
@ -6558,12 +6561,21 @@ void Td::on_request(uint64 id, td_api::reportChat &request) {
|
||||
CREATE_REQUEST(ReportChatRequest, request.chat_id_, std::move(request.reason_), request.message_ids_);
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setNotificationSettings &request) {
|
||||
void Td::on_request(uint64 id, td_api::setChatNotificationSettings &request) {
|
||||
CHECK_AUTH();
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.notification_settings_->sound_);
|
||||
answer_ok_query(id, messages_manager_->set_notification_settings(
|
||||
messages_manager_->get_notification_settings_scope(request.scope_),
|
||||
answer_ok_query(id, messages_manager_->set_dialog_notification_settings(DialogId(request.chat_id_),
|
||||
std::move(request.notification_settings_)));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setScopeNotificationSettings &request) {
|
||||
CHECK_AUTH();
|
||||
CHECK_IS_USER();
|
||||
if (request.scope_ == nullptr) {
|
||||
return send_error_raw(id, 400, "Scope must not be empty");
|
||||
}
|
||||
answer_ok_query(id, messages_manager_->set_scope_notification_settings(
|
||||
MessagesManager::get_notification_settings_scope(request.scope_),
|
||||
std::move(request.notification_settings_)));
|
||||
}
|
||||
|
||||
|
@ -707,9 +707,11 @@ class Td final : public NetQueryCallback {
|
||||
|
||||
void on_request(uint64 id, td_api::removeFavoriteSticker &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getNotificationSettings &request);
|
||||
void on_request(uint64 id, const td_api::getScopeNotificationSettings &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setNotificationSettings &request);
|
||||
void on_request(uint64 id, td_api::setChatNotificationSettings &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setScopeNotificationSettings &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::resetAllNotificationSettings &request);
|
||||
|
||||
|
@ -1479,9 +1479,25 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannelAvailabl
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNotifySettings> update, bool /*force_apply*/) {
|
||||
CHECK(update != nullptr);
|
||||
td_->messages_manager_->on_update_notify_settings(
|
||||
td_->messages_manager_->get_notification_settings_scope(std::move(update->peer_)),
|
||||
std::move(update->notify_settings_));
|
||||
switch (update->peer_->get_id()) {
|
||||
case telegram_api::notifyPeer::ID: {
|
||||
DialogId dialog_id(static_cast<const telegram_api::notifyPeer *>(update->peer_.get())->peer_);
|
||||
if (dialog_id.is_valid()) {
|
||||
td_->messages_manager_->on_update_dialog_notify_settings(dialog_id, std::move(update->notify_settings_));
|
||||
} else {
|
||||
LOG(ERROR) << "Receive wrong " << to_string(update);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case telegram_api::notifyUsers::ID:
|
||||
return td_->messages_manager_->on_update_scope_notify_settings(NotificationSettingsScope::Private,
|
||||
std::move(update->notify_settings_));
|
||||
case telegram_api::notifyChats::ID:
|
||||
return td_->messages_manager_->on_update_scope_notify_settings(NotificationSettingsScope::Group,
|
||||
std::move(update->notify_settings_));
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateWebPage> update, bool force_apply) {
|
||||
|
@ -773,15 +773,10 @@ class CliClient final : public Actor {
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::NotificationSettingsScope> get_notification_settings_scope(Slice scope) const {
|
||||
if (scope == "users" || scope == "privateChats") {
|
||||
return make_tl_object<td_api::notificationSettingsScopePrivateChats>();
|
||||
} else if (scope == "chats" || scope == "groups" || scope == "groupChats") {
|
||||
return make_tl_object<td_api::notificationSettingsScopeBasicGroupChats>();
|
||||
} else if (scope == "all" || scope == "dialogs") {
|
||||
return make_tl_object<td_api::notificationSettingsScopeAllChats>();
|
||||
} else {
|
||||
return make_tl_object<td_api::notificationSettingsScopeChat>(as_chat_id(scope));
|
||||
if (scope == "chats" || scope == "groups" || scope == "channels" || as_bool(scope.str())) {
|
||||
return make_tl_object<td_api::notificationSettingsScopeGroupChats>();
|
||||
}
|
||||
return make_tl_object<td_api::notificationSettingsScopePrivateChats>();
|
||||
}
|
||||
|
||||
static tl_object_ptr<td_api::UserPrivacySetting> get_user_privacy_setting(MutableSlice setting) {
|
||||
@ -2878,9 +2873,26 @@ class CliClient final : public Actor {
|
||||
send_request(make_tl_object<td_api::readAllChatMentions>(as_chat_id(chat_id)));
|
||||
} else if (op == "dpp") {
|
||||
send_request(make_tl_object<td_api::deleteProfilePhoto>(to_integer<int64>(args)));
|
||||
} else if (op == "gns") {
|
||||
send_request(make_tl_object<td_api::getNotificationSettings>(get_notification_settings_scope(args)));
|
||||
} else if (op == "sns") {
|
||||
} else if (op == "gsns") {
|
||||
send_request(make_tl_object<td_api::getScopeNotificationSettings>(get_notification_settings_scope(args)));
|
||||
} else if (op == "scns") {
|
||||
string chat_id;
|
||||
string settings;
|
||||
|
||||
std::tie(chat_id, settings) = split(args);
|
||||
|
||||
string mute_for;
|
||||
string sound;
|
||||
string show_previews;
|
||||
|
||||
std::tie(mute_for, settings) = split(settings, ',');
|
||||
std::tie(sound, show_previews) = split(settings, ',');
|
||||
|
||||
send_request(make_tl_object<td_api::setChatNotificationSettings>(
|
||||
as_chat_id(chat_id),
|
||||
make_tl_object<td_api::chatNotificationSettings>(mute_for.empty(), to_integer<int32>(mute_for), sound.empty(),
|
||||
sound, show_previews.empty(), as_bool(show_previews))));
|
||||
} else if (op == "ssns") {
|
||||
string scope;
|
||||
string settings;
|
||||
|
||||
@ -2893,9 +2905,9 @@ class CliClient final : public Actor {
|
||||
std::tie(mute_for, settings) = split(settings, ',');
|
||||
std::tie(sound, show_previews) = split(settings, ',');
|
||||
|
||||
send_request(make_tl_object<td_api::setNotificationSettings>(
|
||||
get_notification_settings_scope(scope),
|
||||
make_tl_object<td_api::notificationSettings>(to_integer<int32>(mute_for), sound, as_bool(show_previews))));
|
||||
send_request(make_tl_object<td_api::setScopeNotificationSettings>(
|
||||
get_notification_settings_scope(scope), make_tl_object<td_api::scopeNotificationSettings>(
|
||||
to_integer<int32>(mute_for), sound, as_bool(show_previews))));
|
||||
} else if (op == "rans") {
|
||||
send_request(make_tl_object<td_api::resetAllNotificationSettings>());
|
||||
} else if (op == "gcrss") {
|
||||
|
Loading…
Reference in New Issue
Block a user