mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Initial implementation of the PSA API
This commit is contained in:
@@ -1026,6 +1026,9 @@ final class MessageHistoryTable: Table {
|
||||
if forwardInfo.authorSignature != nil {
|
||||
forwardInfoFlags |= 1 << 3
|
||||
}
|
||||
if forwardInfo.psaType != nil {
|
||||
forwardInfoFlags |= 1 << 4
|
||||
}
|
||||
sharedBuffer.write(&forwardInfoFlags, offset: 0, length: 1)
|
||||
var forwardAuthorId: Int64 = forwardInfo.authorId?.toInt64() ?? 0
|
||||
var forwardDate: Int32 = forwardInfo.date
|
||||
@@ -1056,6 +1059,17 @@ final class MessageHistoryTable: Table {
|
||||
sharedBuffer.write(&length, offset: 0, length: 4)
|
||||
}
|
||||
}
|
||||
|
||||
if let psaType = forwardInfo.psaType {
|
||||
if let data = psaType.data(using: .utf8, allowLossyConversion: true) {
|
||||
var length: Int32 = Int32(data.count)
|
||||
sharedBuffer.write(&length, offset: 0, length: 4)
|
||||
sharedBuffer.write(data)
|
||||
} else {
|
||||
var length: Int32 = 0
|
||||
sharedBuffer.write(&length, offset: 0, length: 4)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var forwardInfoFlags: Int8 = 0
|
||||
sharedBuffer.write(&forwardInfoFlags, offset: 0, length: 1)
|
||||
@@ -1698,7 +1712,7 @@ final class MessageHistoryTable: Table {
|
||||
if let previousMessage = self.getMessage(index) {
|
||||
var storeForwardInfo: StoreMessageForwardInfo?
|
||||
if let forwardInfo = previousMessage.forwardInfo {
|
||||
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.authorId, sourceId: forwardInfo.sourceId, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
|
||||
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.authorId, sourceId: forwardInfo.sourceId, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature, psaType: forwardInfo.psaType)
|
||||
}
|
||||
|
||||
var parsedAttributes: [MessageAttribute] = []
|
||||
@@ -2046,6 +2060,7 @@ final class MessageHistoryTable: Table {
|
||||
var forwardSourceId: PeerId?
|
||||
var forwardSourceMessageId: MessageId?
|
||||
var authorSignature: String? = nil
|
||||
var psaType: String? = nil
|
||||
|
||||
value.read(&forwardAuthorId, offset: 0, length: 8)
|
||||
value.read(&forwardDate, offset: 0, length: 4)
|
||||
@@ -2073,7 +2088,14 @@ final class MessageHistoryTable: Table {
|
||||
value.skip(Int(signatureLength))
|
||||
}
|
||||
|
||||
forwardInfo = IntermediateMessageForwardInfo(authorId: forwardAuthorId == 0 ? nil : PeerId(forwardAuthorId), sourceId: forwardSourceId, sourceMessageId: forwardSourceMessageId, date: forwardDate, authorSignature: authorSignature)
|
||||
if (forwardInfoFlags & (1 << 4)) != 0 {
|
||||
var psaTypeLength: Int32 = 0
|
||||
value.read(&psaTypeLength, offset: 0, length: 4)
|
||||
psaType = String(data: Data(bytes: value.memory.assumingMemoryBound(to: UInt8.self).advanced(by: value.offset), count: Int(psaTypeLength)), encoding: .utf8)
|
||||
value.skip(Int(psaTypeLength))
|
||||
}
|
||||
|
||||
forwardInfo = IntermediateMessageForwardInfo(authorId: forwardAuthorId == 0 ? nil : PeerId(forwardAuthorId), sourceId: forwardSourceId, sourceMessageId: forwardSourceMessageId, date: forwardDate, authorSignature: authorSignature, psaType: psaType)
|
||||
}
|
||||
|
||||
var hasAuthor: Int8 = 0
|
||||
@@ -2229,7 +2251,7 @@ final class MessageHistoryTable: Table {
|
||||
if let sourceId = internalForwardInfo.sourceId {
|
||||
source = peerTable.get(sourceId)
|
||||
}
|
||||
forwardInfo = MessageForwardInfo(author: forwardAuthor, source: source, sourceMessageId: internalForwardInfo.sourceMessageId, date: internalForwardInfo.date, authorSignature: internalForwardInfo.authorSignature)
|
||||
forwardInfo = MessageForwardInfo(author: forwardAuthor, source: source, sourceMessageId: internalForwardInfo.sourceMessageId, date: internalForwardInfo.date, authorSignature: internalForwardInfo.authorSignature, psaType: internalForwardInfo.psaType)
|
||||
}
|
||||
|
||||
var author: Peer?
|
||||
|
||||
Reference in New Issue
Block a user