mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Business features
This commit is contained in:
@@ -1613,34 +1613,6 @@ public extension TelegramEngine.EngineData.Item {
|
||||
}
|
||||
}
|
||||
|
||||
public struct BusinessIntro: TelegramEngineDataItem, TelegramEngineMapKeyDataItem, PostboxViewDataItem {
|
||||
public typealias Result = CachedTelegramBusinessIntro?
|
||||
|
||||
fileprivate var id: EnginePeer.Id
|
||||
public var mapKey: EnginePeer.Id {
|
||||
return self.id
|
||||
}
|
||||
|
||||
public init(id: EnginePeer.Id) {
|
||||
self.id = id
|
||||
}
|
||||
|
||||
var key: PostboxViewKey {
|
||||
return .cachedPeerData(peerId: self.id)
|
||||
}
|
||||
|
||||
func extract(view: PostboxView) -> Result {
|
||||
guard let view = view as? CachedPeerDataView else {
|
||||
preconditionFailure()
|
||||
}
|
||||
if let cachedData = view.cachedPeerData as? CachedUserData {
|
||||
return cachedData.businessIntro
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct ChatManagingBot: TelegramEngineDataItem, TelegramEngineMapKeyDataItem, PostboxViewDataItem {
|
||||
public typealias Result = PeerStatusSettings.ManagingBot?
|
||||
|
||||
|
||||
@@ -371,6 +371,9 @@ func _internal_toggleChatManagingBotIsPaused(account: Account, chatId: EnginePee
|
||||
if let managingBot = peerStatusSettings.managingBot {
|
||||
isPaused = !managingBot.isPaused
|
||||
peerStatusSettings.managingBot?.isPaused = isPaused
|
||||
if !isPaused {
|
||||
peerStatusSettings.managingBot?.canReply = true
|
||||
}
|
||||
}
|
||||
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
@@ -412,6 +415,35 @@ func _internal_removeChatManagingBot(account: Account, chatId: EnginePeer.Id) ->
|
||||
return current
|
||||
}
|
||||
})
|
||||
transaction.updatePeerCachedData(peerIds: Set([account.peerId]), update: { _, current in
|
||||
guard let current = current as? CachedUserData else {
|
||||
return current
|
||||
}
|
||||
|
||||
if let connectedBot = current.connectedBot {
|
||||
var additionalPeers = connectedBot.recipients.additionalPeers
|
||||
var excludePeers = connectedBot.recipients.excludePeers
|
||||
if connectedBot.recipients.exclude {
|
||||
additionalPeers.insert(chatId)
|
||||
} else {
|
||||
additionalPeers.remove(chatId)
|
||||
excludePeers.insert(chatId)
|
||||
}
|
||||
|
||||
return current.withUpdatedConnectedBot(TelegramAccountConnectedBot(
|
||||
id: connectedBot.id,
|
||||
recipients: TelegramBusinessRecipients(
|
||||
categories: connectedBot.recipients.categories,
|
||||
additionalPeers: additionalPeers,
|
||||
excludePeers: excludePeers,
|
||||
exclude: connectedBot.recipients.exclude
|
||||
),
|
||||
canReply: connectedBot.canReply
|
||||
))
|
||||
} else {
|
||||
return current
|
||||
}
|
||||
})
|
||||
}
|
||||
|> mapToSignal { _ -> Signal<Never, NoError> in
|
||||
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||
|
||||
@@ -811,7 +811,7 @@ extension TelegramBusinessRecipients {
|
||||
self.init(
|
||||
categories: categories,
|
||||
additionalPeers: Set((users ?? []).map( { PeerId(namespace: Namespaces.Peer.CloudUser, id: ._internalFromInt64Value($0)) })),
|
||||
excludePeers: Set((excludeUsers ?? []).map(PeerId.init)),
|
||||
excludePeers: Set((excludeUsers ?? []).map( { PeerId(namespace: Namespaces.Peer.CloudUser, id: ._internalFromInt64Value($0)) })),
|
||||
exclude: (flags & (1 << 5)) != 0
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user