mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'experimental-2' of gitlab.com:peter-iakovlev/telegram-ios into experimental-2
# Conflicts: # submodules/TelegramCore/Sources/InvitationLinks.swift
This commit is contained in:
commit
b0c24338e3
@ -6,64 +6,64 @@ import MtProtoKit
|
|||||||
|
|
||||||
import SyncCore
|
import SyncCore
|
||||||
|
|
||||||
//
|
|
||||||
//public func ensuredExistingPeerExportedInvitation(account: Account, peerId: PeerId, revokeExisted: Bool = false) -> Signal<ExportedInvitation?, NoError> {
|
public func ensuredExistingPeerExportedInvitation(account: Account, peerId: PeerId, revokeExisted: Bool = false) -> Signal<ExportedInvitation?, NoError> {
|
||||||
// return account.postbox.transaction { transaction -> Signal<ExportedInvitation?, NoError> in
|
return account.postbox.transaction { transaction -> Signal<ExportedInvitation?, NoError> in
|
||||||
// if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
|
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
|
||||||
// if let _ = peer as? TelegramChannel {
|
if let _ = peer as? TelegramChannel {
|
||||||
// if let cachedData = transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData, cachedData.exportedInvitation != nil && !revokeExisted {
|
if let cachedData = transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData, cachedData.exportedInvitation != nil && !revokeExisted {
|
||||||
// return .single(cachedData.exportedInvitation)
|
return .single(cachedData.exportedInvitation)
|
||||||
// } else {
|
} else {
|
||||||
// return account.network.request(Api.functions.messages.exportChatInvite(peer: inputPeer))
|
return account.network.request(Api.functions.messages.exportChatInvite(flags: 0, peer: inputPeer, expireDate: nil, usageLimit: nil))
|
||||||
// |> retryRequest
|
|> retryRequest
|
||||||
// |> mapToSignal { result -> Signal<ExportedInvitation?, NoError> in
|
|> mapToSignal { result -> Signal<ExportedInvitation?, NoError> in
|
||||||
// return account.postbox.transaction { transaction -> ExportedInvitation? in
|
return account.postbox.transaction { transaction -> ExportedInvitation? in
|
||||||
// if let invitation = ExportedInvitation(apiExportedInvite: result) {
|
if let invitation = ExportedInvitation(apiExportedInvite: result) {
|
||||||
// transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||||
// if let current = current as? CachedChannelData {
|
if let current = current as? CachedChannelData {
|
||||||
// return current.withUpdatedExportedInvitation(invitation)
|
return current.withUpdatedExportedInvitation(invitation)
|
||||||
// } else {
|
} else {
|
||||||
// return CachedChannelData().withUpdatedExportedInvitation(invitation)
|
return CachedChannelData().withUpdatedExportedInvitation(invitation)
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// return invitation
|
return invitation
|
||||||
// } else {
|
} else {
|
||||||
// return nil
|
return nil
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// } else if let _ = peer as? TelegramGroup {
|
} else if let _ = peer as? TelegramGroup {
|
||||||
// if let cachedData = transaction.getPeerCachedData(peerId: peerId) as? CachedGroupData, cachedData.exportedInvitation != nil && !revokeExisted {
|
if let cachedData = transaction.getPeerCachedData(peerId: peerId) as? CachedGroupData, cachedData.exportedInvitation != nil && !revokeExisted {
|
||||||
// return .single(cachedData.exportedInvitation)
|
return .single(cachedData.exportedInvitation)
|
||||||
// } else {
|
} else {
|
||||||
// return account.network.request(Api.functions.messages.exportChatInvite(peer: inputPeer))
|
return account.network.request(Api.functions.messages.exportChatInvite(flags: 0, peer: inputPeer, expireDate: nil, usageLimit: nil))
|
||||||
// |> retryRequest
|
|> retryRequest
|
||||||
// |> mapToSignal { result -> Signal<ExportedInvitation?, NoError> in
|
|> mapToSignal { result -> Signal<ExportedInvitation?, NoError> in
|
||||||
// return account.postbox.transaction { transaction -> ExportedInvitation? in
|
return account.postbox.transaction { transaction -> ExportedInvitation? in
|
||||||
// if let invitation = ExportedInvitation(apiExportedInvite: result) {
|
if let invitation = ExportedInvitation(apiExportedInvite: result) {
|
||||||
// transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||||
// if let current = current as? CachedGroupData {
|
if let current = current as? CachedGroupData {
|
||||||
// return current.withUpdatedExportedInvitation(invitation)
|
return current.withUpdatedExportedInvitation(invitation)
|
||||||
// } else {
|
} else {
|
||||||
// return current
|
return current
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// return invitation
|
return invitation
|
||||||
// } else {
|
} else {
|
||||||
// return nil
|
return nil
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// return .complete()
|
return .complete()
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// return .complete()
|
return .complete()
|
||||||
// }
|
}
|
||||||
// } |> switchToLatest
|
} |> switchToLatest
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
|
||||||
public func revokePersistentPeerExportedInvitation(account: Account, peerId: PeerId) -> Signal<ExportedInvitation?, NoError> {
|
public func revokePersistentPeerExportedInvitation(account: Account, peerId: PeerId) -> Signal<ExportedInvitation?, NoError> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user