mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 17:30:12 +00:00
[skip ci]
This commit is contained in:
parent
257def1bd3
commit
0c283bcf1e
@ -6,6 +6,54 @@ import MtProtoKit
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
|
|
||||||
|
public func revokePersistentPeerExportedInvitation(account: Account, peerId: PeerId) -> Signal<ExportedInvitation?, NoError> {
|
||||||
|
return account.postbox.transaction { transaction -> Signal<ExportedInvitation?, NoError> in
|
||||||
|
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
|
||||||
|
let flags: Int32 = (1 << 2)
|
||||||
|
if let _ = peer as? TelegramChannel {
|
||||||
|
return account.network.request(Api.functions.messages.exportChatInvite(flags: flags, peer: inputPeer, expireDate: nil, usageLimit: nil))
|
||||||
|
|> retryRequest
|
||||||
|
|> mapToSignal { result -> Signal<ExportedInvitation?, NoError> in
|
||||||
|
return account.postbox.transaction { transaction -> ExportedInvitation? in
|
||||||
|
let invitation = ExportedInvitation(apiExportedInvite: result)
|
||||||
|
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||||
|
if let current = current as? CachedChannelData {
|
||||||
|
return current.withUpdatedExportedInvitation(invitation)
|
||||||
|
} else {
|
||||||
|
return CachedChannelData().withUpdatedExportedInvitation(invitation)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return invitation
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if let _ = peer as? TelegramGroup {
|
||||||
|
return account.network.request(Api.functions.messages.exportChatInvite(flags: flags, peer: inputPeer, expireDate: nil, usageLimit: nil))
|
||||||
|
|> retryRequest
|
||||||
|
|> mapToSignal { result -> Signal<ExportedInvitation?, NoError> in
|
||||||
|
return account.postbox.transaction { transaction -> ExportedInvitation? in
|
||||||
|
let invitation = ExportedInvitation(apiExportedInvite: result)
|
||||||
|
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||||
|
if let current = current as? CachedGroupData {
|
||||||
|
return current.withUpdatedExportedInvitation(invitation)
|
||||||
|
} else {
|
||||||
|
return current
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return invitation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return .complete()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return .complete()
|
||||||
|
}
|
||||||
|
} |> switchToLatest
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum CreatePeerExportedInvitationError {
|
public enum CreatePeerExportedInvitationError {
|
||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user