mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
API update
This commit is contained in:
parent
e72208e35f
commit
d8d442caad
@ -111,7 +111,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[497489295] = { return Api.help.AppUpdate.parse_appUpdate($0) }
|
||||
dict[-209337866] = { return Api.LangPackDifference.parse_langPackDifference($0) }
|
||||
dict[84438264] = { return Api.WallPaperSettings.parse_wallPaperSettings($0) }
|
||||
dict[1152191385] = { return Api.EmojiURL.parse_EmojiURL($0) }
|
||||
dict[-1519029347] = { return Api.EmojiURL.parse_emojiURL($0) }
|
||||
dict[1611985938] = { return Api.StatsGroupTopAdmin.parse_statsGroupTopAdmin($0) }
|
||||
dict[-791039645] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) }
|
||||
dict[-1736378792] = { return Api.InputCheckPasswordSRP.parse_inputCheckPasswordEmpty($0) }
|
||||
@ -189,7 +189,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-364179876] = { return Api.Update.parse_updateChatParticipantAdd($0) }
|
||||
dict[1851755554] = { return Api.Update.parse_updateChatParticipantDelete($0) }
|
||||
dict[-1906403213] = { return Api.Update.parse_updateDcOptions($0) }
|
||||
dict[-2131957734] = { return Api.Update.parse_updateUserBlocked($0) }
|
||||
dict[-1094555409] = { return Api.Update.parse_updateNotifySettings($0) }
|
||||
dict[-337352679] = { return Api.Update.parse_updateServiceNotification($0) }
|
||||
dict[-298113238] = { return Api.Update.parse_updatePrivacy($0) }
|
||||
@ -257,6 +256,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1708307556] = { return Api.Update.parse_updateChannelParticipant($0) }
|
||||
dict[1854571743] = { return Api.Update.parse_updateChannelMessageForwards($0) }
|
||||
dict[295679367] = { return Api.Update.parse_updateReadDiscussion($0) }
|
||||
dict[610945826] = { return Api.Update.parse_updatePeerBlocked($0) }
|
||||
dict[136574537] = { return Api.messages.VotesList.parse_votesList($0) }
|
||||
dict[1558266229] = { return Api.PopularContact.parse_popularContact($0) }
|
||||
dict[-373643672] = { return Api.FolderPeer.parse_folderPeer($0) }
|
||||
@ -268,8 +268,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1567730343] = { return Api.MessageUserVote.parse_messageUserVote($0) }
|
||||
dict[909603888] = { return Api.MessageUserVote.parse_messageUserVoteInputOption($0) }
|
||||
dict[244310238] = { return Api.MessageUserVote.parse_messageUserVoteMultiple($0) }
|
||||
dict[471043349] = { return Api.contacts.Blocked.parse_blocked($0) }
|
||||
dict[-1878523231] = { return Api.contacts.Blocked.parse_blockedSlice($0) }
|
||||
dict[182326673] = { return Api.contacts.Blocked.parse_blocked($0) }
|
||||
dict[-513392236] = { return Api.contacts.Blocked.parse_blockedSlice($0) }
|
||||
dict[-55902537] = { return Api.InputDialogPeer.parse_inputDialogPeer($0) }
|
||||
dict[1684014375] = { return Api.InputDialogPeer.parse_inputDialogPeerFolder($0) }
|
||||
dict[-994444869] = { return Api.Error.parse_error($0) }
|
||||
@ -492,11 +492,11 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1495959709] = { return Api.MessageReplyHeader.parse_messageReplyHeader($0) }
|
||||
dict[411017418] = { return Api.SecureValue.parse_secureValue($0) }
|
||||
dict[-316748368] = { return Api.SecureValueHash.parse_secureValueHash($0) }
|
||||
dict[1444661369] = { return Api.ContactBlocked.parse_contactBlocked($0) }
|
||||
dict[-398136321] = { return Api.messages.SearchCounter.parse_searchCounter($0) }
|
||||
dict[-2128698738] = { return Api.auth.CheckedPhone.parse_checkedPhone($0) }
|
||||
dict[-1188055347] = { return Api.PageListItem.parse_pageListItemText($0) }
|
||||
dict[635466748] = { return Api.PageListItem.parse_pageListItemBlocks($0) }
|
||||
dict[-386039788] = { return Api.PeerBlocked.parse_peerBlocked($0) }
|
||||
dict[-1182234929] = { return Api.InputUser.parse_inputUserEmpty($0) }
|
||||
dict[-138301121] = { return Api.InputUser.parse_inputUserSelf($0) }
|
||||
dict[-668391402] = { return Api.InputUser.parse_inputUser($0) }
|
||||
@ -1200,14 +1200,14 @@ public struct Api {
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.SecureValueHash:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.ContactBlocked:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.messages.SearchCounter:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.auth.CheckedPhone:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.PageListItem:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.PeerBlocked:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.InputUser:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.Page:
|
||||
|
@ -5004,13 +5004,13 @@ public extension Api {
|
||||
|
||||
}
|
||||
public enum EmojiURL: TypeConstructorDescription {
|
||||
case EmojiURL(url: String)
|
||||
case emojiURL(url: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .EmojiURL(let url):
|
||||
case .emojiURL(let url):
|
||||
if boxed {
|
||||
buffer.appendInt32(1152191385)
|
||||
buffer.appendInt32(-1519029347)
|
||||
}
|
||||
serializeString(url, buffer: buffer, boxed: false)
|
||||
break
|
||||
@ -5019,17 +5019,17 @@ public extension Api {
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .EmojiURL(let url):
|
||||
return ("EmojiURL", [("url", url)])
|
||||
case .emojiURL(let url):
|
||||
return ("emojiURL", [("url", url)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_EmojiURL(_ reader: BufferReader) -> EmojiURL? {
|
||||
public static func parse_emojiURL(_ reader: BufferReader) -> EmojiURL? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.EmojiURL.EmojiURL(url: _1!)
|
||||
return Api.EmojiURL.emojiURL(url: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -6104,7 +6104,6 @@ public extension Api {
|
||||
case updateChatParticipantAdd(chatId: Int32, userId: Int32, inviterId: Int32, date: Int32, version: Int32)
|
||||
case updateChatParticipantDelete(chatId: Int32, userId: Int32, version: Int32)
|
||||
case updateDcOptions(dcOptions: [Api.DcOption])
|
||||
case updateUserBlocked(userId: Int32, blocked: Api.Bool)
|
||||
case updateNotifySettings(peer: Api.NotifyPeer, notifySettings: Api.PeerNotifySettings)
|
||||
case updateServiceNotification(flags: Int32, inboxDate: Int32?, type: String, message: String, media: Api.MessageMedia, entities: [Api.MessageEntity])
|
||||
case updatePrivacy(key: Api.PrivacyKey, rules: [Api.PrivacyRule])
|
||||
@ -6172,6 +6171,7 @@ public extension Api {
|
||||
case updateChannelParticipant(flags: Int32, channelId: Int32, date: Int32, userId: Int32, prevParticipant: Api.ChannelParticipant?, newParticipant: Api.ChannelParticipant?, qts: Int32)
|
||||
case updateChannelMessageForwards(channelId: Int32, id: Int32, forwards: Int32)
|
||||
case updateReadDiscussion(peer: Api.Peer, msgId: Int32, readMaxId: Int32)
|
||||
case updatePeerBlocked(peerId: Api.Peer, blocked: Api.Bool)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -6304,13 +6304,6 @@ public extension Api {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .updateUserBlocked(let userId, let blocked):
|
||||
if boxed {
|
||||
buffer.appendInt32(-2131957734)
|
||||
}
|
||||
serializeInt32(userId, buffer: buffer, boxed: false)
|
||||
blocked.serialize(buffer, true)
|
||||
break
|
||||
case .updateNotifySettings(let peer, let notifySettings):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1094555409)
|
||||
@ -6880,6 +6873,13 @@ public extension Api {
|
||||
serializeInt32(msgId, buffer: buffer, boxed: false)
|
||||
serializeInt32(readMaxId, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .updatePeerBlocked(let peerId, let blocked):
|
||||
if boxed {
|
||||
buffer.appendInt32(610945826)
|
||||
}
|
||||
peerId.serialize(buffer, true)
|
||||
blocked.serialize(buffer, true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -6917,8 +6917,6 @@ public extension Api {
|
||||
return ("updateChatParticipantDelete", [("chatId", chatId), ("userId", userId), ("version", version)])
|
||||
case .updateDcOptions(let dcOptions):
|
||||
return ("updateDcOptions", [("dcOptions", dcOptions)])
|
||||
case .updateUserBlocked(let userId, let blocked):
|
||||
return ("updateUserBlocked", [("userId", userId), ("blocked", blocked)])
|
||||
case .updateNotifySettings(let peer, let notifySettings):
|
||||
return ("updateNotifySettings", [("peer", peer), ("notifySettings", notifySettings)])
|
||||
case .updateServiceNotification(let flags, let inboxDate, let type, let message, let media, let entities):
|
||||
@ -7053,6 +7051,8 @@ public extension Api {
|
||||
return ("updateChannelMessageForwards", [("channelId", channelId), ("id", id), ("forwards", forwards)])
|
||||
case .updateReadDiscussion(let peer, let msgId, let readMaxId):
|
||||
return ("updateReadDiscussion", [("peer", peer), ("msgId", msgId), ("readMaxId", readMaxId)])
|
||||
case .updatePeerBlocked(let peerId, let blocked):
|
||||
return ("updatePeerBlocked", [("peerId", peerId), ("blocked", blocked)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -7329,22 +7329,6 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_updateUserBlocked(_ reader: BufferReader) -> Update? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.Update.updateUserBlocked(userId: _1!, blocked: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_updateNotifySettings(_ reader: BufferReader) -> Update? {
|
||||
var _1: Api.NotifyPeer?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -8467,6 +8451,24 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_updatePeerBlocked(_ reader: BufferReader) -> Update? {
|
||||
var _1: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
var _2: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.Update.updatePeerBlocked(peerId: _1!, blocked: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum PopularContact: TypeConstructorDescription {
|
||||
@ -14302,44 +14304,6 @@ public extension Api {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum ContactBlocked: TypeConstructorDescription {
|
||||
case contactBlocked(userId: Int32, date: Int32)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .contactBlocked(let userId, let date):
|
||||
if boxed {
|
||||
buffer.appendInt32(1444661369)
|
||||
}
|
||||
serializeInt32(userId, buffer: buffer, boxed: false)
|
||||
serializeInt32(date, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .contactBlocked(let userId, let date):
|
||||
return ("contactBlocked", [("userId", userId), ("date", date)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_contactBlocked(_ reader: BufferReader) -> ContactBlocked? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.ContactBlocked.contactBlocked(userId: _1!, date: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum PageListItem: TypeConstructorDescription {
|
||||
case pageListItemText(text: Api.RichText)
|
||||
@ -14402,6 +14366,46 @@ public extension Api {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum PeerBlocked: TypeConstructorDescription {
|
||||
case peerBlocked(peerId: Api.Peer, date: Int32)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .peerBlocked(let peerId, let date):
|
||||
if boxed {
|
||||
buffer.appendInt32(-386039788)
|
||||
}
|
||||
peerId.serialize(buffer, true)
|
||||
serializeInt32(date, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .peerBlocked(let peerId, let date):
|
||||
return ("peerBlocked", [("peerId", peerId), ("date", date)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_peerBlocked(_ reader: BufferReader) -> PeerBlocked? {
|
||||
var _1: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.PeerBlocked.peerBlocked(peerId: _1!, date: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum InputUser: TypeConstructorDescription {
|
||||
case inputUserEmpty
|
||||
|
@ -1315,14 +1315,14 @@ public struct auth {
|
||||
public extension Api {
|
||||
public struct contacts {
|
||||
public enum Blocked: TypeConstructorDescription {
|
||||
case blocked(blocked: [Api.ContactBlocked], users: [Api.User])
|
||||
case blockedSlice(count: Int32, blocked: [Api.ContactBlocked], users: [Api.User])
|
||||
case blocked(blocked: [Api.PeerBlocked], chats: [Api.Chat], users: [Api.User])
|
||||
case blockedSlice(count: Int32, blocked: [Api.PeerBlocked], chats: [Api.Chat], users: [Api.User])
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .blocked(let blocked, let users):
|
||||
case .blocked(let blocked, let chats, let users):
|
||||
if boxed {
|
||||
buffer.appendInt32(471043349)
|
||||
buffer.appendInt32(182326673)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(blocked.count))
|
||||
@ -1330,14 +1330,19 @@ public struct contacts {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(chats.count))
|
||||
for item in chats {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(users.count))
|
||||
for item in users {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .blockedSlice(let count, let blocked, let users):
|
||||
case .blockedSlice(let count, let blocked, let chats, let users):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1878523231)
|
||||
buffer.appendInt32(-513392236)
|
||||
}
|
||||
serializeInt32(count, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
@ -1346,6 +1351,11 @@ public struct contacts {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(chats.count))
|
||||
for item in chats {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(users.count))
|
||||
for item in users {
|
||||
item.serialize(buffer, true)
|
||||
@ -1356,37 +1366,21 @@ public struct contacts {
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .blocked(let blocked, let users):
|
||||
return ("blocked", [("blocked", blocked), ("users", users)])
|
||||
case .blockedSlice(let count, let blocked, let users):
|
||||
return ("blockedSlice", [("count", count), ("blocked", blocked), ("users", users)])
|
||||
case .blocked(let blocked, let chats, let users):
|
||||
return ("blocked", [("blocked", blocked), ("chats", chats), ("users", users)])
|
||||
case .blockedSlice(let count, let blocked, let chats, let users):
|
||||
return ("blockedSlice", [("count", count), ("blocked", blocked), ("chats", chats), ("users", users)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_blocked(_ reader: BufferReader) -> Blocked? {
|
||||
var _1: [Api.ContactBlocked]?
|
||||
var _1: [Api.PeerBlocked]?
|
||||
if let _ = reader.readInt32() {
|
||||
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.ContactBlocked.self)
|
||||
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PeerBlocked.self)
|
||||
}
|
||||
var _2: [Api.User]?
|
||||
var _2: [Api.Chat]?
|
||||
if let _ = reader.readInt32() {
|
||||
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.contacts.Blocked.blocked(blocked: _1!, users: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_blockedSlice(_ reader: BufferReader) -> Blocked? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: [Api.ContactBlocked]?
|
||||
if let _ = reader.readInt32() {
|
||||
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.ContactBlocked.self)
|
||||
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
|
||||
}
|
||||
var _3: [Api.User]?
|
||||
if let _ = reader.readInt32() {
|
||||
@ -1396,7 +1390,33 @@ public struct contacts {
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.contacts.Blocked.blockedSlice(count: _1!, blocked: _2!, users: _3!)
|
||||
return Api.contacts.Blocked.blocked(blocked: _1!, chats: _2!, users: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_blockedSlice(_ reader: BufferReader) -> Blocked? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: [Api.PeerBlocked]?
|
||||
if let _ = reader.readInt32() {
|
||||
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PeerBlocked.self)
|
||||
}
|
||||
var _3: [Api.Chat]?
|
||||
if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
|
||||
}
|
||||
var _4: [Api.User]?
|
||||
if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.contacts.Blocked.blockedSlice(count: _1!, blocked: _2!, chats: _3!, users: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -4957,34 +4957,6 @@ public extension Api {
|
||||
})
|
||||
}
|
||||
|
||||
public static func block(id: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(858475004)
|
||||
id.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "contacts.block", parameters: [("id", id)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func unblock(id: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-448724803)
|
||||
id.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "contacts.unblock", parameters: [("id", id)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func getBlocked(offset: Int32, limit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.contacts.Blocked>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-176409329)
|
||||
@ -5232,6 +5204,34 @@ public extension Api {
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func block(id: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1758204945)
|
||||
id.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "contacts.block", parameters: [("id", id)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func unblock(id: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-1096393392)
|
||||
id.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "contacts.unblock", parameters: [("id", id)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public struct help {
|
||||
public static func getConfig() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Config>) {
|
||||
|
@ -1129,8 +1129,8 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
return previous.withUpdatedPinnedMessageId(id == 0 ? nil : MessageId(peerId: groupPeerId, namespace: Namespaces.Message.Cloud, id: id))
|
||||
})
|
||||
case let .updateUserBlocked(userId, blocked):
|
||||
let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
case let .updatePeerBlocked(peerId, blocked):
|
||||
let userPeerId = peerId.peerId
|
||||
updatedState.updateCachedPeerData(userPeerId, { current in
|
||||
let previous: CachedUserData
|
||||
if let current = current as? CachedUserData {
|
||||
|
@ -13,11 +13,19 @@ public func requestBlockedPeers(account: Account) -> Signal<[Peer], NoError> {
|
||||
return account.postbox.transaction { transaction -> [Peer] in
|
||||
var peers: [Peer] = []
|
||||
let apiUsers: [Api.User]
|
||||
let apiChats: [Api.Chat]
|
||||
switch result {
|
||||
case let .blocked(_, users):
|
||||
case let .blocked(_, chats, users):
|
||||
apiUsers = users
|
||||
case let .blockedSlice(_, _, users):
|
||||
apiChats = chats
|
||||
case let .blockedSlice(_, _, chats, users):
|
||||
apiUsers = users
|
||||
apiChats = chats
|
||||
}
|
||||
for chat in apiChats {
|
||||
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
||||
peers.append(groupOrChannel)
|
||||
}
|
||||
}
|
||||
for user in apiUsers {
|
||||
let parsed = TelegramUser(user: user)
|
||||
@ -35,12 +43,12 @@ public func requestBlockedPeers(account: Account) -> Signal<[Peer], NoError> {
|
||||
|
||||
public func requestUpdatePeerIsBlocked(account: Account, peerId: PeerId, isBlocked: Bool) -> Signal<Void, NoError> {
|
||||
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
if let peer = transaction.getPeer(peerId), let inputUser = apiInputUser(peer) {
|
||||
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
|
||||
let signal: Signal<Api.Bool, MTRpcError>
|
||||
if isBlocked {
|
||||
signal = account.network.request(Api.functions.contacts.block(id: inputUser))
|
||||
signal = account.network.request(Api.functions.contacts.block(id: inputPeer))
|
||||
} else {
|
||||
signal = account.network.request(Api.functions.contacts.unblock(id: inputUser))
|
||||
signal = account.network.request(Api.functions.contacts.unblock(id: inputPeer))
|
||||
}
|
||||
return signal
|
||||
|> map(Optional.init)
|
||||
|
@ -64,8 +64,13 @@ public final class BlockedPeersContext {
|
||||
|> mapToSignal { result -> Signal<(peers: [RenderedPeer], canLoadMore: Bool, totalCount: Int?), NoError> in
|
||||
return postbox.transaction { transaction -> (peers: [RenderedPeer], canLoadMore: Bool, totalCount: Int?) in
|
||||
switch result {
|
||||
case let .blocked(blocked, users):
|
||||
case let .blocked(blocked, chats, users):
|
||||
var peers: [Peer] = []
|
||||
for chat in chats {
|
||||
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
||||
peers.append(groupOrChannel)
|
||||
}
|
||||
}
|
||||
for user in users {
|
||||
peers.append(TelegramUser(user: user))
|
||||
}
|
||||
@ -74,16 +79,21 @@ public final class BlockedPeersContext {
|
||||
var renderedPeers: [RenderedPeer] = []
|
||||
for blockedPeer in blocked {
|
||||
switch blockedPeer {
|
||||
case let .contactBlocked(userId, _):
|
||||
if let peer = transaction.getPeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)) {
|
||||
case let .peerBlocked(peerId, _):
|
||||
if let peer = transaction.getPeer(peerId.peerId) {
|
||||
renderedPeers.append(RenderedPeer(peer: peer))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (renderedPeers, false, nil)
|
||||
case let .blockedSlice(count, blocked, users):
|
||||
case let .blockedSlice(count, blocked, chats, users):
|
||||
var peers: [Peer] = []
|
||||
for chat in chats {
|
||||
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
||||
peers.append(groupOrChannel)
|
||||
}
|
||||
}
|
||||
for user in users {
|
||||
peers.append(TelegramUser(user: user))
|
||||
}
|
||||
@ -92,8 +102,8 @@ public final class BlockedPeersContext {
|
||||
var renderedPeers: [RenderedPeer] = []
|
||||
for blockedPeer in blocked {
|
||||
switch blockedPeer {
|
||||
case let .contactBlocked(userId, _):
|
||||
if let peer = transaction.getPeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)) {
|
||||
case let .peerBlocked(peerId, _):
|
||||
if let peer = transaction.getPeer(peerId.peerId) {
|
||||
renderedPeers.append(RenderedPeer(peer: peer))
|
||||
}
|
||||
}
|
||||
@ -135,15 +145,15 @@ public final class BlockedPeersContext {
|
||||
|
||||
let postbox = self.account.postbox
|
||||
let network = self.account.network
|
||||
return self.account.postbox.transaction { transaction -> Api.InputUser? in
|
||||
return transaction.getPeer(peerId).flatMap(apiInputUser)
|
||||
return self.account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||
}
|
||||
|> castError(BlockedPeersContextAddError.self)
|
||||
|> mapToSignal { [weak self] inputUser -> Signal<Never, BlockedPeersContextAddError> in
|
||||
guard let inputUser = inputUser else {
|
||||
|> mapToSignal { [weak self] inputPeer -> Signal<Never, BlockedPeersContextAddError> in
|
||||
guard let inputPeer = inputPeer else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
return network.request(Api.functions.contacts.block(id: inputUser))
|
||||
return network.request(Api.functions.contacts.block(id: inputPeer))
|
||||
|> mapError { _ -> BlockedPeersContextAddError in
|
||||
return .generic
|
||||
}
|
||||
@ -192,15 +202,15 @@ public final class BlockedPeersContext {
|
||||
assert(Queue.mainQueue().isCurrent())
|
||||
let postbox = self.account.postbox
|
||||
let network = self.account.network
|
||||
return self.account.postbox.transaction { transaction -> Api.InputUser? in
|
||||
return transaction.getPeer(peerId).flatMap(apiInputUser)
|
||||
return self.account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||
}
|
||||
|> castError(BlockedPeersContextRemoveError.self)
|
||||
|> mapToSignal { [weak self] inputUser -> Signal<Never, BlockedPeersContextRemoveError> in
|
||||
guard let inputUser = inputUser else {
|
||||
|> mapToSignal { [weak self] inputPeer -> Signal<Never, BlockedPeersContextRemoveError> in
|
||||
guard let inputPeer = inputPeer else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
return network.request(Api.functions.contacts.unblock(id: inputUser))
|
||||
return network.request(Api.functions.contacts.unblock(id: inputPeer))
|
||||
|> mapError { _ -> BlockedPeersContextRemoveError in
|
||||
return .generic
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user