Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
@@ -0,0 +1,35 @@
import Foundation
import Postbox
import SwiftSignalKit
func managedNotificationSettingsBehaviors(postbox: Postbox) -> Signal<Never, NoError> {
return postbox.combinedView(keys: [.peerNotificationSettingsBehaviorTimestampView])
|> mapToSignal { views -> Signal<Never, NoError> in
guard let view = views.views[.peerNotificationSettingsBehaviorTimestampView] as? PeerNotificationSettingsBehaviorTimestampView else {
return .complete()
}
guard let earliestTimestamp = view.earliestTimestamp else {
return .complete()
}
let checkSignal = postbox.transaction { transaction -> Void in
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
for (peerId, notificationSettings) in transaction.getPeerIdsAndNotificationSettingsWithBehaviorTimestampLessThanOrEqualTo(timestamp) {
if let notificationSettings = notificationSettings as? TelegramPeerNotificationSettings {
if case let .muted(untilTimestamp) = notificationSettings.muteState, untilTimestamp <= timestamp {
transaction.updateCurrentPeerNotificationSettings([peerId: notificationSettings.withUpdatedMuteState(.unmuted)])
}
}
}
}
|> ignoreValues
let timeout = earliestTimestamp - Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
if timeout <= 0 {
return checkSignal
} else {
return checkSignal |> delay(Double(timeout), queue: .mainQueue())
}
}
}