mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Stats and recommendations improvements
This commit is contained in:
@@ -9,7 +9,7 @@ public enum SearchMessagesLocation: Equatable {
|
||||
case general(tags: MessageTags?, minDate: Int32?, maxDate: Int32?)
|
||||
case group(groupId: PeerGroupId, tags: MessageTags?, minDate: Int32?, maxDate: Int32?)
|
||||
case peer(peerId: PeerId, fromId: PeerId?, tags: MessageTags?, topMsgId: MessageId?, minDate: Int32?, maxDate: Int32?)
|
||||
case publicForwards(messageId: MessageId, datacenterId: Int?)
|
||||
case publicForwards(messageId: MessageId)
|
||||
case sentMedia(tags: MessageTags?)
|
||||
}
|
||||
|
||||
@@ -354,30 +354,31 @@ func _internal_searchMessages(account: Account, location: SearchMessagesLocation
|
||||
return .single((nil, nil))
|
||||
}
|
||||
}
|
||||
case let .publicForwards(messageId, datacenterId):
|
||||
remoteSearchResult = account.postbox.transaction { transaction -> (Api.InputChannel?, Int32, MessageIndex?, Api.InputPeer) in
|
||||
case let .publicForwards(messageId):
|
||||
remoteSearchResult = account.postbox.transaction { transaction -> (Api.InputChannel?, Int32, MessageIndex?, Api.InputPeer, Int32?) in
|
||||
let sourcePeer = transaction.getPeer(messageId.peerId)
|
||||
let inputChannel = sourcePeer.flatMap { apiInputChannel($0) }
|
||||
let statsDatacenterId = (transaction.getPeerCachedData(peerId: messageId.peerId) as? CachedChannelData)?.statsDatacenterId
|
||||
|
||||
var lowerBound: MessageIndex?
|
||||
if let state = state, let message = state.main.messages.last {
|
||||
lowerBound = message.index
|
||||
}
|
||||
if let lowerBound = lowerBound, let peer = transaction.getPeer(lowerBound.id.peerId), let inputPeer = apiInputPeer(peer) {
|
||||
return (inputChannel, state?.main.nextRate ?? 0, lowerBound, inputPeer)
|
||||
return (inputChannel, state?.main.nextRate ?? 0, lowerBound, inputPeer, statsDatacenterId)
|
||||
} else {
|
||||
return (inputChannel, 0, lowerBound, .inputPeerEmpty)
|
||||
return (inputChannel, 0, lowerBound, .inputPeerEmpty, statsDatacenterId)
|
||||
}
|
||||
}
|
||||
|> mapToSignal { (inputChannel, nextRate, lowerBound, inputPeer) in
|
||||
|> mapToSignal { (inputChannel, nextRate, lowerBound, inputPeer, statsDatacenterId) in
|
||||
guard let inputChannel = inputChannel else {
|
||||
return .complete()
|
||||
}
|
||||
|
||||
let request = Api.functions.stats.getMessagePublicForwards(channel: inputChannel, msgId: messageId.id, offsetRate: nextRate, offsetPeer: inputPeer, offsetId: lowerBound?.id.id ?? 0, limit: limit)
|
||||
let signal: Signal<Api.messages.Messages, MTRpcError>
|
||||
if let datacenterId = datacenterId, account.network.datacenterId != datacenterId {
|
||||
signal = account.network.download(datacenterId: datacenterId, isMedia: false, tag: nil)
|
||||
if let statsDatacenterId = statsDatacenterId, account.network.datacenterId != statsDatacenterId {
|
||||
signal = account.network.download(datacenterId: Int(statsDatacenterId), isMedia: false, tag: nil)
|
||||
|> castError(MTRpcError.self)
|
||||
|> mapToSignal { worker in
|
||||
return worker.request(request)
|
||||
|
||||
Reference in New Issue
Block a user