mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Stories
This commit is contained in:
@@ -223,6 +223,62 @@ func locallyRenderedMessage(message: StoreMessage, peers: [PeerId: Peer], associ
|
||||
return Message(stableId: stableId, stableVersion: 0, id: id, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: message.threadId, timestamp: message.timestamp, flags: MessageFlags(message.flags), tags: message.tags, globalTags: message.globalTags, localTags: message.localTags, forwardInfo: forwardInfo, author: author, text: message.text, attributes: message.attributes, media: message.media, peers: messagePeers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: associatedThreadInfo, associatedStories: [:])
|
||||
}
|
||||
|
||||
func locallyRenderedMessage(message: StoreMessage, peers: AccumulatedPeers, associatedThreadInfo: Message.AssociatedThreadInfo? = nil) -> Message? {
|
||||
guard case let .Id(id) = message.id else {
|
||||
return nil
|
||||
}
|
||||
|
||||
var messagePeers = SimpleDictionary<PeerId, Peer>()
|
||||
|
||||
var author: Peer?
|
||||
if let authorId = message.authorId {
|
||||
author = peers.get(authorId)
|
||||
if let author = author {
|
||||
messagePeers[author.id] = author
|
||||
}
|
||||
}
|
||||
|
||||
if let peer = peers.get(id.peerId) {
|
||||
messagePeers[peer.id] = peer
|
||||
|
||||
if let group = peer as? TelegramGroup, let migrationReference = group.migrationReference {
|
||||
if let channelPeer = peers.get(migrationReference.peerId) {
|
||||
messagePeers[channelPeer.id] = channelPeer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for media in message.media {
|
||||
for peerId in media.peerIds {
|
||||
if let peer = peers.get(peerId) {
|
||||
messagePeers[peer.id] = peer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var forwardInfo: MessageForwardInfo?
|
||||
if let info = message.forwardInfo {
|
||||
forwardInfo = MessageForwardInfo(author: info.authorId.flatMap({ peers.get($0) }), source: info.sourceId.flatMap({ peers.get($0) }), sourceMessageId: info.sourceMessageId, date: info.date, authorSignature: info.authorSignature, psaType: info.psaType, flags: info.flags)
|
||||
if let author = forwardInfo?.author {
|
||||
messagePeers[author.id] = author
|
||||
}
|
||||
if let source = forwardInfo?.source {
|
||||
messagePeers[source.id] = source
|
||||
}
|
||||
}
|
||||
|
||||
var hasher = Hasher()
|
||||
hasher.combine(id.id)
|
||||
hasher.combine(id.peerId)
|
||||
|
||||
let hashValue = Int64(hasher.finalize())
|
||||
let first = UInt32((hashValue >> 32) & 0xffffffff)
|
||||
let second = UInt32(hashValue & 0xffffffff)
|
||||
let stableId = first &+ second
|
||||
|
||||
return Message(stableId: stableId, stableVersion: 0, id: id, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: message.threadId, timestamp: message.timestamp, flags: MessageFlags(message.flags), tags: message.tags, globalTags: message.globalTags, localTags: message.localTags, forwardInfo: forwardInfo, author: author, text: message.text, attributes: message.attributes, media: message.media, peers: messagePeers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: associatedThreadInfo, associatedStories: [:])
|
||||
}
|
||||
|
||||
public extension Message {
|
||||
func effectivelyIncoming(_ accountPeerId: PeerId) -> Bool {
|
||||
if self.id.peerId == accountPeerId {
|
||||
|
||||
Reference in New Issue
Block a user