no message

This commit is contained in:
overtake 2018-06-15 23:17:26 +03:00
parent 38f04aff40
commit 4b3f89b467
5 changed files with 52 additions and 6 deletions

View File

@ -39,6 +39,8 @@
C27982511E72C97800262BFD /* MacosLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C27982501E72C97800262BFD /* MacosLegacy.swift */; };
C28725421EF967E700613564 /* NotificationInfoMessageAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = C28725411EF967E700613564 /* NotificationInfoMessageAttribute.swift */; };
C28725431EF967E700613564 /* NotificationInfoMessageAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = C28725411EF967E700613564 /* NotificationInfoMessageAttribute.swift */; };
C28D3CF020D3DA900027F4D6 /* DeepLinkInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C28D3CEF20D3DA900027F4D6 /* DeepLinkInfo.swift */; };
C28D3CF120D3DAA30027F4D6 /* DeepLinkInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C28D3CEF20D3DA900027F4D6 /* DeepLinkInfo.swift */; };
C29340F31F5080FA0074991E /* UpdateGroupSpecificStickerset.swift in Sources */ = {isa = PBXBuildFile; fileRef = C29340F21F5080FA0074991E /* UpdateGroupSpecificStickerset.swift */; };
C29340F41F5081280074991E /* UpdateGroupSpecificStickerset.swift in Sources */ = {isa = PBXBuildFile; fileRef = C29340F21F5080FA0074991E /* UpdateGroupSpecificStickerset.swift */; };
C2A315C01E2E776A00D89000 /* RequestStartBot.swift in Sources */ = {isa = PBXBuildFile; fileRef = D01749581E1092BC0057C89A /* RequestStartBot.swift */; };
@ -740,6 +742,7 @@
C251D7421E65E50500283EDE /* StickerSetInstallation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StickerSetInstallation.swift; sourceTree = "<group>"; };
C27982501E72C97800262BFD /* MacosLegacy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MacosLegacy.swift; sourceTree = "<group>"; };
C28725411EF967E700613564 /* NotificationInfoMessageAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationInfoMessageAttribute.swift; sourceTree = "<group>"; };
C28D3CEF20D3DA900027F4D6 /* DeepLinkInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeepLinkInfo.swift; sourceTree = "<group>"; };
C29340F21F5080FA0074991E /* UpdateGroupSpecificStickerset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateGroupSpecificStickerset.swift; sourceTree = "<group>"; };
C2E064671ECEEF0A00387BB8 /* TelegramMediaInvoice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelegramMediaInvoice.swift; sourceTree = "<group>"; };
C2E0646C1ECF171D00387BB8 /* TelegramMediaWebDocument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelegramMediaWebDocument.swift; sourceTree = "<group>"; };
@ -1262,6 +1265,7 @@
D01C06B61FBBA269001561AB /* CanSendMessagesToPeer.swift */,
D0F8C39F2017AF2700236FC5 /* GlobalTelegramCoreConfiguration.swift */,
D0E412E9206AD18E00BEE4A2 /* DecryptedResourceData.swift */,
C28D3CEF20D3DA900027F4D6 /* DeepLinkInfo.swift */,
);
name = Utils;
sourceTree = "<group>";
@ -2240,6 +2244,7 @@
D0BE304B20627D9800FBE6D8 /* AccessSecureId.swift in Sources */,
D0BEAF5D1E54941B00BD963D /* Authorization.swift in Sources */,
D0C26D6C1FE286C3004ABF18 /* FetchChatList.swift in Sources */,
C28D3CF020D3DA900027F4D6 /* DeepLinkInfo.swift in Sources */,
D0B843831DA6EDB8005F29E1 /* CachedGroupData.swift in Sources */,
D0E35A121DE4A25E00BC6096 /* OutgoingChatContextResultMessageAttribute.swift in Sources */,
D093D806206539D000BC3599 /* SaveSecureIdValue.swift in Sources */,
@ -2365,6 +2370,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C28D3CF120D3DAA30027F4D6 /* DeepLinkInfo.swift in Sources */,
9FC8ADAC206BC00A0094F7B4 /* RecentWebSessions.swift in Sources */,
9FC8ADA9206BBD000094F7B4 /* SaveSecureIdValue.swift in Sources */,
9F10CE8C20613CDB002DD61A /* TelegramDeviceContactImportInfo.swift in Sources */,

View File

@ -57,12 +57,22 @@ public func channelAdmins(account: Account, peerId: PeerId) -> Signal<[RenderedC
}
public func channelAdminIds(postbox: Postbox, network: Network, peerId: PeerId, hash: Int32) -> Signal<[PeerId], Void> {
return postbox.modify { modifier in
if let peer = modifier.getPeer(peerId) as? TelegramChannel, case .group = peer.info, let apiChannel = apiInputChannel(peer) {
return postbox.transaction { transaction in
if let peer = transaction.getPeer(peerId) as? TelegramChannel, case .group = peer.info, let apiChannel = apiInputChannel(peer) {
let api = Api.functions.channels.getParticipants(channel: apiChannel, filter: .channelParticipantsAdmins, offset: 0, limit: 100, hash: hash)
return network.request(api) |> retryRequest |> mapToSignal { result in
switch result {
case let .channelParticipants(_, _, users):
case let .channelParticipants(_, participants, users):
let users = users.filter({ user in
return participants.contains(where: { participant in
switch participant {
case let .channelParticipantAdmin(_, userId, _, _, _, _):
return user.peerId.id == userId
default:
return false
}
})
})
return .single(users.map({TelegramUser(user: $0).id}))
default:
return .complete()

View File

@ -0,0 +1,23 @@
import Foundation
#if os(macOS)
import SwiftSignalKitMac
#else
import SwiftSignalKit
#endif
public struct DeepLinkInfo {
public let message: String
public let entities: [MessageTextEntity]
public let updateApp: Bool
}
public func getDeepLinkInfo(network: Network, path: String) -> Signal<DeepLinkInfo?, Void> {
return network.request(Api.functions.help.getDeepLinkInfo(path: path)) |> retryRequest |> map { value -> DeepLinkInfo? in
switch value {
case .deepLinkInfoEmpty:
return nil
case let .deepLinkInfo(flags, message, entities):
return DeepLinkInfo(message: message, entities: entities != nil ? messageTextEntitiesFromApiEntities(entities!) : [], updateApp: (flags & (1 << 0)) != 0)
}
}
}

View File

@ -19,8 +19,8 @@ public struct ChatContextGeoPoint {
}
public func requestChatContextResults(account: Account, botId: PeerId, peerId: PeerId, query: String, offset: String, geopoint: ChatContextGeoPoint? = nil) -> Signal<ChatContextResultCollection?, NoError> {
return account.postbox.modify { modifier -> (bot: Peer, peer: Peer)? in
if let bot = modifier.getPeer(botId), let peer = modifier.getPeer(peerId) {
return account.postbox.transaction { transaction -> (bot: Peer, peer: Peer)? in
if let bot = transaction.getPeer(botId), let peer = transaction.getPeer(peerId) {
return (bot, peer)
} else {
return nil

View File

@ -12,6 +12,7 @@ import Foundation
public enum RequestSecureIdFormError {
case generic
case serverError(String)
case versionOutdated
}
private func parseSecureValueType(_ type: Api.SecureValueType, selfie: Bool) -> SecureIdRequestedFormField {
@ -238,7 +239,13 @@ public func requestSecureIdForm(postbox: Postbox, network: Network, peerId: Peer
}
return network.request(Api.functions.account.getAuthorizationForm(botId: peerId.id, scope: scope, publicKey: publicKey))
|> mapError { error -> RequestSecureIdFormError in
return .serverError(error.errorDescription)
switch error.errorDescription {
case "APP_VERSION_OUTDATED":
return .versionOutdated
default:
return .serverError(error.errorDescription)
}
}
|> mapToSignal { result -> Signal<EncryptedSecureIdForm, RequestSecureIdFormError> in
return postbox.transaction { transaction -> EncryptedSecureIdForm in