mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Support [inputN|n]otifyBroadcasts setting.
This commit is contained in:
@@ -1813,7 +1813,9 @@ void Session::requestNotifySettings(not_null<PeerData*> peer) {
|
||||
if (defaultNotifySettings(peer).settingsUnknown()) {
|
||||
_session->api().requestNotifySettings(peer->isUser()
|
||||
? MTP_inputNotifyUsers()
|
||||
: MTP_inputNotifyChats());
|
||||
: (peer->isChat() || peer->isMegagroup())
|
||||
? MTP_inputNotifyChats()
|
||||
: MTP_inputNotifyBroadcasts());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1840,7 +1842,7 @@ void Session::applyNotifySetting(
|
||||
if (_defaultChatNotifySettings.change(settings)) {
|
||||
_defaultChatNotifyUpdates.fire({});
|
||||
|
||||
App::enumerateChatsChannels([&](not_null<PeerData*> peer) {
|
||||
App::enumerateGroups([&](not_null<PeerData*> peer) {
|
||||
if (!peer->notifySettingsUnknown()
|
||||
&& ((!peer->notifyMuteUntil()
|
||||
&& _defaultChatNotifySettings.muteUntil())
|
||||
@@ -1851,6 +1853,21 @@ void Session::applyNotifySetting(
|
||||
});
|
||||
}
|
||||
} break;
|
||||
case mtpc_notifyBroadcasts: {
|
||||
if (_defaultBroadcastNotifySettings.change(settings)) {
|
||||
_defaultBroadcastNotifyUpdates.fire({});
|
||||
|
||||
App::enumerateChannels([&](not_null<ChannelData*> channel) {
|
||||
if (!channel->notifySettingsUnknown()
|
||||
&& ((!channel->notifyMuteUntil()
|
||||
&& _defaultBroadcastNotifySettings.muteUntil())
|
||||
|| (!channel->notifySilentPosts()
|
||||
&& _defaultBroadcastNotifySettings.silentPosts()))) {
|
||||
updateNotifySettingsLocal(channel);
|
||||
}
|
||||
});
|
||||
}
|
||||
} break;
|
||||
case mtpc_notifyPeer: {
|
||||
const auto &data = notifyPeer.c_notifyPeer();
|
||||
if (const auto peer = App::peerLoaded(peerFromMTP(data.vpeer))) {
|
||||
@@ -1937,11 +1954,17 @@ rpl::producer<> Session::defaultChatNotifyUpdates() const {
|
||||
return _defaultChatNotifyUpdates.events();
|
||||
}
|
||||
|
||||
rpl::producer<> Session::defaultBroadcastNotifyUpdates() const {
|
||||
return _defaultBroadcastNotifyUpdates.events();
|
||||
}
|
||||
|
||||
rpl::producer<> Session::defaultNotifyUpdates(
|
||||
not_null<const PeerData*> peer) const {
|
||||
return peer->isUser()
|
||||
? defaultUserNotifyUpdates()
|
||||
: defaultChatNotifyUpdates();
|
||||
: (peer->isChat() || peer->isMegagroup())
|
||||
? defaultChatNotifyUpdates()
|
||||
: defaultBroadcastNotifyUpdates();
|
||||
}
|
||||
|
||||
void Session::serviceNotification(
|
||||
|
@@ -416,6 +416,7 @@ public:
|
||||
bool notifySettingsUnknown(not_null<const PeerData*> peer) const;
|
||||
rpl::producer<> defaultUserNotifyUpdates() const;
|
||||
rpl::producer<> defaultChatNotifyUpdates() const;
|
||||
rpl::producer<> defaultBroadcastNotifyUpdates() const;
|
||||
rpl::producer<> defaultNotifyUpdates(
|
||||
not_null<const PeerData*> peer) const;
|
||||
|
||||
@@ -641,8 +642,10 @@ private:
|
||||
|
||||
NotifySettings _defaultUserNotifySettings;
|
||||
NotifySettings _defaultChatNotifySettings;
|
||||
NotifySettings _defaultBroadcastNotifySettings;
|
||||
rpl::event_stream<> _defaultUserNotifyUpdates;
|
||||
rpl::event_stream<> _defaultChatNotifyUpdates;
|
||||
rpl::event_stream<> _defaultBroadcastNotifyUpdates;
|
||||
std::unordered_set<not_null<const PeerData*>> _mutedPeers;
|
||||
base::Timer _unmuteByFinishedTimer;
|
||||
|
||||
|
Reference in New Issue
Block a user