Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
@@ -0,0 +1,66 @@
import Foundation
import Postbox
import SwiftSignalKit
public struct PeerCommand: Hashable {
public let peer: Peer
public let command: BotCommand
public static func ==(lhs: PeerCommand, rhs: PeerCommand) -> Bool {
return lhs.peer.isEqual(rhs.peer) && lhs.command == rhs.command
}
public func hash(into hasher: inout Hasher) {
hasher.combine(self.peer.id)
hasher.combine(self.command)
}
}
public struct PeerCommands: Equatable {
public let commands: [PeerCommand]
public static func ==(lhs: PeerCommands, rhs: PeerCommands) -> Bool {
return lhs.commands == rhs.commands
}
}
func _internal_peerCommands(account: Account, id: PeerId) -> Signal<PeerCommands, NoError> {
return account.postbox.peerView(id: id) |> map { view -> PeerCommands in
if let cachedUserData = view.cachedData as? CachedUserData {
if let botInfo = cachedUserData.botInfo {
if let botPeer = view.peers[id] {
var commands: [PeerCommand] = []
for command in botInfo.commands {
commands.append(PeerCommand(peer: botPeer, command: command))
}
return PeerCommands(commands: commands)
}
}
return PeerCommands(commands: [])
} else if let cachedGroupData = view.cachedData as? CachedGroupData {
var commands: [PeerCommand] = []
for cachedBotInfo in cachedGroupData.botInfos {
if let botPeer = view.peers[cachedBotInfo.peerId] {
for command in cachedBotInfo.botInfo.commands {
commands.append(PeerCommand(peer: botPeer, command: command))
}
}
}
return PeerCommands(commands: commands)
} else if let cachedChannelData = view.cachedData as? CachedChannelData {
var commands: [PeerCommand] = []
for cachedBotInfo in cachedChannelData.botInfos {
if let botPeer = view.peers[cachedBotInfo.peerId] {
for command in cachedBotInfo.botInfo.commands {
commands.append(PeerCommand(peer: botPeer, command: command))
}
}
}
return PeerCommands(commands: commands)
} else {
return PeerCommands(commands: [])
}
}
|> distinctUntilChanged
}