mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Initial history import support
This commit is contained in:
@@ -1061,6 +1061,9 @@ final class MessageHistoryTable: Table {
|
||||
if forwardInfo.psaType != nil {
|
||||
forwardInfoFlags |= 1 << 4
|
||||
}
|
||||
if !forwardInfo.flags.isEmpty {
|
||||
forwardInfoFlags |= 1 << 5
|
||||
}
|
||||
sharedBuffer.write(&forwardInfoFlags, offset: 0, length: 1)
|
||||
var forwardAuthorId: Int64 = forwardInfo.authorId?.toInt64() ?? 0
|
||||
var forwardDate: Int32 = forwardInfo.date
|
||||
@@ -1102,6 +1105,11 @@ final class MessageHistoryTable: Table {
|
||||
sharedBuffer.write(&length, offset: 0, length: 4)
|
||||
}
|
||||
}
|
||||
|
||||
if !forwardInfo.flags.isEmpty {
|
||||
var value: Int32 = forwardInfo.flags.rawValue
|
||||
sharedBuffer.write(&value, offset: 0, length: 4)
|
||||
}
|
||||
} else {
|
||||
var forwardInfoFlags: Int8 = 0
|
||||
sharedBuffer.write(&forwardInfoFlags, offset: 0, length: 1)
|
||||
@@ -1630,6 +1638,9 @@ final class MessageHistoryTable: Table {
|
||||
if forwardInfo.psaType != nil {
|
||||
forwardInfoFlags |= 1 << 4
|
||||
}
|
||||
if !forwardInfo.flags.isEmpty {
|
||||
forwardInfoFlags |= 1 << 5
|
||||
}
|
||||
sharedBuffer.write(&forwardInfoFlags, offset: 0, length: 1)
|
||||
var forwardAuthorId: Int64 = forwardInfo.authorId?.toInt64() ?? 0
|
||||
var forwardDate: Int32 = forwardInfo.date
|
||||
@@ -1671,6 +1682,11 @@ final class MessageHistoryTable: Table {
|
||||
sharedBuffer.write(&length, offset: 0, length: 4)
|
||||
}
|
||||
}
|
||||
|
||||
if !forwardInfo.flags.isEmpty {
|
||||
var value: Int32 = forwardInfo.flags.rawValue
|
||||
sharedBuffer.write(&value, offset: 0, length: 4)
|
||||
}
|
||||
} else {
|
||||
var forwardInfoFlags: Int8 = 0
|
||||
sharedBuffer.write(&forwardInfoFlags, offset: 0, length: 1)
|
||||
@@ -1784,7 +1800,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, psaType: forwardInfo.psaType)
|
||||
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.authorId, sourceId: forwardInfo.sourceId, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature, psaType: forwardInfo.psaType, flags: forwardInfo.flags)
|
||||
}
|
||||
|
||||
var parsedAttributes: [MessageAttribute] = []
|
||||
@@ -2187,6 +2203,7 @@ final class MessageHistoryTable: Table {
|
||||
var forwardSourceMessageId: MessageId?
|
||||
var authorSignature: String? = nil
|
||||
var psaType: String? = nil
|
||||
var flags: MessageForwardInfo.Flags = []
|
||||
|
||||
value.read(&forwardAuthorId, offset: 0, length: 8)
|
||||
value.read(&forwardDate, offset: 0, length: 4)
|
||||
@@ -2221,7 +2238,13 @@ final class MessageHistoryTable: Table {
|
||||
value.skip(Int(psaTypeLength))
|
||||
}
|
||||
|
||||
forwardInfo = IntermediateMessageForwardInfo(authorId: forwardAuthorId == 0 ? nil : PeerId(forwardAuthorId), sourceId: forwardSourceId, sourceMessageId: forwardSourceMessageId, date: forwardDate, authorSignature: authorSignature, psaType: psaType)
|
||||
if (forwardInfoFlags & (1 << 5)) != 0 {
|
||||
var rawValue: Int32 = 0
|
||||
value.read(&rawValue, offset: 0, length: 4)
|
||||
flags = MessageForwardInfo.Flags(rawValue: rawValue)
|
||||
}
|
||||
|
||||
forwardInfo = IntermediateMessageForwardInfo(authorId: forwardAuthorId == 0 ? nil : PeerId(forwardAuthorId), sourceId: forwardSourceId, sourceMessageId: forwardSourceMessageId, date: forwardDate, authorSignature: authorSignature, psaType: psaType, flags: flags)
|
||||
}
|
||||
|
||||
var hasAuthor: Int8 = 0
|
||||
@@ -2377,7 +2400,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, psaType: internalForwardInfo.psaType)
|
||||
forwardInfo = MessageForwardInfo(author: forwardAuthor, source: source, sourceMessageId: internalForwardInfo.sourceMessageId, date: internalForwardInfo.date, authorSignature: internalForwardInfo.authorSignature, psaType: internalForwardInfo.psaType, flags: internalForwardInfo.flags)
|
||||
}
|
||||
|
||||
var author: Peer?
|
||||
|
||||
Reference in New Issue
Block a user