diff --git a/submodules/TelegramCore/Sources/Account/AccountManager.swift b/submodules/TelegramCore/Sources/Account/AccountManager.swift index d2da8ade54..89807cef1d 100644 --- a/submodules/TelegramCore/Sources/Account/AccountManager.swift +++ b/submodules/TelegramCore/Sources/Account/AccountManager.swift @@ -193,6 +193,7 @@ private var declaredEncodables: Void = { declareEncodable(TelegramExtendedMedia.self, f: { TelegramExtendedMedia(decoder: $0) }) declareEncodable(TelegramPeerUsername.self, f: { TelegramPeerUsername(decoder: $0) }) declareEncodable(MediaSpoilerMessageAttribute.self, f: { MediaSpoilerMessageAttribute(decoder: $0) }) + declareEncodable(AuthSessionInfoAttribute.self, f: { AuthSessionInfoAttribute(decoder: $0) }) declareEncodable(TranslationMessageAttribute.self, f: { TranslationMessageAttribute(decoder: $0) }) declareEncodable(SynchronizeAutosaveItemOperation.self, f: { SynchronizeAutosaveItemOperation(decoder: $0) }) declareEncodable(TelegramMediaStory.self, f: { TelegramMediaStory(decoder: $0) }) diff --git a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift index da1f555d16..a688dbc8d5 100644 --- a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift +++ b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift @@ -1164,6 +1164,10 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox: if type.hasPrefix("auth") { updatedState.authorizationListUpdated = true + let string = type.dropFirst(4).components(separatedBy: "_") + if string.count == 2, let hash = Int64(string[0]), let timestamp = Int32(string[1]) { + attributes.append(AuthSessionInfoAttribute(hash: hash, timestamp: timestamp)) + } } let message = StoreMessage(peerId: peerId, namespace: Namespaces.Message.Local, globallyUniqueId: nil, groupingKey: nil, threadId: nil, timestamp: date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, authorId: peerId, text: messageText, attributes: attributes, media: medias) diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_AuthSessionInfoAttribute.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_AuthSessionInfoAttribute.swift new file mode 100644 index 0000000000..5f78b4f4d9 --- /dev/null +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_AuthSessionInfoAttribute.swift @@ -0,0 +1,26 @@ +import Foundation +import Postbox + +public class AuthSessionInfoAttribute: MessageAttribute { + public var associatedMessageIds: [MessageId] = [] + + public let hash: Int64 + public let timestamp: Int32 + + public init(hash: Int64, timestamp: Int32) { + self.hash = hash + self.timestamp = timestamp + } + + required public init(decoder: PostboxDecoder) { + self.timestamp = decoder.decodeInt32ForKey("t", orElse: 0) + self.hash = decoder.decodeInt64ForKey("s", orElse: 0) + + } + + public func encode(_ encoder: PostboxEncoder) { + encoder.encodeInt32(self.timestamp, forKey: "t") + encoder.encodeInt64(self.hash, forKey: "s") + + } +}