mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-07 06:43:43 +00:00
API updates
This commit is contained in:
parent
da68a6d0db
commit
214764ee38
@ -1034,17 +1034,12 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
return current
|
||||
}
|
||||
})
|
||||
case let .updateChatAdmins(chatId, enabled, version):
|
||||
updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId), { peer in
|
||||
case let .updateChatDefaultBannedRights(peer, defaultBannedRights, version):
|
||||
updatedState.updatePeer(peer.peerId, { peer in
|
||||
if let group = peer as? TelegramGroup {//, group.version == version - 1 {
|
||||
var flags = group.flags
|
||||
switch enabled {
|
||||
case .boolTrue:
|
||||
flags.insert(.adminsEnabled)
|
||||
case .boolFalse:
|
||||
let _ = flags.remove(.adminsEnabled)
|
||||
}
|
||||
return group.updateFlags(flags: flags, version: max(group.version, Int(version)))
|
||||
return group.updateDefaultBannedRights(TelegramChatBannedRights(apiBannedRights: defaultBannedRights), version: max(group.version, Int(version)))
|
||||
} else if let channel = peer as? TelegramChannel {//, group.version == version - 1 {
|
||||
return channel.withUpdatedDefaultBannedRights(TelegramChatBannedRights(apiBannedRights: defaultBannedRights))
|
||||
} else {
|
||||
return peer
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-457104426] = { return Api.InputGeoPoint.parse_inputGeoPointEmpty($0) }
|
||||
dict[-206066487] = { return Api.InputGeoPoint.parse_inputGeoPoint($0) }
|
||||
dict[-784000893] = { return Api.payments.ValidatedRequestedInfo.parse_validatedRequestedInfo($0) }
|
||||
dict[-2092810828] = { return Api.ChatFull.parse_channelFull($0) }
|
||||
dict[1682396002] = { return Api.ChatFull.parse_chatFull($0) }
|
||||
dict[478652186] = { return Api.ChatFull.parse_channelFull($0) }
|
||||
dict[581055962] = { return Api.ChatFull.parse_chatFull($0) }
|
||||
dict[1465219162] = { return Api.PollResults.parse_pollResults($0) }
|
||||
dict[-925415106] = { return Api.ChatParticipant.parse_chatParticipant($0) }
|
||||
dict[-636267638] = { return Api.ChatParticipant.parse_chatParticipantCreator($0) }
|
||||
@ -57,8 +57,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1683826688] = { return Api.Chat.parse_chatEmpty($0) }
|
||||
dict[120753115] = { return Api.Chat.parse_chatForbidden($0) }
|
||||
dict[681420594] = { return Api.Chat.parse_channelForbidden($0) }
|
||||
dict[17100984] = { return Api.Chat.parse_chat($0) }
|
||||
dict[-1197714950] = { return Api.Chat.parse_channel($0) }
|
||||
dict[1004149726] = { return Api.Chat.parse_chat($0) }
|
||||
dict[1307772980] = { return Api.Chat.parse_channel($0) }
|
||||
dict[1202287072] = { return Api.StatsURL.parse_statsURL($0) }
|
||||
dict[1516793212] = { return Api.ChatInvite.parse_chatInviteAlready($0) }
|
||||
dict[-613092008] = { return Api.ChatInvite.parse_chatInvite($0) }
|
||||
@ -181,7 +181,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1108669311] = { return Api.Update.parse_updateReadChannelInbox($0) }
|
||||
dict[-1015733815] = { return Api.Update.parse_updateDeleteChannelMessages($0) }
|
||||
dict[-1734268085] = { return Api.Update.parse_updateChannelMessageViews($0) }
|
||||
dict[1855224129] = { return Api.Update.parse_updateChatAdmins($0) }
|
||||
dict[-1232070311] = { return Api.Update.parse_updateChatParticipantAdmin($0) }
|
||||
dict[1753886890] = { return Api.Update.parse_updateNewStickerSet($0) }
|
||||
dict[196268545] = { return Api.Update.parse_updateStickerSetsOrder($0) }
|
||||
@ -218,6 +217,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1279515160] = { return Api.Update.parse_updateUserPinnedMessage($0) }
|
||||
dict[579418918] = { return Api.Update.parse_updateChatPinnedMessage($0) }
|
||||
dict[-1398708869] = { return Api.Update.parse_updateMessagePoll($0) }
|
||||
dict[1421875280] = { return Api.Update.parse_updateChatDefaultBannedRights($0) }
|
||||
dict[1558266229] = { return Api.PopularContact.parse_popularContact($0) }
|
||||
dict[367766557] = { return Api.ChannelParticipant.parse_channelParticipant($0) }
|
||||
dict[-1557620115] = { return Api.ChannelParticipant.parse_channelParticipantSelf($0) }
|
||||
|
||||
@ -50,14 +50,14 @@ extension Api {
|
||||
|
||||
}
|
||||
enum ChatFull: TypeConstructorDescription {
|
||||
case channelFull(flags: Int32, id: Int32, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, onlineCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite, botInfo: [Api.BotInfo], migratedFromChatId: Int32?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, defaultBannedRights: Api.ChatBannedRights?)
|
||||
case chatFull(flags: Int32, id: Int32, about: String, participants: Api.ChatParticipants, chatPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite, botInfo: [Api.BotInfo]?, pinnedMsgId: Int32?, defaultBannedRights: Api.ChatBannedRights?)
|
||||
case channelFull(flags: Int32, id: Int32, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, onlineCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite, botInfo: [Api.BotInfo], migratedFromChatId: Int32?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?)
|
||||
case chatFull(flags: Int32, id: Int32, about: String, participants: Api.ChatParticipants, chatPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite, botInfo: [Api.BotInfo]?, pinnedMsgId: Int32?)
|
||||
|
||||
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .channelFull(let flags, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId, let defaultBannedRights):
|
||||
case .channelFull(let flags, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId):
|
||||
if boxed {
|
||||
buffer.appendInt32(-2092810828)
|
||||
buffer.appendInt32(478652186)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(id, buffer: buffer, boxed: false)
|
||||
@ -83,11 +83,10 @@ extension Api {
|
||||
if Int(flags) & Int(1 << 5) != 0 {serializeInt32(pinnedMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 8) != 0 {stickerset!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 9) != 0 {serializeInt32(availableMinId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 14) != 0 {defaultBannedRights!.serialize(buffer, true)}
|
||||
break
|
||||
case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId, let defaultBannedRights):
|
||||
case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId):
|
||||
if boxed {
|
||||
buffer.appendInt32(1682396002)
|
||||
buffer.appendInt32(581055962)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(id, buffer: buffer, boxed: false)
|
||||
@ -102,17 +101,16 @@ extension Api {
|
||||
item.serialize(buffer, true)
|
||||
}}
|
||||
if Int(flags) & Int(1 << 6) != 0 {serializeInt32(pinnedMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 7) != 0 {defaultBannedRights!.serialize(buffer, true)}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .channelFull(let flags, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId, let defaultBannedRights):
|
||||
return ("channelFull", [("flags", flags), ("id", id), ("about", about), ("participantsCount", participantsCount), ("adminsCount", adminsCount), ("kickedCount", kickedCount), ("bannedCount", bannedCount), ("onlineCount", onlineCount), ("readInboxMaxId", readInboxMaxId), ("readOutboxMaxId", readOutboxMaxId), ("unreadCount", unreadCount), ("chatPhoto", chatPhoto), ("notifySettings", notifySettings), ("exportedInvite", exportedInvite), ("botInfo", botInfo), ("migratedFromChatId", migratedFromChatId), ("migratedFromMaxId", migratedFromMaxId), ("pinnedMsgId", pinnedMsgId), ("stickerset", stickerset), ("availableMinId", availableMinId), ("defaultBannedRights", defaultBannedRights)])
|
||||
case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId, let defaultBannedRights):
|
||||
return ("chatFull", [("flags", flags), ("id", id), ("about", about), ("participants", participants), ("chatPhoto", chatPhoto), ("notifySettings", notifySettings), ("exportedInvite", exportedInvite), ("botInfo", botInfo), ("pinnedMsgId", pinnedMsgId), ("defaultBannedRights", defaultBannedRights)])
|
||||
case .channelFull(let flags, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId):
|
||||
return ("channelFull", [("flags", flags), ("id", id), ("about", about), ("participantsCount", participantsCount), ("adminsCount", adminsCount), ("kickedCount", kickedCount), ("bannedCount", bannedCount), ("onlineCount", onlineCount), ("readInboxMaxId", readInboxMaxId), ("readOutboxMaxId", readOutboxMaxId), ("unreadCount", unreadCount), ("chatPhoto", chatPhoto), ("notifySettings", notifySettings), ("exportedInvite", exportedInvite), ("botInfo", botInfo), ("migratedFromChatId", migratedFromChatId), ("migratedFromMaxId", migratedFromMaxId), ("pinnedMsgId", pinnedMsgId), ("stickerset", stickerset), ("availableMinId", availableMinId)])
|
||||
case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId):
|
||||
return ("chatFull", [("flags", flags), ("id", id), ("about", about), ("participants", participants), ("chatPhoto", chatPhoto), ("notifySettings", notifySettings), ("exportedInvite", exportedInvite), ("botInfo", botInfo), ("pinnedMsgId", pinnedMsgId)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,10 +165,6 @@ extension Api {
|
||||
} }
|
||||
var _20: Int32?
|
||||
if Int(_1!) & Int(1 << 9) != 0 {_20 = reader.readInt32() }
|
||||
var _21: Api.ChatBannedRights?
|
||||
if Int(_1!) & Int(1 << 14) != 0 {if let signature = reader.readInt32() {
|
||||
_21 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
@ -191,9 +185,8 @@ extension Api {
|
||||
let _c18 = (Int(_1!) & Int(1 << 5) == 0) || _18 != nil
|
||||
let _c19 = (Int(_1!) & Int(1 << 8) == 0) || _19 != nil
|
||||
let _c20 = (Int(_1!) & Int(1 << 9) == 0) || _20 != nil
|
||||
let _c21 = (Int(_1!) & Int(1 << 14) == 0) || _21 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 && _c21 {
|
||||
return Api.ChatFull.channelFull(flags: _1!, id: _2!, about: _3!, participantsCount: _4, adminsCount: _5, kickedCount: _6, bannedCount: _7, onlineCount: _8, readInboxMaxId: _9!, readOutboxMaxId: _10!, unreadCount: _11!, chatPhoto: _12!, notifySettings: _13!, exportedInvite: _14!, botInfo: _15!, migratedFromChatId: _16, migratedFromMaxId: _17, pinnedMsgId: _18, stickerset: _19, availableMinId: _20, defaultBannedRights: _21)
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 {
|
||||
return Api.ChatFull.channelFull(flags: _1!, id: _2!, about: _3!, participantsCount: _4, adminsCount: _5, kickedCount: _6, bannedCount: _7, onlineCount: _8, readInboxMaxId: _9!, readOutboxMaxId: _10!, unreadCount: _11!, chatPhoto: _12!, notifySettings: _13!, exportedInvite: _14!, botInfo: _15!, migratedFromChatId: _16, migratedFromMaxId: _17, pinnedMsgId: _18, stickerset: _19, availableMinId: _20)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -228,10 +221,6 @@ extension Api {
|
||||
} }
|
||||
var _9: Int32?
|
||||
if Int(_1!) & Int(1 << 6) != 0 {_9 = reader.readInt32() }
|
||||
var _10: Api.ChatBannedRights?
|
||||
if Int(_1!) & Int(1 << 7) != 0 {if let signature = reader.readInt32() {
|
||||
_10 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
@ -241,9 +230,8 @@ extension Api {
|
||||
let _c7 = _7 != nil
|
||||
let _c8 = (Int(_1!) & Int(1 << 3) == 0) || _8 != nil
|
||||
let _c9 = (Int(_1!) & Int(1 << 6) == 0) || _9 != nil
|
||||
let _c10 = (Int(_1!) & Int(1 << 7) == 0) || _10 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 {
|
||||
return Api.ChatFull.chatFull(flags: _1!, id: _2!, about: _3!, participants: _4!, chatPhoto: _5, notifySettings: _6!, exportedInvite: _7!, botInfo: _8, pinnedMsgId: _9, defaultBannedRights: _10)
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
|
||||
return Api.ChatFull.chatFull(flags: _1!, id: _2!, about: _3!, participants: _4!, chatPhoto: _5, notifySettings: _6!, exportedInvite: _7!, botInfo: _8, pinnedMsgId: _9)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -1395,8 +1383,8 @@ extension Api {
|
||||
case chatEmpty(id: Int32)
|
||||
case chatForbidden(id: Int32, title: String)
|
||||
case channelForbidden(flags: Int32, id: Int32, accessHash: Int64, title: String, untilDate: Int32?)
|
||||
case chat(flags: Int32, id: Int32, title: String, photo: Api.ChatPhoto, participantsCount: Int32, date: Int32, version: Int32, migratedTo: Api.InputChannel?, adminRights: Api.ChatAdminRights?, bannedRights: Api.ChatBannedRights?)
|
||||
case channel(flags: Int32, id: Int32, accessHash: Int64?, title: String, username: String?, photo: Api.ChatPhoto, date: Int32, version: Int32, restrictionReason: String?, adminRights: Api.ChatAdminRights?, bannedRights: Api.ChatBannedRights?, participantsCount: Int32?)
|
||||
case chat(flags: Int32, id: Int32, title: String, photo: Api.ChatPhoto, participantsCount: Int32, date: Int32, version: Int32, migratedTo: Api.InputChannel?, adminRights: Api.ChatAdminRights?, defaultBannedRights: Api.ChatBannedRights?)
|
||||
case channel(flags: Int32, id: Int32, accessHash: Int64?, title: String, username: String?, photo: Api.ChatPhoto, date: Int32, version: Int32, restrictionReason: String?, adminRights: Api.ChatAdminRights?, bannedRights: Api.ChatBannedRights?, defaultBannedRights: Api.ChatBannedRights?, participantsCount: Int32?)
|
||||
|
||||
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -1423,9 +1411,9 @@ extension Api {
|
||||
serializeString(title, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 16) != 0 {serializeInt32(untilDate!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .chat(let flags, let id, let title, let photo, let participantsCount, let date, let version, let migratedTo, let adminRights, let bannedRights):
|
||||
case .chat(let flags, let id, let title, let photo, let participantsCount, let date, let version, let migratedTo, let adminRights, let defaultBannedRights):
|
||||
if boxed {
|
||||
buffer.appendInt32(17100984)
|
||||
buffer.appendInt32(1004149726)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(id, buffer: buffer, boxed: false)
|
||||
@ -1436,11 +1424,11 @@ extension Api {
|
||||
serializeInt32(version, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 6) != 0 {migratedTo!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 14) != 0 {adminRights!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 15) != 0 {bannedRights!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 18) != 0 {defaultBannedRights!.serialize(buffer, true)}
|
||||
break
|
||||
case .channel(let flags, let id, let accessHash, let title, let username, let photo, let date, let version, let restrictionReason, let adminRights, let bannedRights, let participantsCount):
|
||||
case .channel(let flags, let id, let accessHash, let title, let username, let photo, let date, let version, let restrictionReason, let adminRights, let bannedRights, let defaultBannedRights, let participantsCount):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1197714950)
|
||||
buffer.appendInt32(1307772980)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(id, buffer: buffer, boxed: false)
|
||||
@ -1453,6 +1441,7 @@ extension Api {
|
||||
if Int(flags) & Int(1 << 9) != 0 {serializeString(restrictionReason!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 14) != 0 {adminRights!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 15) != 0 {bannedRights!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 18) != 0 {defaultBannedRights!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 17) != 0 {serializeInt32(participantsCount!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
}
|
||||
@ -1466,10 +1455,10 @@ extension Api {
|
||||
return ("chatForbidden", [("id", id), ("title", title)])
|
||||
case .channelForbidden(let flags, let id, let accessHash, let title, let untilDate):
|
||||
return ("channelForbidden", [("flags", flags), ("id", id), ("accessHash", accessHash), ("title", title), ("untilDate", untilDate)])
|
||||
case .chat(let flags, let id, let title, let photo, let participantsCount, let date, let version, let migratedTo, let adminRights, let bannedRights):
|
||||
return ("chat", [("flags", flags), ("id", id), ("title", title), ("photo", photo), ("participantsCount", participantsCount), ("date", date), ("version", version), ("migratedTo", migratedTo), ("adminRights", adminRights), ("bannedRights", bannedRights)])
|
||||
case .channel(let flags, let id, let accessHash, let title, let username, let photo, let date, let version, let restrictionReason, let adminRights, let bannedRights, let participantsCount):
|
||||
return ("channel", [("flags", flags), ("id", id), ("accessHash", accessHash), ("title", title), ("username", username), ("photo", photo), ("date", date), ("version", version), ("restrictionReason", restrictionReason), ("adminRights", adminRights), ("bannedRights", bannedRights), ("participantsCount", participantsCount)])
|
||||
case .chat(let flags, let id, let title, let photo, let participantsCount, let date, let version, let migratedTo, let adminRights, let defaultBannedRights):
|
||||
return ("chat", [("flags", flags), ("id", id), ("title", title), ("photo", photo), ("participantsCount", participantsCount), ("date", date), ("version", version), ("migratedTo", migratedTo), ("adminRights", adminRights), ("defaultBannedRights", defaultBannedRights)])
|
||||
case .channel(let flags, let id, let accessHash, let title, let username, let photo, let date, let version, let restrictionReason, let adminRights, let bannedRights, let defaultBannedRights, let participantsCount):
|
||||
return ("channel", [("flags", flags), ("id", id), ("accessHash", accessHash), ("title", title), ("username", username), ("photo", photo), ("date", date), ("version", version), ("restrictionReason", restrictionReason), ("adminRights", adminRights), ("bannedRights", bannedRights), ("defaultBannedRights", defaultBannedRights), ("participantsCount", participantsCount)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -1547,7 +1536,7 @@ extension Api {
|
||||
_9 = Api.parse(reader, signature: signature) as? Api.ChatAdminRights
|
||||
} }
|
||||
var _10: Api.ChatBannedRights?
|
||||
if Int(_1!) & Int(1 << 15) != 0 {if let signature = reader.readInt32() {
|
||||
if Int(_1!) & Int(1 << 18) != 0 {if let signature = reader.readInt32() {
|
||||
_10 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
@ -1559,9 +1548,9 @@ extension Api {
|
||||
let _c7 = _7 != nil
|
||||
let _c8 = (Int(_1!) & Int(1 << 6) == 0) || _8 != nil
|
||||
let _c9 = (Int(_1!) & Int(1 << 14) == 0) || _9 != nil
|
||||
let _c10 = (Int(_1!) & Int(1 << 15) == 0) || _10 != nil
|
||||
let _c10 = (Int(_1!) & Int(1 << 18) == 0) || _10 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 {
|
||||
return Api.Chat.chat(flags: _1!, id: _2!, title: _3!, photo: _4!, participantsCount: _5!, date: _6!, version: _7!, migratedTo: _8, adminRights: _9, bannedRights: _10)
|
||||
return Api.Chat.chat(flags: _1!, id: _2!, title: _3!, photo: _4!, participantsCount: _5!, date: _6!, version: _7!, migratedTo: _8, adminRights: _9, defaultBannedRights: _10)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -1596,8 +1585,12 @@ extension Api {
|
||||
if Int(_1!) & Int(1 << 15) != 0 {if let signature = reader.readInt32() {
|
||||
_11 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights
|
||||
} }
|
||||
var _12: Int32?
|
||||
if Int(_1!) & Int(1 << 17) != 0 {_12 = reader.readInt32() }
|
||||
var _12: Api.ChatBannedRights?
|
||||
if Int(_1!) & Int(1 << 18) != 0 {if let signature = reader.readInt32() {
|
||||
_12 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights
|
||||
} }
|
||||
var _13: Int32?
|
||||
if Int(_1!) & Int(1 << 17) != 0 {_13 = reader.readInt32() }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 13) == 0) || _3 != nil
|
||||
@ -1609,9 +1602,10 @@ extension Api {
|
||||
let _c9 = (Int(_1!) & Int(1 << 9) == 0) || _9 != nil
|
||||
let _c10 = (Int(_1!) & Int(1 << 14) == 0) || _10 != nil
|
||||
let _c11 = (Int(_1!) & Int(1 << 15) == 0) || _11 != nil
|
||||
let _c12 = (Int(_1!) & Int(1 << 17) == 0) || _12 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 {
|
||||
return Api.Chat.channel(flags: _1!, id: _2!, accessHash: _3, title: _4!, username: _5, photo: _6!, date: _7!, version: _8!, restrictionReason: _9, adminRights: _10, bannedRights: _11, participantsCount: _12)
|
||||
let _c12 = (Int(_1!) & Int(1 << 18) == 0) || _12 != nil
|
||||
let _c13 = (Int(_1!) & Int(1 << 17) == 0) || _13 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 {
|
||||
return Api.Chat.channel(flags: _1!, id: _2!, accessHash: _3, title: _4!, username: _5, photo: _6!, date: _7!, version: _8!, restrictionReason: _9, adminRights: _10, bannedRights: _11, defaultBannedRights: _12, participantsCount: _13)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -3546,7 +3540,6 @@ extension Api {
|
||||
case updateReadChannelInbox(channelId: Int32, maxId: Int32)
|
||||
case updateDeleteChannelMessages(channelId: Int32, messages: [Int32], pts: Int32, ptsCount: Int32)
|
||||
case updateChannelMessageViews(channelId: Int32, id: Int32, views: Int32)
|
||||
case updateChatAdmins(chatId: Int32, enabled: Api.Bool, version: Int32)
|
||||
case updateChatParticipantAdmin(chatId: Int32, userId: Int32, isAdmin: Api.Bool, version: Int32)
|
||||
case updateNewStickerSet(stickerset: Api.messages.StickerSet)
|
||||
case updateStickerSetsOrder(flags: Int32, order: [Int64])
|
||||
@ -3583,6 +3576,7 @@ extension Api {
|
||||
case updateUserPinnedMessage(userId: Int32, id: Int32)
|
||||
case updateChatPinnedMessage(chatId: Int32, id: Int32)
|
||||
case updateMessagePoll(flags: Int32, pollId: Int64, poll: Api.Poll?, results: Api.PollResults)
|
||||
case updateChatDefaultBannedRights(peer: Api.Peer, defaultBannedRights: Api.ChatBannedRights, version: Int32)
|
||||
|
||||
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -3858,14 +3852,6 @@ extension Api {
|
||||
serializeInt32(id, buffer: buffer, boxed: false)
|
||||
serializeInt32(views, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .updateChatAdmins(let chatId, let enabled, let version):
|
||||
if boxed {
|
||||
buffer.appendInt32(1855224129)
|
||||
}
|
||||
serializeInt32(chatId, buffer: buffer, boxed: false)
|
||||
enabled.serialize(buffer, true)
|
||||
serializeInt32(version, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .updateChatParticipantAdmin(let chatId, let userId, let isAdmin, let version):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1232070311)
|
||||
@ -4153,6 +4139,14 @@ extension Api {
|
||||
if Int(flags) & Int(1 << 0) != 0 {poll!.serialize(buffer, true)}
|
||||
results.serialize(buffer, true)
|
||||
break
|
||||
case .updateChatDefaultBannedRights(let peer, let defaultBannedRights, let version):
|
||||
if boxed {
|
||||
buffer.appendInt32(1421875280)
|
||||
}
|
||||
peer.serialize(buffer, true)
|
||||
defaultBannedRights.serialize(buffer, true)
|
||||
serializeInt32(version, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -4222,8 +4216,6 @@ extension Api {
|
||||
return ("updateDeleteChannelMessages", [("channelId", channelId), ("messages", messages), ("pts", pts), ("ptsCount", ptsCount)])
|
||||
case .updateChannelMessageViews(let channelId, let id, let views):
|
||||
return ("updateChannelMessageViews", [("channelId", channelId), ("id", id), ("views", views)])
|
||||
case .updateChatAdmins(let chatId, let enabled, let version):
|
||||
return ("updateChatAdmins", [("chatId", chatId), ("enabled", enabled), ("version", version)])
|
||||
case .updateChatParticipantAdmin(let chatId, let userId, let isAdmin, let version):
|
||||
return ("updateChatParticipantAdmin", [("chatId", chatId), ("userId", userId), ("isAdmin", isAdmin), ("version", version)])
|
||||
case .updateNewStickerSet(let stickerset):
|
||||
@ -4296,6 +4288,8 @@ extension Api {
|
||||
return ("updateChatPinnedMessage", [("chatId", chatId), ("id", id)])
|
||||
case .updateMessagePoll(let flags, let pollId, let poll, let results):
|
||||
return ("updateMessagePoll", [("flags", flags), ("pollId", pollId), ("poll", poll), ("results", results)])
|
||||
case .updateChatDefaultBannedRights(let peer, let defaultBannedRights, let version):
|
||||
return ("updateChatDefaultBannedRights", [("peer", peer), ("defaultBannedRights", defaultBannedRights), ("version", version)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -4871,25 +4865,6 @@ extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
static func parse_updateChatAdmins(_ 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
|
||||
}
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.Update.updateChatAdmins(chatId: _1!, enabled: _2!, version: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
static func parse_updateChatParticipantAdmin(_ reader: BufferReader) -> Update? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
@ -5449,6 +5424,27 @@ extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
static func parse_updateChatDefaultBannedRights(_ reader: BufferReader) -> Update? {
|
||||
var _1: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
var _2: Api.ChatBannedRights?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights
|
||||
}
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.Update.updateChatDefaultBannedRights(peer: _1!, defaultBannedRights: _2!, version: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
enum PopularContact: TypeConstructorDescription {
|
||||
|
||||
@ -21,7 +21,7 @@ func imageRepresentationsForApiChatPhoto(_ photo: Api.ChatPhoto) -> [TelegramMed
|
||||
|
||||
func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
switch chat {
|
||||
case let .chat(flags, id, title, photo, participantsCount, date, version, migratedTo, adminRights, bannedRights):
|
||||
case let .chat(flags, id, title, photo, participantsCount, date, version, migratedTo, adminRights, defaultBannedRights):
|
||||
let left = (flags & ((1 << 1) | (1 << 2))) != 0
|
||||
var migrationReference: TelegramGroupToChannelMigrationReference?
|
||||
if let migratedTo = migratedTo {
|
||||
@ -36,21 +36,18 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
var role: TelegramGroupRole = .member
|
||||
if (flags & (1 << 0)) != 0 {
|
||||
role = .creator
|
||||
} else if (flags & (1 << 4)) != 0 {
|
||||
role = .admin
|
||||
}
|
||||
if (flags & (1 << 3)) != 0 {
|
||||
groupFlags.insert(.adminsEnabled)
|
||||
} else if adminRights != nil {
|
||||
//role = .admin
|
||||
}
|
||||
if (flags & (1 << 5)) != 0 {
|
||||
groupFlags.insert(.deactivated)
|
||||
}
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: title, photo: imageRepresentationsForApiChatPhoto(photo), participantCount: Int(participantsCount), role: role, membership: left ? .Left : .Member, flags: groupFlags, migrationReference: migrationReference, creationDate: date, version: Int(version))
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: title, photo: imageRepresentationsForApiChatPhoto(photo), participantCount: Int(participantsCount), role: role, membership: left ? .Left : .Member, flags: groupFlags, defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init(apiBannedRights:)), migrationReference: migrationReference, creationDate: date, version: Int(version))
|
||||
case let .chatEmpty(id):
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: "", photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], migrationReference: nil, creationDate: 0, version: 0)
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: "", photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0)
|
||||
case let .chatForbidden(id, title):
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: title, photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], migrationReference: nil, creationDate: 0, version: 0)
|
||||
case let .channel(flags, id, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, _/*feed*//*, feedId*/):
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: title, photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0)
|
||||
case let .channel(flags, id, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, defaultBannedRights, _/*feed*//*, feedId*/):
|
||||
let participationStatus: TelegramChannelParticipationStatus
|
||||
if (flags & Int32(1 << 1)) != 0 {
|
||||
participationStatus = .kicked
|
||||
@ -87,7 +84,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
restrictionInfo = nil
|
||||
}
|
||||
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: id), accessHash: accessHash, title: title, username: username, photo: imageRepresentationsForApiChatPhoto(photo), creationDate: date, version: version, participationStatus: participationStatus, info: info, flags: channelFlags, restrictionInfo: restrictionInfo, adminRights: adminRights.flatMap(TelegramChatAdminRights.init), bannedRights: bannedRights.flatMap(TelegramChatBannedRights.init), peerGroupId: /*feed*/nil/*feedId.flatMap { PeerGroupId(rawValue: $0) }*/)
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: id), accessHash: accessHash, title: title, username: username, photo: imageRepresentationsForApiChatPhoto(photo), creationDate: date, version: version, participationStatus: participationStatus, info: info, flags: channelFlags, restrictionInfo: restrictionInfo, adminRights: adminRights.flatMap(TelegramChatAdminRights.init), bannedRights: bannedRights.flatMap(TelegramChatBannedRights.init), defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init), peerGroupId: /*feed*/nil/*feedId.flatMap { PeerGroupId(rawValue: $0) }*/)
|
||||
case let .channelForbidden(flags, id, accessHash, title, untilDate):
|
||||
let info: TelegramChannelInfo
|
||||
if (flags & Int32(1 << 8)) != 0 {
|
||||
@ -96,7 +93,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
info = .broadcast(TelegramChannelBroadcastInfo(flags: []))
|
||||
}
|
||||
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: id), accessHash: accessHash, title: title, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .kicked, info: info, flags: TelegramChannelFlags(), restrictionInfo: nil, adminRights: nil, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], personal: true, untilDate: untilDate ?? Int32.max), peerGroupId: nil)
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: id), accessHash: accessHash, title: title, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .kicked, info: info, flags: TelegramChannelFlags(), restrictionInfo: nil, adminRights: nil, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: untilDate ?? Int32.max), defaultBannedRights: nil, peerGroupId: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +101,7 @@ func mergeGroupOrChannel(lhs: Peer?, rhs: Api.Chat) -> Peer? {
|
||||
switch rhs {
|
||||
case .chat, .chatEmpty, .chatForbidden, .channelForbidden:
|
||||
return parseTelegramGroupOrChannel(chat: rhs)
|
||||
case let .channel(flags, _, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, _/*feed*//*, feedId*/):
|
||||
case let .channel(flags, _, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, defaultBannedRights, _/*feed*//*, feedId*/):
|
||||
if accessHash != nil && (flags & (1 << 12)) == 0 {
|
||||
return parseTelegramGroupOrChannel(chat: rhs)
|
||||
} else if let lhs = lhs as? TelegramChannel {
|
||||
@ -122,7 +119,7 @@ func mergeGroupOrChannel(lhs: Peer?, rhs: Api.Chat) -> Peer? {
|
||||
let infoFlags = TelegramChannelGroupFlags()
|
||||
info = .group(TelegramChannelGroupInfo(flags: infoFlags))
|
||||
}
|
||||
return TelegramChannel(id: lhs.id, accessHash: lhs.accessHash, title: title, username: username, photo: imageRepresentationsForApiChatPhoto(photo), creationDate: lhs.creationDate, version: lhs.version, participationStatus: lhs.participationStatus, info: info, flags: channelFlags, restrictionInfo: lhs.restrictionInfo, adminRights: lhs.adminRights, bannedRights: lhs.bannedRights, peerGroupId: lhs.peerGroupId)
|
||||
return TelegramChannel(id: lhs.id, accessHash: lhs.accessHash, title: title, username: username, photo: imageRepresentationsForApiChatPhoto(photo), creationDate: lhs.creationDate, version: lhs.version, participationStatus: lhs.participationStatus, info: info, flags: channelFlags, restrictionInfo: lhs.restrictionInfo, adminRights: lhs.adminRights, bannedRights: lhs.bannedRights, defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init), peerGroupId: lhs.peerGroupId)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -136,7 +136,6 @@ public final class CachedChannelData: CachedPeerData {
|
||||
public let stickerPack: StickerPackCollectionInfo?
|
||||
public let minAvailableMessageId: MessageId?
|
||||
public let migrationReference: ChannelMigrationReference?
|
||||
public let defaultBannedRights: TelegramChatBannedRights?
|
||||
|
||||
public let peerIds: Set<PeerId>
|
||||
public let messageIds: Set<MessageId>
|
||||
@ -158,10 +157,9 @@ public final class CachedChannelData: CachedPeerData {
|
||||
self.stickerPack = nil
|
||||
self.minAvailableMessageId = nil
|
||||
self.migrationReference = nil
|
||||
self.defaultBannedRights = nil
|
||||
}
|
||||
|
||||
init(isNotAccessible: Bool, flags: CachedChannelFlags, about: String?, participantsSummary: CachedChannelParticipantsSummary, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], reportStatus: PeerReportStatus, pinnedMessageId: MessageId?, stickerPack: StickerPackCollectionInfo?, minAvailableMessageId: MessageId?, migrationReference: ChannelMigrationReference?, defaultBannedRights: TelegramChatBannedRights?) {
|
||||
init(isNotAccessible: Bool, flags: CachedChannelFlags, about: String?, participantsSummary: CachedChannelParticipantsSummary, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], reportStatus: PeerReportStatus, pinnedMessageId: MessageId?, stickerPack: StickerPackCollectionInfo?, minAvailableMessageId: MessageId?, migrationReference: ChannelMigrationReference?) {
|
||||
self.isNotAccessible = isNotAccessible
|
||||
self.flags = flags
|
||||
self.about = about
|
||||
@ -173,7 +171,6 @@ public final class CachedChannelData: CachedPeerData {
|
||||
self.stickerPack = stickerPack
|
||||
self.minAvailableMessageId = minAvailableMessageId
|
||||
self.migrationReference = migrationReference
|
||||
self.defaultBannedRights = defaultBannedRights
|
||||
|
||||
var peerIds = Set<PeerId>()
|
||||
for botInfo in botInfos {
|
||||
@ -189,51 +186,47 @@ public final class CachedChannelData: CachedPeerData {
|
||||
}
|
||||
|
||||
func withUpdatedIsNotAccessible(_ isNotAccessible: Bool) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference)
|
||||
}
|
||||
|
||||
func withUpdatedFlags(_ flags: CachedChannelFlags) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference)
|
||||
}
|
||||
|
||||
func withUpdatedAbout(_ about: String?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference)
|
||||
}
|
||||
|
||||
func withUpdatedParticipantsSummary(_ participantsSummary: CachedChannelParticipantsSummary) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference)
|
||||
}
|
||||
|
||||
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference)
|
||||
}
|
||||
|
||||
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference)
|
||||
}
|
||||
|
||||
func withUpdatedReportStatus(_ reportStatus: PeerReportStatus) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference)
|
||||
}
|
||||
|
||||
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference)
|
||||
}
|
||||
|
||||
func withUpdatedStickerPack(_ stickerPack: StickerPackCollectionInfo?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference)
|
||||
}
|
||||
|
||||
func withUpdatedMinAvailableMessageId(_ minAvailableMessageId: MessageId?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: minAvailableMessageId, migrationReference: self.migrationReference)
|
||||
}
|
||||
|
||||
func withUpdatedMigrationReference(_ migrationReference: ChannelMigrationReference?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: migrationReference, defaultBannedRights: self.defaultBannedRights)
|
||||
}
|
||||
|
||||
func withUpdatedDefaultBannedRights(_ defaultBannedRights: TelegramChatBannedRights?) -> CachedChannelData {
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, defaultBannedRights: defaultBannedRights)
|
||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: migrationReference)
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
@ -264,7 +257,6 @@ public final class CachedChannelData: CachedPeerData {
|
||||
}
|
||||
|
||||
self.migrationReference = decoder.decodeObjectForKey("mr", decoder: { ChannelMigrationReference(decoder: $0) }) as? ChannelMigrationReference
|
||||
self.defaultBannedRights = decoder.decodeObjectForKey("defbr", decoder: { TelegramChatBannedRights(decoder: $0) }) as? TelegramChatBannedRights
|
||||
|
||||
for botInfo in self.botInfos {
|
||||
peerIds.insert(botInfo.peerId)
|
||||
@ -323,11 +315,6 @@ public final class CachedChannelData: CachedPeerData {
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "mr")
|
||||
}
|
||||
if let defaultBannedRights = self.defaultBannedRights {
|
||||
encoder.encodeObject(defaultBannedRights, forKey: "defbr")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "defbr")
|
||||
}
|
||||
}
|
||||
|
||||
public func isEqual(to: CachedPeerData) -> Bool {
|
||||
@ -379,10 +366,6 @@ public final class CachedChannelData: CachedPeerData {
|
||||
return false
|
||||
}
|
||||
|
||||
if other.defaultBannedRights != self.defaultBannedRights {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,14 +29,28 @@ public final class CachedPeerBotInfo: PostboxCoding, Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct CachedGroupFlags: OptionSet {
|
||||
public var rawValue: Int32
|
||||
|
||||
public init() {
|
||||
self.rawValue = 0
|
||||
}
|
||||
|
||||
public init(rawValue: Int32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static let canChangeUsername = CachedGroupFlags(rawValue: 1 << 0)
|
||||
}
|
||||
|
||||
public final class CachedGroupData: CachedPeerData {
|
||||
public let participants: CachedGroupParticipants?
|
||||
public let exportedInvitation: ExportedInvitation?
|
||||
public let botInfos: [CachedPeerBotInfo]
|
||||
public let reportStatus: PeerReportStatus
|
||||
public let pinnedMessageId: MessageId?
|
||||
public let defaultBannedRights: TelegramChatBannedRights?
|
||||
public let about: String?
|
||||
public let flags: CachedGroupFlags
|
||||
|
||||
public let peerIds: Set<PeerId>
|
||||
public let messageIds: Set<MessageId>
|
||||
@ -50,17 +64,18 @@ public final class CachedGroupData: CachedPeerData {
|
||||
self.pinnedMessageId = nil
|
||||
self.messageIds = Set()
|
||||
self.peerIds = Set()
|
||||
self.defaultBannedRights = nil
|
||||
self.about = nil
|
||||
self.flags = CachedGroupFlags()
|
||||
}
|
||||
|
||||
public init(participants: CachedGroupParticipants?, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], reportStatus: PeerReportStatus, pinnedMessageId: MessageId?, defaultBannedRights: TelegramChatBannedRights?, about: String?) {
|
||||
public init(participants: CachedGroupParticipants?, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], reportStatus: PeerReportStatus, pinnedMessageId: MessageId?, about: String?, flags: CachedGroupFlags) {
|
||||
self.participants = participants
|
||||
self.exportedInvitation = exportedInvitation
|
||||
self.botInfos = botInfos
|
||||
self.reportStatus = reportStatus
|
||||
self.pinnedMessageId = pinnedMessageId
|
||||
self.defaultBannedRights = defaultBannedRights
|
||||
self.about = about
|
||||
self.flags = flags
|
||||
|
||||
var messageIds = Set<MessageId>()
|
||||
if let pinnedMessageId = self.pinnedMessageId {
|
||||
@ -78,7 +93,6 @@ public final class CachedGroupData: CachedPeerData {
|
||||
peerIds.insert(botInfo.peerId)
|
||||
}
|
||||
self.peerIds = peerIds
|
||||
self.about = about
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
@ -92,8 +106,8 @@ public final class CachedGroupData: CachedPeerData {
|
||||
} else {
|
||||
self.pinnedMessageId = nil
|
||||
}
|
||||
self.defaultBannedRights = decoder.decodeObjectForKey("defbr", decoder: { TelegramChatBannedRights(decoder: $0) }) as? TelegramChatBannedRights
|
||||
self.about = decoder.decodeOptionalStringForKey("ab")
|
||||
self.flags = CachedGroupFlags(rawValue: decoder.decodeInt32ForKey("fl", orElse: 0))
|
||||
|
||||
var messageIds = Set<MessageId>()
|
||||
if let pinnedMessageId = self.pinnedMessageId {
|
||||
@ -136,16 +150,12 @@ public final class CachedGroupData: CachedPeerData {
|
||||
encoder.encodeNil(forKey: "pm.n")
|
||||
encoder.encodeNil(forKey: "pm.i")
|
||||
}
|
||||
if let defaultBannedRights = self.defaultBannedRights {
|
||||
encoder.encodeObject(defaultBannedRights, forKey: "defbr")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "defbr")
|
||||
}
|
||||
if let about = self.about {
|
||||
encoder.encodeString(about, forKey: "ab")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "ab")
|
||||
}
|
||||
encoder.encodeInt32(self.flags.rawValue, forKey: "fl")
|
||||
}
|
||||
|
||||
public func isEqual(to: CachedPeerData) -> Bool {
|
||||
@ -153,34 +163,34 @@ public final class CachedGroupData: CachedPeerData {
|
||||
return false
|
||||
}
|
||||
|
||||
return self.participants == other.participants && self.exportedInvitation == other.exportedInvitation && self.botInfos == other.botInfos && self.reportStatus == other.reportStatus && self.pinnedMessageId == other.pinnedMessageId && self.defaultBannedRights == other.defaultBannedRights && self.about == other.about
|
||||
return self.participants == other.participants && self.exportedInvitation == other.exportedInvitation && self.botInfos == other.botInfos && self.reportStatus == other.reportStatus && self.pinnedMessageId == other.pinnedMessageId && self.about == other.about && self.flags == other.flags
|
||||
}
|
||||
|
||||
func withUpdatedParticipants(_ participants: CachedGroupParticipants?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: self.about)
|
||||
return CachedGroupData(participants: participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: self.about)
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: self.about)
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedReportStatus(_ reportStatus: PeerReportStatus) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: self.about)
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: reportStatus, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: self.about)
|
||||
}
|
||||
|
||||
func withUpdatedDefaultBannedRights(_ defaultBannedRights: TelegramChatBannedRights?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: defaultBannedRights, about: self.about)
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: pinnedMessageId, about: self.about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedAbout(_ about: String?) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, defaultBannedRights: self.defaultBannedRights, about: about)
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, about: about, flags: self.flags)
|
||||
}
|
||||
|
||||
func withUpdatedFlags(_ flags: CachedGroupFlags) -> CachedGroupData {
|
||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, reportStatus: self.reportStatus, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: flags)
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,15 +264,18 @@ public func updateDefaultChannelMemberBannedRights(account: Account, peerId: Pee
|
||||
|> mapToSignal { result -> Signal<Never, NoError> in
|
||||
account.stateManager.addUpdates(result)
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, cachedData -> CachedPeerData? in
|
||||
if let cachedData = cachedData as? CachedChannelData {
|
||||
return cachedData.withUpdatedDefaultBannedRights(rights)
|
||||
} else if let cachedData = cachedData as? CachedGroupData {
|
||||
return cachedData.withUpdatedDefaultBannedRights(rights)
|
||||
} else {
|
||||
return cachedData
|
||||
}
|
||||
})
|
||||
guard let peer = transaction.getPeer(peerId) else {
|
||||
return
|
||||
}
|
||||
if let peer = peer as? TelegramGroup {
|
||||
updatePeers(transaction: transaction, peers: [peer.updateDefaultBannedRights(rights, version: peer.version)], update: { _, updated in
|
||||
return updated
|
||||
})
|
||||
} else if let peer = peer as? TelegramChannel {
|
||||
updatePeers(transaction: transaction, peers: [peer.withUpdatedDefaultBannedRights(rights)], update: { _, updated in
|
||||
return updated
|
||||
})
|
||||
}
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ import Foundation
|
||||
|
||||
public func removePeerMember(account: Account, peerId: PeerId, memberId: PeerId) -> Signal<Void, NoError> {
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
return updateChannelMemberBannedRights(account: account, peerId: peerId, memberId: memberId, rights: TelegramChatBannedRights(flags: [.banReadMessages], personal: false, untilDate: 0))
|
||||
return updateChannelMemberBannedRights(account: account, peerId: peerId, memberId: memberId, rights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: 0))
|
||||
|> mapToSignal { _ -> Signal<Void, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|
||||
@ -48,8 +48,8 @@ public func searchPeers(account: Account, query: String) -> Signal<([FoundPeer],
|
||||
peers[groupOrChannel.id] = groupOrChannel
|
||||
switch chat {
|
||||
/*feed*/
|
||||
case let .channel(_, _, _, _, _, _, _, _, _, _, _, participantsCount/*, _*/):
|
||||
if let participantsCount = participantsCount {
|
||||
case let .channel(channel):
|
||||
if let participantsCount = channel.participantsCount {
|
||||
subscribers[groupOrChannel.id] = participantsCount
|
||||
}
|
||||
default:
|
||||
|
||||
@ -158,6 +158,7 @@ public final class TelegramChannel: Peer {
|
||||
public let restrictionInfo: PeerAccessRestrictionInfo?
|
||||
public let adminRights: TelegramChatAdminRights?
|
||||
public let bannedRights: TelegramChatBannedRights?
|
||||
public let defaultBannedRights: TelegramChatBannedRights?
|
||||
public let peerGroupId: PeerGroupId?
|
||||
|
||||
public var indexName: PeerIndexNameRepresentation {
|
||||
@ -167,7 +168,7 @@ public final class TelegramChannel: Peer {
|
||||
public let associatedPeerId: PeerId? = nil
|
||||
public let notificationSettingsPeerId: PeerId? = nil
|
||||
|
||||
public init(id: PeerId, accessHash: Int64?, title: String, username: String?, photo: [TelegramMediaImageRepresentation], creationDate: Int32, version: Int32, participationStatus: TelegramChannelParticipationStatus, info: TelegramChannelInfo, flags: TelegramChannelFlags, restrictionInfo: PeerAccessRestrictionInfo?, adminRights: TelegramChatAdminRights?, bannedRights: TelegramChatBannedRights?, peerGroupId: PeerGroupId?) {
|
||||
public init(id: PeerId, accessHash: Int64?, title: String, username: String?, photo: [TelegramMediaImageRepresentation], creationDate: Int32, version: Int32, participationStatus: TelegramChannelParticipationStatus, info: TelegramChannelInfo, flags: TelegramChannelFlags, restrictionInfo: PeerAccessRestrictionInfo?, adminRights: TelegramChatAdminRights?, bannedRights: TelegramChatBannedRights?, defaultBannedRights: TelegramChatBannedRights?, peerGroupId: PeerGroupId?) {
|
||||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
self.title = title
|
||||
@ -181,6 +182,7 @@ public final class TelegramChannel: Peer {
|
||||
self.restrictionInfo = restrictionInfo
|
||||
self.adminRights = adminRights
|
||||
self.bannedRights = bannedRights
|
||||
self.defaultBannedRights = defaultBannedRights
|
||||
self.peerGroupId = peerGroupId
|
||||
}
|
||||
|
||||
@ -198,6 +200,7 @@ public final class TelegramChannel: Peer {
|
||||
self.restrictionInfo = decoder.decodeObjectForKey("ri") as? PeerAccessRestrictionInfo
|
||||
self.adminRights = decoder.decodeObjectForKey("ar", decoder: { TelegramChatAdminRights(decoder: $0) }) as? TelegramChatAdminRights
|
||||
self.bannedRights = decoder.decodeObjectForKey("br", decoder: { TelegramChatBannedRights(decoder: $0) }) as? TelegramChatBannedRights
|
||||
self.defaultBannedRights = decoder.decodeObjectForKey("dbr", decoder: { TelegramChatBannedRights(decoder: $0) }) as? TelegramChatBannedRights
|
||||
if let value = decoder.decodeOptionalInt32ForKey("pgi") {
|
||||
self.peerGroupId = PeerGroupId(rawValue: value)
|
||||
} else {
|
||||
@ -239,6 +242,11 @@ public final class TelegramChannel: Peer {
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "br")
|
||||
}
|
||||
if let defaultBannedRights = self.defaultBannedRights {
|
||||
encoder.encodeObject(defaultBannedRights, forKey: "dbr")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "dbr")
|
||||
}
|
||||
if let peerGroupId = self.peerGroupId {
|
||||
encoder.encodeInt32(peerGroupId.rawValue, forKey: "pgi")
|
||||
} else {
|
||||
@ -271,6 +279,10 @@ public final class TelegramChannel: Peer {
|
||||
return false
|
||||
}
|
||||
|
||||
if self.defaultBannedRights != other.defaultBannedRights {
|
||||
return false
|
||||
}
|
||||
|
||||
if self.peerGroupId != other.peerGroupId {
|
||||
return false
|
||||
}
|
||||
@ -279,7 +291,11 @@ public final class TelegramChannel: Peer {
|
||||
}
|
||||
|
||||
func withUpdatedAddressName(_ addressName: String?) -> TelegramChannel {
|
||||
return TelegramChannel(id: self.id, accessHash: self.accessHash, title: self.title, username: addressName, photo: self.photo, creationDate: self.creationDate, version: self.version, participationStatus: self.participationStatus, info: self.info, flags: self.flags, restrictionInfo: self.restrictionInfo, adminRights: self.adminRights, bannedRights: self.bannedRights, peerGroupId: self.peerGroupId)
|
||||
return TelegramChannel(id: self.id, accessHash: self.accessHash, title: self.title, username: addressName, photo: self.photo, creationDate: self.creationDate, version: self.version, participationStatus: self.participationStatus, info: self.info, flags: self.flags, restrictionInfo: self.restrictionInfo, adminRights: self.adminRights, bannedRights: self.bannedRights, defaultBannedRights: self.defaultBannedRights, peerGroupId: self.peerGroupId)
|
||||
}
|
||||
|
||||
func withUpdatedDefaultBannedRights(_ defaultBannedRights: TelegramChatBannedRights?) -> TelegramChannel {
|
||||
return TelegramChannel(id: self.id, accessHash: self.accessHash, title: self.title, username: self.addressName, photo: self.photo, creationDate: self.creationDate, version: self.version, participationStatus: self.participationStatus, info: self.info, flags: self.flags, restrictionInfo: self.restrictionInfo, adminRights: self.adminRights, bannedRights: self.bannedRights, defaultBannedRights: defaultBannedRights, peerGroupId: self.peerGroupId)
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,8 +328,11 @@ public extension TelegramChannel {
|
||||
if let adminRights = self.adminRights, adminRights.flags.contains(.canPostMessages) {
|
||||
return true
|
||||
}
|
||||
if let bannedRights = self.bannedRights, !bannedRights.flags.contains(.banSendMessages) {
|
||||
return true
|
||||
if let bannedRights = self.bannedRights, bannedRights.flags.contains(.banSendMessages) {
|
||||
return false
|
||||
}
|
||||
if let defaultBannedRights = self.defaultBannedRights, defaultBannedRights.flags.contains(.banSendMessages) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -328,8 +347,11 @@ public extension TelegramChannel {
|
||||
if let adminRights = self.adminRights, adminRights.flags.contains(.canPinMessages) {
|
||||
return true
|
||||
}
|
||||
if let bannedRights = self.bannedRights, !bannedRights.flags.contains(.banPinMessages) {
|
||||
return true
|
||||
if let bannedRights = self.bannedRights, bannedRights.flags.contains(.banPinMessages) {
|
||||
return false
|
||||
}
|
||||
if let defaultBannedRights = self.defaultBannedRights, defaultBannedRights.flags.contains(.banPinMessages) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -344,8 +366,11 @@ public extension TelegramChannel {
|
||||
if let adminRights = self.adminRights, adminRights.flags.contains(.canInviteUsers) {
|
||||
return true
|
||||
}
|
||||
if let bannedRights = self.bannedRights, !bannedRights.flags.contains(.banAddMembers) {
|
||||
return true
|
||||
if let bannedRights = self.bannedRights, bannedRights.flags.contains(.banAddMembers) {
|
||||
return false
|
||||
}
|
||||
if let defaultBannedRights = self.defaultBannedRights, defaultBannedRights.flags.contains(.banAddMembers) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -375,8 +400,11 @@ public extension TelegramChannel {
|
||||
if let adminRights = self.adminRights, adminRights.flags.contains(.canChangeInfo) {
|
||||
return true
|
||||
}
|
||||
if let bannedRights = self.bannedRights, !bannedRights.flags.contains(.banChangeInfo) {
|
||||
return true
|
||||
if let bannedRights = self.bannedRights, bannedRights.flags.contains(.banChangeInfo) {
|
||||
return false
|
||||
}
|
||||
if let defaultBannedRights = self.defaultBannedRights, defaultBannedRights.flags.contains(.banChangeInfo) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -392,4 +420,14 @@ public extension TelegramChannel {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
public func hasBannedPermission(_ rights: TelegramChatBannedRightsFlags) -> (Int32, Bool)? {
|
||||
if let defaultBannedRights = self.defaultBannedRights, defaultBannedRights.flags.contains(rights) {
|
||||
return (Int32.max, false)
|
||||
}
|
||||
if let bannedRights = self.bannedRights, bannedRights.flags.contains(rights) {
|
||||
return (bannedRights.untilDate, true)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,29 +32,25 @@ public struct TelegramChatBannedRightsFlags: OptionSet {
|
||||
|
||||
public struct TelegramChatBannedRights: PostboxCoding, Equatable {
|
||||
public let flags: TelegramChatBannedRightsFlags
|
||||
public let personal: Bool
|
||||
public let untilDate: Int32
|
||||
|
||||
public init(flags: TelegramChatBannedRightsFlags, personal: Bool, untilDate: Int32) {
|
||||
public init(flags: TelegramChatBannedRightsFlags, untilDate: Int32) {
|
||||
self.flags = flags
|
||||
self.personal = personal
|
||||
self.untilDate = untilDate
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.flags = TelegramChatBannedRightsFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0))
|
||||
self.personal = decoder.decodeInt32ForKey("per", orElse: 0) != 0
|
||||
self.untilDate = decoder.decodeInt32ForKey("d", orElse: 0)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt32(self.flags.rawValue, forKey: "f")
|
||||
encoder.encodeInt32(self.personal ? 1 : 0, forKey: "per")
|
||||
encoder.encodeInt32(self.untilDate, forKey: "d")
|
||||
}
|
||||
|
||||
public static func ==(lhs: TelegramChatBannedRights, rhs: TelegramChatBannedRights) -> Bool {
|
||||
return lhs.flags == rhs.flags && lhs.personal == rhs.personal && lhs.untilDate == rhs.untilDate
|
||||
return lhs.flags == rhs.flags && lhs.untilDate == rhs.untilDate
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +58,7 @@ extension TelegramChatBannedRights {
|
||||
init(apiBannedRights: Api.ChatBannedRights) {
|
||||
switch apiBannedRights {
|
||||
case let .chatBannedRights(flags, untilDate):
|
||||
self.init(flags: TelegramChatBannedRightsFlags(rawValue: flags), personal: (flags & 1 << 30) != 0, untilDate: untilDate)
|
||||
self.init(flags: TelegramChatBannedRightsFlags(rawValue: flags), untilDate: untilDate)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,10 +5,36 @@ import Foundation
|
||||
import Postbox
|
||||
#endif
|
||||
|
||||
public enum TelegramGroupRole: Int32 {
|
||||
public enum TelegramGroupRole: Equatable, PostboxCoding {
|
||||
case creator
|
||||
case admin
|
||||
case admin(TelegramChatAdminRights)
|
||||
case member
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
switch decoder.decodeInt32ForKey("_v", orElse: 0) {
|
||||
case 0:
|
||||
self = .creator
|
||||
case 1:
|
||||
self = .admin(decoder.decodeObjectForKey("r", decoder: { TelegramChatAdminRights(decoder: $0) }) as! TelegramChatAdminRights)
|
||||
case 2:
|
||||
self = .member
|
||||
default:
|
||||
assertionFailure()
|
||||
self = .member
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
switch self {
|
||||
case .creator:
|
||||
encoder.encodeInt32(0, forKey: "_v")
|
||||
case let .admin(rights):
|
||||
encoder.encodeInt32(1, forKey: "_v")
|
||||
encoder.encodeObject(rights, forKey: "r")
|
||||
case .member:
|
||||
encoder.encodeInt32(2, forKey: "_v")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum TelegramGroupMembership: Int32 {
|
||||
@ -28,7 +54,6 @@ public struct TelegramGroupFlags: OptionSet {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static let adminsEnabled = TelegramGroupFlags(rawValue: 1 << 0)
|
||||
public static let deactivated = TelegramGroupFlags(rawValue: 1 << 1)
|
||||
}
|
||||
|
||||
@ -49,6 +74,7 @@ public final class TelegramGroup: Peer {
|
||||
public let role: TelegramGroupRole
|
||||
public let membership: TelegramGroupMembership
|
||||
public let flags: TelegramGroupFlags
|
||||
public let defaultBannedRights: TelegramChatBannedRights?
|
||||
public let migrationReference: TelegramGroupToChannelMigrationReference?
|
||||
public let creationDate: Int32
|
||||
public let version: Int
|
||||
@ -60,7 +86,7 @@ public final class TelegramGroup: Peer {
|
||||
public let associatedPeerId: PeerId? = nil
|
||||
public let notificationSettingsPeerId: PeerId? = nil
|
||||
|
||||
public init(id: PeerId, title: String, photo: [TelegramMediaImageRepresentation], participantCount: Int, role: TelegramGroupRole, membership: TelegramGroupMembership, flags: TelegramGroupFlags, migrationReference: TelegramGroupToChannelMigrationReference?, creationDate: Int32, version: Int) {
|
||||
public init(id: PeerId, title: String, photo: [TelegramMediaImageRepresentation], participantCount: Int, role: TelegramGroupRole, membership: TelegramGroupMembership, flags: TelegramGroupFlags, defaultBannedRights: TelegramChatBannedRights?, migrationReference: TelegramGroupToChannelMigrationReference?, creationDate: Int32, version: Int) {
|
||||
self.id = id
|
||||
self.title = title
|
||||
self.photo = photo
|
||||
@ -68,6 +94,7 @@ public final class TelegramGroup: Peer {
|
||||
self.role = role
|
||||
self.membership = membership
|
||||
self.flags = flags
|
||||
self.defaultBannedRights = defaultBannedRights
|
||||
self.migrationReference = migrationReference
|
||||
self.creationDate = creationDate
|
||||
self.version = version
|
||||
@ -78,9 +105,16 @@ public final class TelegramGroup: Peer {
|
||||
self.title = decoder.decodeStringForKey("t", orElse: "")
|
||||
self.photo = decoder.decodeObjectArrayForKey("ph")
|
||||
self.participantCount = Int(decoder.decodeInt32ForKey("pc", orElse: 0))
|
||||
self.role = TelegramGroupRole(rawValue: decoder.decodeInt32ForKey("r", orElse: 0))!
|
||||
if let role = decoder.decodeObjectForKey("rv", decoder: { TelegramGroupRole(decoder: $0) }) as? TelegramGroupRole {
|
||||
self.role = role
|
||||
} else if let roleValue = decoder.decodeOptionalInt32ForKey("r"), roleValue == 0 {
|
||||
self.role = .creator
|
||||
} else {
|
||||
self.role = .member
|
||||
}
|
||||
self.membership = TelegramGroupMembership(rawValue: decoder.decodeInt32ForKey("m", orElse: 0))!
|
||||
self.flags = TelegramGroupFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0))
|
||||
self.defaultBannedRights = decoder.decodeObjectForKey("dbr", decoder: { TelegramChatBannedRights(decoder: $0) }) as? TelegramChatBannedRights
|
||||
let migrationPeerId: Int64? = decoder.decodeOptionalInt64ForKey("mr.i")
|
||||
let migrationAccessHash: Int64? = decoder.decodeOptionalInt64ForKey("mr.a")
|
||||
if let migrationPeerId = migrationPeerId, let migrationAccessHash = migrationAccessHash {
|
||||
@ -97,8 +131,13 @@ public final class TelegramGroup: Peer {
|
||||
encoder.encodeString(self.title, forKey: "t")
|
||||
encoder.encodeObjectArray(self.photo, forKey: "ph")
|
||||
encoder.encodeInt32(Int32(self.participantCount), forKey: "pc")
|
||||
encoder.encodeInt32(self.role.rawValue, forKey: "r")
|
||||
encoder.encodeObject(self.role, forKey: "rv")
|
||||
encoder.encodeInt32(self.membership.rawValue, forKey: "m")
|
||||
if let defaultBannedRights = self.defaultBannedRights {
|
||||
encoder.encodeObject(defaultBannedRights, forKey: "dbr")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "dbr")
|
||||
}
|
||||
if let migrationReference = self.migrationReference {
|
||||
encoder.encodeInt64(migrationReference.peerId.toInt64(), forKey: "mr.i")
|
||||
encoder.encodeInt64(migrationReference.accessHash, forKey: "mr.a")
|
||||
@ -133,6 +172,9 @@ public final class TelegramGroup: Peer {
|
||||
if self.role != other.role {
|
||||
return false
|
||||
}
|
||||
if self.defaultBannedRights != other.defaultBannedRights {
|
||||
return false
|
||||
}
|
||||
if self.migrationReference != other.migrationReference {
|
||||
return false
|
||||
}
|
||||
@ -149,6 +191,25 @@ public final class TelegramGroup: Peer {
|
||||
}
|
||||
|
||||
public func updateFlags(flags: TelegramGroupFlags, version: Int) -> TelegramGroup {
|
||||
return TelegramGroup(id: self.id, title: self.title, photo: self.photo, participantCount: self.participantCount, role: self.role, membership: self.membership, flags: flags, migrationReference: self.migrationReference, creationDate: self.creationDate, version: version)
|
||||
return TelegramGroup(id: self.id, title: self.title, photo: self.photo, participantCount: self.participantCount, role: self.role, membership: self.membership, flags: flags, defaultBannedRights: self.defaultBannedRights, migrationReference: self.migrationReference, creationDate: self.creationDate, version: version)
|
||||
}
|
||||
|
||||
public func updateDefaultBannedRights(_ defaultBannedRights: TelegramChatBannedRights?, version: Int) -> TelegramGroup {
|
||||
return TelegramGroup(id: self.id, title: self.title, photo: self.photo, participantCount: self.participantCount, role: self.role, membership: self.membership, flags: self.flags, defaultBannedRights: defaultBannedRights, migrationReference: self.migrationReference, creationDate: self.creationDate, version: version)
|
||||
}
|
||||
}
|
||||
|
||||
public extension TelegramGroup {
|
||||
public func hasBannedPermission(_ rights: TelegramChatBannedRightsFlags) -> Bool {
|
||||
switch self.role {
|
||||
case .creator, .admin:
|
||||
return false
|
||||
default:
|
||||
if let bannedRights = self.defaultBannedRights {
|
||||
return bannedRights.flags.contains(rights)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +184,6 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
||||
let participants = CachedGroupParticipants(apiParticipants: chatFull.participants)
|
||||
let exportedInvitation = ExportedInvitation(apiExportedInvite: chatFull.exportedInvite)
|
||||
let pinnedMessageId = chatFull.pinnedMsgId.flatMap({ MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) })
|
||||
let defaultBannedRights = chatFull.defaultBannedRights.flatMap(TelegramChatBannedRights.init(apiBannedRights:))
|
||||
|
||||
var peers: [Peer] = []
|
||||
var peerPresences: [PeerId: PeerPresence] = [:]
|
||||
@ -207,6 +206,11 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
||||
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: peerPresences)
|
||||
|
||||
var flags = CachedGroupFlags()
|
||||
if (chatFull.flags & 1 << 7) != 0 {
|
||||
flags.insert(.canChangeUsername)
|
||||
}
|
||||
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current in
|
||||
let previous: CachedGroupData
|
||||
if let current = current as? CachedGroupData {
|
||||
@ -219,8 +223,8 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
||||
.withUpdatedExportedInvitation(exportedInvitation)
|
||||
.withUpdatedBotInfos(botInfos)
|
||||
.withUpdatedPinnedMessageId(pinnedMessageId)
|
||||
.withUpdatedDefaultBannedRights(defaultBannedRights)
|
||||
.withUpdatedAbout(chatFull.about)
|
||||
.withUpdatedFlags(flags)
|
||||
})
|
||||
case .channelFull:
|
||||
break
|
||||
@ -250,7 +254,7 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
||||
}
|
||||
|
||||
switch fullChat {
|
||||
case let .channelFull(flags, _, about, participantsCount, adminsCount, kickedCount, bannedCount, _, _, _, _, _, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId, apiDefaultBannedRights):
|
||||
case let .channelFull(flags, _, about, participantsCount, adminsCount, kickedCount, bannedCount, _, _, _, _, _, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId):
|
||||
var channelFlags = CachedChannelFlags()
|
||||
if (flags & (1 << 3)) != 0 {
|
||||
channelFlags.insert(.canDisplayParticipants)
|
||||
@ -293,8 +297,6 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
||||
migrationReference = ChannelMigrationReference(maxMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: migratedFromChatId), namespace: Namespaces.Message.Cloud, id: migratedFromMaxId))
|
||||
}
|
||||
|
||||
let defaultBannedRights = apiDefaultBannedRights.flatMap(TelegramChatBannedRights.init(apiBannedRights:))
|
||||
|
||||
var peers: [Peer] = []
|
||||
var peerPresences: [PeerId: PeerPresence] = [:]
|
||||
for chat in chats {
|
||||
@ -352,7 +354,6 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
||||
.withUpdatedStickerPack(stickerPack)
|
||||
.withUpdatedMinAvailableMessageId(minAvailableMessageId)
|
||||
.withUpdatedMigrationReference(migrationReference)
|
||||
.withUpdatedDefaultBannedRights(defaultBannedRights)
|
||||
})
|
||||
|
||||
if let minAvailableMessageId = minAvailableMessageId, minAvailableMessageIdUpdated {
|
||||
|
||||
@ -78,15 +78,15 @@ public func requestUpdatePinnedMessage(account: Account, peerId: PeerId, update:
|
||||
} else {
|
||||
var canPin = false
|
||||
if let group = peer as? TelegramGroup {
|
||||
if group.flags.contains(.adminsEnabled) {
|
||||
switch group.role {
|
||||
case .creator, .admin:
|
||||
switch group.role {
|
||||
case .creator, .admin:
|
||||
canPin = true
|
||||
default:
|
||||
if let defaultBannedRights = group.defaultBannedRights {
|
||||
canPin = !defaultBannedRights.flags.contains(.banPinMessages)
|
||||
} else {
|
||||
canPin = true
|
||||
default:
|
||||
canPin = false
|
||||
}
|
||||
} else {
|
||||
canPin = true
|
||||
}
|
||||
}
|
||||
} else if let _ = peer as? TelegramUser, let cachedPeerData = cachedPeerData as? CachedUserData {
|
||||
canPin = cachedPeerData.canPinMessages
|
||||
|
||||
@ -167,8 +167,8 @@ extension Api.Chat {
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: id)
|
||||
case let .chatForbidden(id, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: id)
|
||||
case let .channel(_, id, _, _, _, _, _, _, _, _, _, _/*feed*//*, _*/):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: id)
|
||||
case let .channel(channel):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: channel.id)
|
||||
case let .channelForbidden(_, id, _, _, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: id)
|
||||
}
|
||||
@ -266,8 +266,6 @@ extension Api.Update {
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)]
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)]
|
||||
case let .updateChatAdmins(chatId, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)]
|
||||
case let .updateChatParticipantAdd(chatId, userId, inviterId, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId), PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), PeerId(namespace: Namespaces.Peer.CloudUser, id: inviterId)]
|
||||
case let .updateChatParticipantAdmin(chatId, userId, _, _):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user