mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 13:13:55 +00:00
Support latest API
This commit is contained in:
parent
40f7e805b8
commit
01a434f3d9
@ -422,6 +422,8 @@
|
||||
D067066D1D512ADB00DED3E3 /* SwiftSignalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D06706681D512ADB00DED3E3 /* SwiftSignalKit.framework */; };
|
||||
D06AFE8920BF66BF00EA5124 /* DeserializeFunctionResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06AFE8820BF66BF00EA5124 /* DeserializeFunctionResponse.swift */; };
|
||||
D06AFE8A20BF66BF00EA5124 /* DeserializeFunctionResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06AFE8820BF66BF00EA5124 /* DeserializeFunctionResponse.swift */; };
|
||||
D06CA13522772EB20094E707 /* ManagedNotificationSettingsBehaviors.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06CA13422772EB20094E707 /* ManagedNotificationSettingsBehaviors.swift */; };
|
||||
D06CA13622772EB20094E707 /* ManagedNotificationSettingsBehaviors.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06CA13422772EB20094E707 /* ManagedNotificationSettingsBehaviors.swift */; };
|
||||
D06ECFC820B810D300C576C2 /* TermsOfService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06ECFC720B810D300C576C2 /* TermsOfService.swift */; };
|
||||
D06ECFC920B810D300C576C2 /* TermsOfService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06ECFC720B810D300C576C2 /* TermsOfService.swift */; };
|
||||
D07047B41F3DF1FE00F6A8D4 /* ConsumablePersonalMentionMessageAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = D07047B31F3DF1FE00F6A8D4 /* ConsumablePersonalMentionMessageAttribute.swift */; };
|
||||
@ -1043,6 +1045,7 @@
|
||||
D06706681D512ADB00DED3E3 /* SwiftSignalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SwiftSignalKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D067066E1D512AEB00DED3E3 /* MtProtoKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = MtProtoKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D06AFE8820BF66BF00EA5124 /* DeserializeFunctionResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeserializeFunctionResponse.swift; sourceTree = "<group>"; };
|
||||
D06CA13422772EB20094E707 /* ManagedNotificationSettingsBehaviors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManagedNotificationSettingsBehaviors.swift; sourceTree = "<group>"; };
|
||||
D06ECFC720B810D300C576C2 /* TermsOfService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfService.swift; sourceTree = "<group>"; };
|
||||
D07047B31F3DF1FE00F6A8D4 /* ConsumablePersonalMentionMessageAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsumablePersonalMentionMessageAttribute.swift; sourceTree = "<group>"; };
|
||||
D07047B61F3DF2CD00F6A8D4 /* ManagedConsumePersonalMessagesActions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManagedConsumePersonalMessagesActions.swift; sourceTree = "<group>"; };
|
||||
@ -1578,6 +1581,7 @@
|
||||
093857A72243D87900EB6A54 /* SynchronizeEmojiKeywordsOperation.swift */,
|
||||
093857A62243D87800EB6A54 /* ManagedSynchronizeEmojiKeywordsOperations.swift */,
|
||||
D0CA8E4A227209C4008A74C3 /* ManagedSynchronizeGroupMessageStats.swift */,
|
||||
D06CA13422772EB20094E707 /* ManagedNotificationSettingsBehaviors.swift */,
|
||||
);
|
||||
name = State;
|
||||
sourceTree = "<group>";
|
||||
@ -2502,6 +2506,7 @@
|
||||
D0C27B421F4B58C000A4E170 /* PeerSpecificStickerPack.swift in Sources */,
|
||||
D054648B2073854A002ECC1E /* SecureIdPersonalDetailsValue.swift in Sources */,
|
||||
D01749591E1092BC0057C89A /* RequestStartBot.swift in Sources */,
|
||||
D06CA13522772EB20094E707 /* ManagedNotificationSettingsBehaviors.swift in Sources */,
|
||||
D03DC9101F82E344001D584C /* AccountStateReset.swift in Sources */,
|
||||
D01B27A21E394D8B0022A4C0 /* PrivacySettings.swift in Sources */,
|
||||
D0223A9B1EA5654D00211D94 /* TelegramMediaResource.swift in Sources */,
|
||||
@ -2738,6 +2743,7 @@
|
||||
D0B8442B1DAB91E0005F29E1 /* NBMetadataCore.m in Sources */,
|
||||
D093D7EF206413F600BC3599 /* SecureIdDataTypes.swift in Sources */,
|
||||
D03DC9141F82F89D001D584C /* RegularChatState.swift in Sources */,
|
||||
D06CA13622772EB20094E707 /* ManagedNotificationSettingsBehaviors.swift in Sources */,
|
||||
D0C44B621FC616E200227BE0 /* SearchGroupMembers.swift in Sources */,
|
||||
D0F3A8A61E82C94C00B4C64C /* SynchronizeableChatInputState.swift in Sources */,
|
||||
D00BDA1A1EE593D600C64C5E /* TelegramChannelAdminRights.swift in Sources */,
|
||||
|
||||
@ -1209,6 +1209,8 @@ public class Account {
|
||||
self.managedOperationsDisposable.add(managedPendingPeerNotificationSettings(postbox: self.postbox, network: self.network).start())
|
||||
self.managedOperationsDisposable.add(managedSynchronizeAppLogEventsOperations(postbox: self.postbox, network: self.network).start())
|
||||
|
||||
self.managedOperationsDisposable.add(managedNotificationSettingsBehaviors(postbox: self.postbox).start())
|
||||
|
||||
let mediaBox = postbox.mediaBox
|
||||
self.storageSettingsDisposable = accountManager.sharedData(keys: [SharedDataKeys.cacheStorageSettings]).start(next: { [weak mediaBox] sharedData in
|
||||
guard let mediaBox = mediaBox else {
|
||||
|
||||
@ -2680,6 +2680,14 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
|
||||
if processSecretChatIncomingEncryptedOperations(transaction: transaction, peerId: peerId) {
|
||||
let processResult = processSecretChatIncomingDecryptedOperations(mediaBox: mediaBox, transaction: transaction, peerId: peerId)
|
||||
if !processResult.addedMessages.isEmpty {
|
||||
let currentInclusion = transaction.getPeerChatListInclusion(peerId)
|
||||
if let groupId = currentInclusion.groupId, groupId == Namespaces.PeerGroup.archive {
|
||||
if let peer = transaction.getPeer(peerId) as? TelegramSecretChat {
|
||||
if let notificationSettings = transaction.getPeerNotificationSettings(peer.regularPeerId) as? TelegramPeerNotificationSettings, !notificationSettings.isRemovedFromTotalUnreadCount {
|
||||
transaction.updatePeerChatListInclusion(peerId, inclusion: currentInclusion.withGroupId(groupId: .root))
|
||||
}
|
||||
}
|
||||
}
|
||||
for message in processResult.addedMessages {
|
||||
if case let .Id(id) = message.id {
|
||||
addedSecretMessageIds.append(id)
|
||||
|
||||
39
TelegramCore/ManagedNotificationSettingsBehaviors.swift
Normal file
39
TelegramCore/ManagedNotificationSettingsBehaviors.swift
Normal file
@ -0,0 +1,39 @@
|
||||
import Foundation
|
||||
#if os(macOS)
|
||||
import PostboxMac
|
||||
import SwiftSignalKitMac
|
||||
#else
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
#endif
|
||||
|
||||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,6 +129,14 @@ public final class TelegramPeerNotificationSettings: PeerNotificationSettings, E
|
||||
}
|
||||
}
|
||||
|
||||
public var behavior: PeerNotificationSettingsBehavior {
|
||||
if case let .muted(untilTimestamp) = self.muteState, untilTimestamp < Int32.max {
|
||||
return .reset(atTimestamp: untilTimestamp, toValue: self.withUpdatedMuteState(.unmuted))
|
||||
} else {
|
||||
return .none
|
||||
}
|
||||
}
|
||||
|
||||
public init(muteState: PeerMuteState, messageSound: PeerMessageSound) {
|
||||
self.muteState = muteState
|
||||
self.messageSound = messageSound
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user