Merge commit '6af4b0c184d3656e89a32858cc25fcff9b3b5253'

# Conflicts:
#	submodules/TelegramApi/Sources/Api0.swift
#	submodules/TelegramApi/Sources/Api27.swift
#	submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift
#	submodules/TelegramCore/Sources/ApiUtils/BotInfo.swift
#	submodules/TelegramCore/Sources/ApiUtils/TelegramUser.swift
This commit is contained in:
Isaac
2024-12-19 16:27:06 +08:00
53 changed files with 522 additions and 423 deletions

View File

@@ -67,7 +67,25 @@ public extension TelegramEngine {
} else {
return false
}
} .map(EngineRenderedPeer.init)
}.map(EngineRenderedPeer.init)
case .groups:
return peers.filter { item in
if let channel = item.peer as? TelegramChannel, case .group = channel.info {
return true
} else if item.peer is TelegramGroup {
return true
} else {
return false
}
}.map(EngineRenderedPeer.init)
case .privateChats:
return peers.filter { item in
if item.peer is TelegramUser {
return true
} else {
return false
}
}.map(EngineRenderedPeer.init)
}
}
}

View File

@@ -241,7 +241,8 @@ private class AdMessagesHistoryContextImpl {
profileBackgroundEmojiId: nil,
emojiStatus: nil,
approximateBoostLevel: nil,
subscriptionUntilDate: nil
subscriptionUntilDate: nil,
verification: nil
)
messagePeers[author.id] = author

View File

@@ -470,6 +470,10 @@ func _internal_searchMessages(account: Account, location: SearchMessagesLocation
break
case .channels:
flags |= (1 << 1)
case .groups:
flags |= (1 << 2)
case .privateChats:
flags |= (1 << 3)
}
}

View File

@@ -21,6 +21,8 @@ public struct FoundPeer: Equatable {
public enum TelegramSearchPeersScope {
case everywhere
case channels
case groups
case privateChats
}
public func _internal_searchPeers(accountPeerId: PeerId, postbox: Postbox, network: Network, query: String, scope: TelegramSearchPeersScope) -> Signal<([FoundPeer], [FoundPeer]), NoError> {
@@ -102,6 +104,40 @@ public func _internal_searchPeers(accountPeerId: PeerId, postbox: Postbox, netwo
return false
}
}
case .groups:
renderedMyPeers = renderedMyPeers.filter { item in
if let channel = item.peer as? TelegramChannel, case .group = channel.info {
return true
} else if item.peer is TelegramGroup {
return true
} else {
return false
}
}
renderedPeers = renderedPeers.filter { item in
if let channel = item.peer as? TelegramChannel, case .group = channel.info {
return true
} else if item.peer is TelegramGroup {
return true
} else {
return false
}
}
case .privateChats:
renderedMyPeers = renderedMyPeers.filter { item in
if item.peer is TelegramUser {
return true
} else {
return false
}
}
renderedPeers = renderedPeers.filter { item in
if item.peer is TelegramUser {
return true
} else {
return false
}
}
}
return (renderedMyPeers, renderedPeers)

View File

@@ -815,6 +815,10 @@ public extension TelegramEngine {
return _internal_toggleBotEmojiStatusAccess(account: self.account, peerId: peerId, enabled: enabled)
}
public func updateCustomVerification(botId: PeerId, peerId: PeerId, value: UpdateCustomVerificationValue) -> Signal<Never, UpdateCustomVerificationError> {
return _internal_updateCustomVerification(account: self.account, botId: botId, peerId: peerId, value: value)
}
public func updatePeerNameColorAndEmoji(peerId: EnginePeer.Id, nameColor: PeerNameColor, backgroundEmojiId: Int64?, profileColor: PeerNameColor?, profileBackgroundEmojiId: Int64?) -> Signal<Void, UpdatePeerNameColorAndEmojiError> {
return _internal_updatePeerNameColorAndEmoji(account: self.account, peerId: peerId, nameColor: nameColor, backgroundEmojiId: backgroundEmojiId, profileColor: profileColor, profileBackgroundEmojiId: profileBackgroundEmojiId)
}

View File

@@ -100,7 +100,7 @@ func _internal_updateBotDescription(account: Account, peerId: PeerId, descriptio
if let botInfo = current.botInfo {
var updatedBotInfo = botInfo
if botInfo.description == editableBotInfo.description {
updatedBotInfo = BotInfo(description: description, photo: botInfo.photo, video: botInfo.video, commands: botInfo.commands, menuButton: botInfo.menuButton, privacyPolicyUrl: botInfo.privacyPolicyUrl, appSettings: botInfo.appSettings)
updatedBotInfo = BotInfo(description: description, photo: botInfo.photo, video: botInfo.video, commands: botInfo.commands, menuButton: botInfo.menuButton, privacyPolicyUrl: botInfo.privacyPolicyUrl, appSettings: botInfo.appSettings, verifierSettings: botInfo.verifierSettings)
}
return current.withUpdatedEditableBotInfo(editableBotInfo.withUpdatedDescription(description)).withUpdatedBotInfo(updatedBotInfo)
} else {
@@ -161,3 +161,41 @@ func _internal_toggleBotEmojiStatusAccess(account: Account, peerId: PeerId, enab
|> switchToLatest
|> ignoreValues
}
public enum UpdateCustomVerificationError {
case generic
}
public enum UpdateCustomVerificationValue {
case enabled(description: String?)
case disabled
}
func _internal_updateCustomVerification(account: Account, botId: PeerId, peerId: PeerId, value: UpdateCustomVerificationValue) -> Signal<Never, UpdateCustomVerificationError> {
return account.postbox.transaction { transaction -> Signal<Api.Bool, UpdateCustomVerificationError> in
if let bot = transaction.getPeer(botId), let inputBot = apiInputUser(bot), let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
var flags: Int32 = (1 << 0)
var customDescription: String?
switch value {
case let .enabled(description):
flags |= (1 << 1)
if let description, !description.isEmpty {
flags |= (1 << 2)
customDescription = description
}
case .disabled:
break
}
return account.network.request(Api.functions.bots.setCustomVerification(flags: flags, bot: inputBot, peer: inputPeer, customDescription: customDescription))
|> mapError { _ -> UpdateCustomVerificationError in
return .generic
}
} else {
return .fail(.generic)
}
}
|> mapError { _ -> UpdateCustomVerificationError in }
|> switchToLatest
|> ignoreValues
}