Update API

This commit is contained in:
Peter 2019-02-22 18:21:37 +03:00
parent f787c05c93
commit 7872182e3c
6 changed files with 61 additions and 7 deletions

View File

@ -739,6 +739,8 @@
D0F3CC7D1DDE289E008148FA /* ResolvePeerByName.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F3CC7C1DDE289E008148FA /* ResolvePeerByName.swift */; };
D0F53BE91E784A4800117362 /* ChangeAccountPhoneNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F53BE81E784A4800117362 /* ChangeAccountPhoneNumber.swift */; };
D0F53BEA1E784A4800117362 /* ChangeAccountPhoneNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F53BE81E784A4800117362 /* ChangeAccountPhoneNumber.swift */; };
D0F760D822202FE20074F7E5 /* ChannelStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F760D722202FE20074F7E5 /* ChannelStats.swift */; };
D0F760D922202FE20074F7E5 /* ChannelStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F760D722202FE20074F7E5 /* ChannelStats.swift */; };
D0F7AB2C1DCE889D009AD9A1 /* EditedMessageAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F7AB2B1DCE889D009AD9A1 /* EditedMessageAttribute.swift */; };
D0F7AB2D1DCE889D009AD9A1 /* EditedMessageAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F7AB2B1DCE889D009AD9A1 /* EditedMessageAttribute.swift */; };
D0F7AB2F1DCF507E009AD9A1 /* ReplyMarkupMessageAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F7AB2E1DCF507E009AD9A1 /* ReplyMarkupMessageAttribute.swift */; };
@ -1200,6 +1202,7 @@
D0F3A8A71E82CD7D00B4C64C /* UpdatePeerChatInterfaceState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdatePeerChatInterfaceState.swift; sourceTree = "<group>"; };
D0F3CC7C1DDE289E008148FA /* ResolvePeerByName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResolvePeerByName.swift; sourceTree = "<group>"; };
D0F53BE81E784A4800117362 /* ChangeAccountPhoneNumber.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChangeAccountPhoneNumber.swift; sourceTree = "<group>"; };
D0F760D722202FE20074F7E5 /* ChannelStats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelStats.swift; sourceTree = "<group>"; };
D0F7AB2B1DCE889D009AD9A1 /* EditedMessageAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditedMessageAttribute.swift; sourceTree = "<group>"; };
D0F7AB2E1DCF507E009AD9A1 /* ReplyMarkupMessageAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReplyMarkupMessageAttribute.swift; sourceTree = "<group>"; };
D0F8C39C20178B9B00236FC5 /* GroupFeedPeers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupFeedPeers.swift; sourceTree = "<group>"; };
@ -1962,6 +1965,7 @@
D0F8C39C20178B9B00236FC5 /* GroupFeedPeers.swift */,
D018EE042045E95000CBB130 /* CheckPeerChatServiceActions.swift */,
9F06830F21A40DEC001D8EDB /* NotificationExceptionsList.swift */,
D0F760D722202FE20074F7E5 /* ChannelStats.swift */,
);
name = Peers;
sourceTree = "<group>";
@ -2469,6 +2473,7 @@
D0CA3F84207391560042D2B6 /* SecureIdPadding.swift in Sources */,
D0FA8BB61E223C16001E855B /* SecretApiLayer8.swift in Sources */,
D0B843C71DA7FF30005F29E1 /* NBPhoneNumberDefines.m in Sources */,
D0F760D822202FE20074F7E5 /* ChannelStats.swift in Sources */,
0962E66921B5A11100245FD9 /* SynchronizeAppLogEventsOperation.swift in Sources */,
D049EAF51E44DF3300A2CD3A /* AccountState.swift in Sources */,
C28725421EF967E700613564 /* NotificationInfoMessageAttribute.swift in Sources */,
@ -2861,6 +2866,7 @@
D0F7B1E41E045C7B007EB8A5 /* InstantPage.swift in Sources */,
D03E5E0D1E55E02D0029569A /* LoggedOutAccountAttribute.swift in Sources */,
D0B418AD1D7E0597004562A4 /* Serialization.swift in Sources */,
D0F760D922202FE20074F7E5 /* ChannelStats.swift in Sources */,
D0ADF912212B00DD00310BBC /* SecureIdConfiguration.swift in Sources */,
C28725431EF967E700613564 /* NotificationInfoMessageAttribute.swift in Sources */,
D0A89990217A37A000759EE6 /* NotificationAutolockReportManager.swift in Sources */,

View File

@ -2740,11 +2740,12 @@ extension Api {
})
}
static func getStatsURL(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.StatsURL>) {
static func getStatsURL(peer: Api.InputPeer, params: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.StatsURL>) {
let buffer = Buffer()
buffer.appendInt32(-2080980787)
buffer.appendInt32(-338326349)
peer.serialize(buffer, true)
return (FunctionDescription(name: "messages.getStatsURL", parameters: [("peer", peer)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.StatsURL? in
serializeString(params, buffer: buffer, boxed: false)
return (FunctionDescription(name: "messages.getStatsURL", parameters: [("peer", peer), ("params", params)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.StatsURL? in
let reader = BufferReader(buffer)
var result: Api.StatsURL?
if let signature = reader.readInt32() {

View File

@ -20,6 +20,7 @@ public struct CachedChannelFlags: OptionSet {
public static let canChangeUsername = CachedChannelFlags(rawValue: 1 << 1)
public static let canSetStickerSet = CachedChannelFlags(rawValue: 1 << 2)
public static let preHistoryEnabled = CachedChannelFlags(rawValue: 1 << 3)
public static let canViewStats = CachedChannelFlags(rawValue: 1 << 4)
}
public struct CachedChannelParticipantsSummary: PostboxCoding, Equatable {

View File

@ -0,0 +1,34 @@
import Foundation
#if os(macOS)
import SwiftSignalKitMac
import PostboxMac
#else
import SwiftSignalKit
import Postbox
#endif
public enum ChannelStatsUrlError {
case generic
}
public func channelStatsUrl(postbox: Postbox, network: Network, peerId: PeerId, params: String) -> Signal<String, ChannelStatsUrlError> {
return postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}
|> introduceError(ChannelStatsUrlError.self)
|> mapToSignal { inputPeer -> Signal<String, ChannelStatsUrlError> in
guard let inputPeer = inputPeer else {
return .fail(.generic)
}
return network.request(Api.functions.messages.getStatsURL(peer: inputPeer, params: params))
|> map { result -> String in
switch result {
case let .statsURL(url):
return url
}
}
|> `catch` { _ -> Signal<String, ChannelStatsUrlError> in
return .fail(.generic)
}
}
}

View File

@ -7,13 +7,22 @@ import Foundation
import SwiftSignalKit
#endif
public func removePeerChat(postbox: Postbox, peerId: PeerId, reportChatSpam: Bool, deleteGloballyIfPossible: Bool = false) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in
removePeerChat(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId, reportChatSpam: reportChatSpam, deleteGloballyIfPossible: deleteGloballyIfPossible)
public func removePeerChat(account: Account, peerId: PeerId, reportChatSpam: Bool, deleteGloballyIfPossible: Bool = false) -> Signal<Void, NoError> {
return account.postbox.transaction { transaction -> Void in
removePeerChat(account: account, transaction: transaction, mediaBox: account.postbox.mediaBox, peerId: peerId, reportChatSpam: reportChatSpam, deleteGloballyIfPossible: deleteGloballyIfPossible)
}
}
public func removePeerChat(transaction: Transaction, mediaBox: MediaBox, peerId: PeerId, reportChatSpam: Bool, deleteGloballyIfPossible: Bool) {
public func removePeerChat(account: Account, transaction: Transaction, mediaBox: MediaBox, peerId: PeerId, reportChatSpam: Bool, deleteGloballyIfPossible: Bool) {
if let _ = transaction.getPeerChatInterfaceState(peerId) {
transaction.updatePeerChatInterfaceState(peerId, update: { current in
if let current = current {
return account.auxiliaryMethods.updatePeerChatInputState(current, nil)
} else {
return nil
}
})
}
if peerId.namespace == Namespaces.Peer.SecretChat {
if let state = transaction.getPeerChatState(peerId) as? SecretChatState {

View File

@ -265,6 +265,9 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
if (flags & (1 << 10)) == 0 {
channelFlags.insert(.preHistoryEnabled)
}
if (flags & (1 << 12)) != 0 {
channelFlags.insert(.canViewStats)
}
if (flags & (1 << 7)) != 0 {
channelFlags.insert(.canSetStickerSet)
}