134 layer fixes

This commit is contained in:
overtake
2021-10-05 14:52:24 +03:00
parent 4e497dbff5
commit 1981066669
3 changed files with 17 additions and 4 deletions

View File

@@ -81,6 +81,9 @@ func _internal_createPeerExportedInvitation(account: Account, peerId: PeerId, ex
if let _ = usageLimit {
flags |= (1 << 1)
}
if let _ = requestNeeded {
flags |= (1 << 3)
}
return account.network.request(Api.functions.messages.exportChatInvite(flags: flags, peer: inputPeer, expireDate: expireDate, usageLimit: usageLimit))
|> mapError { _ in return CreatePeerExportedInvitationError.generic }
|> map { result -> ExportedInvitation? in

View File

@@ -22,7 +22,16 @@ func apiUpdatesGroups(_ updates: Api.Updates) -> [Api.Chat] {
}
public enum ExternalJoiningChatState {
case invite(title: String, about: String?, photoRepresentation: TelegramMediaImageRepresentation?, participantsCount: Int32, participants: [Peer]?)
public struct InviteFlags {
public let isChannel: Bool
public let isBroadcast: Bool
public let isPublic: Bool
public let isMegagroup: Bool
public let requestNeeded: Bool
}
case invite(flags: InviteFlags, title: String, about: String?, photoRepresentation: TelegramMediaImageRepresentation?, participantsCount: Int32, participants: [Peer]?)
case alreadyJoined(PeerId)
case invalidHash
case peek(PeerId, Int32)
@@ -67,9 +76,10 @@ func _internal_joinLinkInformation(_ hash: String, account: Account) -> Signal<E
|> mapToSignal { (result) -> Signal<ExternalJoiningChatState, NoError> in
if let result = result {
switch result {
case let .chatInvite(_, title, about, invitePhoto, participantsCount, participants):
case let .chatInvite(flags, title, about, invitePhoto, participantsCount, participants):
let photo = telegramMediaImageFromApiPhoto(invitePhoto).flatMap({ smallestImageRepresentation($0.representations) })
return .single(.invite(title: title, about: about, photoRepresentation: photo, participantsCount: participantsCount, participants: participants?.map({TelegramUser(user: $0)})))
let flags:ExternalJoiningChatState.InviteFlags = .init(isChannel: (flags & (1 << 0)) != 0, isBroadcast: (flags & (1 << 1)) != 0, isPublic: (flags & (1 << 2)) != 0, isMegagroup: (flags & (1 << 3)) != 0, requestNeeded: (flags & (1 << 6)) != 0)
return .single(.invite(flags: flags, title: title, about: about, photoRepresentation: photo, participantsCount: participantsCount, participants: participants?.map({TelegramUser(user: $0)})))
case let .chatInviteAlready(chat):
if let peer = parseTelegramGroupOrChannel(chat: chat) {
return account.postbox.transaction({ (transaction) -> ExternalJoiningChatState in