mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-04 20:00:53 +00:00
added authsessioninfoattrubute
This commit is contained in:
parent
d0e9953d28
commit
96bc8d7a22
@ -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) })
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user