mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-25 20:36:41 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
42 lines
1.3 KiB
Swift
42 lines
1.3 KiB
Swift
import Foundation
|
|
import Postbox
|
|
|
|
public class DerivedDataMessageAttribute: MessageAttribute {
|
|
private struct EntryData: PostboxCoding {
|
|
var data: CodableEntry
|
|
|
|
init(data: CodableEntry) {
|
|
self.data = data
|
|
}
|
|
|
|
init(decoder: PostboxDecoder) {
|
|
self.data = CodableEntry(data: decoder.decodeDataForKey("d") ?? Data())
|
|
}
|
|
|
|
func encode(_ encoder: PostboxEncoder) {
|
|
encoder.encodeData(self.data.data, forKey: "d")
|
|
}
|
|
}
|
|
|
|
public let data: [String: CodableEntry]
|
|
|
|
public init(data: [String: CodableEntry]) {
|
|
self.data = data
|
|
}
|
|
|
|
required public init(decoder: PostboxDecoder) {
|
|
let data = decoder.decodeObjectDictionaryForKey("d", keyDecoder: { key in
|
|
return key.decodeStringForKey("k", orElse: "")
|
|
}, valueDecoder: { value in
|
|
return EntryData(data: CodableEntry(data: value.decodeDataForKey("d") ?? Data()))
|
|
})
|
|
self.data = data.mapValues(\.data)
|
|
}
|
|
|
|
public func encode(_ encoder: PostboxEncoder) {
|
|
encoder.encodeObjectDictionary(self.data.mapValues(EntryData.init(data:)), forKey: "d", keyEncoder: { k, e in
|
|
e.encodeString(k, forKey: "k")
|
|
})
|
|
}
|
|
}
|