This commit is contained in:
Ali 2023-08-29 13:50:21 +04:00
parent fa9cf22304
commit f9c2a1e14c
15 changed files with 428 additions and 9227 deletions

View File

@ -168,7 +168,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1605510357] = { return Api.ChatAdminRights.parse_chatAdminRights($0) }
dict[-219353309] = { return Api.ChatAdminWithInvites.parse_chatAdminWithInvites($0) }
dict[-1626209256] = { return Api.ChatBannedRights.parse_chatBannedRights($0) }
dict[-231385849] = { return Api.ChatFull.parse_channelFull($0) }
dict[1915758525] = { return Api.ChatFull.parse_channelFull($0) }
dict[-908914376] = { return Api.ChatFull.parse_chatFull($0) }
dict[806110401] = { return Api.ChatInvite.parse_chatInvite($0) }
dict[1516793212] = { return Api.ChatInvite.parse_chatInviteAlready($0) }
@ -453,7 +453,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1361650766] = { return Api.MaskCoords.parse_maskCoords($0) }
dict[-1300094593] = { return Api.MediaArea.parse_inputMediaAreaVenue($0) }
dict[-544523486] = { return Api.MediaArea.parse_mediaAreaGeoPoint($0) }
dict[1272429760] = { return Api.MediaArea.parse_mediaAreaSuggestedReaction($0) }
dict[340088945] = { return Api.MediaArea.parse_mediaAreaSuggestedReaction($0) }
dict[-1098720356] = { return Api.MediaArea.parse_mediaAreaVenue($0) }
dict[64088654] = { return Api.MediaAreaCoordinates.parse_mediaAreaCoordinates($0) }
dict[940666592] = { return Api.Message.parse_message($0) }

View File

@ -50,7 +50,7 @@ public extension Api {
enum MediaArea: TypeConstructorDescription {
case inputMediaAreaVenue(coordinates: Api.MediaAreaCoordinates, queryId: Int64, resultId: String)
case mediaAreaGeoPoint(coordinates: Api.MediaAreaCoordinates, geo: Api.GeoPoint)
case mediaAreaSuggestedReaction(coordinates: Api.MediaAreaCoordinates, reaction: Api.Reaction)
case mediaAreaSuggestedReaction(flags: Int32, coordinates: Api.MediaAreaCoordinates, reaction: Api.Reaction)
case mediaAreaVenue(coordinates: Api.MediaAreaCoordinates, geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -70,10 +70,11 @@ public extension Api {
coordinates.serialize(buffer, true)
geo.serialize(buffer, true)
break
case .mediaAreaSuggestedReaction(let coordinates, let reaction):
case .mediaAreaSuggestedReaction(let flags, let coordinates, let reaction):
if boxed {
buffer.appendInt32(1272429760)
buffer.appendInt32(340088945)
}
serializeInt32(flags, buffer: buffer, boxed: false)
coordinates.serialize(buffer, true)
reaction.serialize(buffer, true)
break
@ -98,8 +99,8 @@ public extension Api {
return ("inputMediaAreaVenue", [("coordinates", coordinates as Any), ("queryId", queryId as Any), ("resultId", resultId as Any)])
case .mediaAreaGeoPoint(let coordinates, let geo):
return ("mediaAreaGeoPoint", [("coordinates", coordinates as Any), ("geo", geo as Any)])
case .mediaAreaSuggestedReaction(let coordinates, let reaction):
return ("mediaAreaSuggestedReaction", [("coordinates", coordinates as Any), ("reaction", reaction as Any)])
case .mediaAreaSuggestedReaction(let flags, let coordinates, let reaction):
return ("mediaAreaSuggestedReaction", [("flags", flags as Any), ("coordinates", coordinates as Any), ("reaction", reaction as Any)])
case .mediaAreaVenue(let coordinates, let geo, let title, let address, let provider, let venueId, let venueType):
return ("mediaAreaVenue", [("coordinates", coordinates as Any), ("geo", geo as Any), ("title", title as Any), ("address", address as Any), ("provider", provider as Any), ("venueId", venueId as Any), ("venueType", venueType as Any)])
}
@ -143,18 +144,21 @@ public extension Api {
}
}
public static func parse_mediaAreaSuggestedReaction(_ reader: BufferReader) -> MediaArea? {
var _1: Api.MediaAreaCoordinates?
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.MediaAreaCoordinates?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.MediaAreaCoordinates
_2 = Api.parse(reader, signature: signature) as? Api.MediaAreaCoordinates
}
var _2: Api.Reaction?
var _3: Api.Reaction?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Reaction
_3 = Api.parse(reader, signature: signature) as? Api.Reaction
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.MediaArea.mediaAreaSuggestedReaction(coordinates: _1!, reaction: _2!)
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.MediaArea.mediaAreaSuggestedReaction(flags: _1!, coordinates: _2!, reaction: _3!)
}
else {
return nil

View File

@ -894,14 +894,14 @@ public extension Api {
}
public extension Api {
enum ChatFull: TypeConstructorDescription {
case channelFull(flags: Int32, flags2: Int32, id: Int64, 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: Int64?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int64?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?, ttlPeriod: Int32?, pendingSuggestions: [String]?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, defaultSendAs: Api.Peer?, availableReactions: Api.ChatReactions?)
case channelFull(flags: Int32, flags2: Int32, id: Int64, 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: Int64?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int64?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?, ttlPeriod: Int32?, pendingSuggestions: [String]?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, defaultSendAs: Api.Peer?, availableReactions: Api.ChatReactions?, stories: Api.PeerStories?)
case chatFull(flags: Int32, id: Int64, about: String, participants: Api.ChatParticipants, chatPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo]?, pinnedMsgId: Int32?, folderId: Int32?, call: Api.InputGroupCall?, ttlPeriod: Int32?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, availableReactions: Api.ChatReactions?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .channelFull(let flags, let flags2, 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 folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call, let ttlPeriod, let pendingSuggestions, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let defaultSendAs, let availableReactions):
case .channelFull(let flags, let flags2, 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 folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call, let ttlPeriod, let pendingSuggestions, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let defaultSendAs, let availableReactions, let stories):
if boxed {
buffer.appendInt32(-231385849)
buffer.appendInt32(1915758525)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(flags2, buffer: buffer, boxed: false)
@ -952,6 +952,7 @@ public extension Api {
}}
if Int(flags) & Int(1 << 29) != 0 {defaultSendAs!.serialize(buffer, true)}
if Int(flags) & Int(1 << 30) != 0 {availableReactions!.serialize(buffer, true)}
if Int(flags2) & Int(1 << 4) != 0 {stories!.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 folderId, let call, let ttlPeriod, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let availableReactions):
if boxed {
@ -988,8 +989,8 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .channelFull(let flags, let flags2, 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 folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call, let ttlPeriod, let pendingSuggestions, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let defaultSendAs, let availableReactions):
return ("channelFull", [("flags", flags as Any), ("flags2", flags2 as Any), ("id", id as Any), ("about", about as Any), ("participantsCount", participantsCount as Any), ("adminsCount", adminsCount as Any), ("kickedCount", kickedCount as Any), ("bannedCount", bannedCount as Any), ("onlineCount", onlineCount as Any), ("readInboxMaxId", readInboxMaxId as Any), ("readOutboxMaxId", readOutboxMaxId as Any), ("unreadCount", unreadCount as Any), ("chatPhoto", chatPhoto as Any), ("notifySettings", notifySettings as Any), ("exportedInvite", exportedInvite as Any), ("botInfo", botInfo as Any), ("migratedFromChatId", migratedFromChatId as Any), ("migratedFromMaxId", migratedFromMaxId as Any), ("pinnedMsgId", pinnedMsgId as Any), ("stickerset", stickerset as Any), ("availableMinId", availableMinId as Any), ("folderId", folderId as Any), ("linkedChatId", linkedChatId as Any), ("location", location as Any), ("slowmodeSeconds", slowmodeSeconds as Any), ("slowmodeNextSendDate", slowmodeNextSendDate as Any), ("statsDc", statsDc as Any), ("pts", pts as Any), ("call", call as Any), ("ttlPeriod", ttlPeriod as Any), ("pendingSuggestions", pendingSuggestions as Any), ("groupcallDefaultJoinAs", groupcallDefaultJoinAs as Any), ("themeEmoticon", themeEmoticon as Any), ("requestsPending", requestsPending as Any), ("recentRequesters", recentRequesters as Any), ("defaultSendAs", defaultSendAs as Any), ("availableReactions", availableReactions as Any)])
case .channelFull(let flags, let flags2, 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 folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call, let ttlPeriod, let pendingSuggestions, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let defaultSendAs, let availableReactions, let stories):
return ("channelFull", [("flags", flags as Any), ("flags2", flags2 as Any), ("id", id as Any), ("about", about as Any), ("participantsCount", participantsCount as Any), ("adminsCount", adminsCount as Any), ("kickedCount", kickedCount as Any), ("bannedCount", bannedCount as Any), ("onlineCount", onlineCount as Any), ("readInboxMaxId", readInboxMaxId as Any), ("readOutboxMaxId", readOutboxMaxId as Any), ("unreadCount", unreadCount as Any), ("chatPhoto", chatPhoto as Any), ("notifySettings", notifySettings as Any), ("exportedInvite", exportedInvite as Any), ("botInfo", botInfo as Any), ("migratedFromChatId", migratedFromChatId as Any), ("migratedFromMaxId", migratedFromMaxId as Any), ("pinnedMsgId", pinnedMsgId as Any), ("stickerset", stickerset as Any), ("availableMinId", availableMinId as Any), ("folderId", folderId as Any), ("linkedChatId", linkedChatId as Any), ("location", location as Any), ("slowmodeSeconds", slowmodeSeconds as Any), ("slowmodeNextSendDate", slowmodeNextSendDate as Any), ("statsDc", statsDc as Any), ("pts", pts as Any), ("call", call as Any), ("ttlPeriod", ttlPeriod as Any), ("pendingSuggestions", pendingSuggestions as Any), ("groupcallDefaultJoinAs", groupcallDefaultJoinAs as Any), ("themeEmoticon", themeEmoticon as Any), ("requestsPending", requestsPending as Any), ("recentRequesters", recentRequesters as Any), ("defaultSendAs", defaultSendAs as Any), ("availableReactions", availableReactions as Any), ("stories", stories as Any)])
case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId, let folderId, let call, let ttlPeriod, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let availableReactions):
return ("chatFull", [("flags", flags as Any), ("id", id as Any), ("about", about as Any), ("participants", participants as Any), ("chatPhoto", chatPhoto as Any), ("notifySettings", notifySettings as Any), ("exportedInvite", exportedInvite as Any), ("botInfo", botInfo as Any), ("pinnedMsgId", pinnedMsgId as Any), ("folderId", folderId as Any), ("call", call as Any), ("ttlPeriod", ttlPeriod as Any), ("groupcallDefaultJoinAs", groupcallDefaultJoinAs as Any), ("themeEmoticon", themeEmoticon as Any), ("requestsPending", requestsPending as Any), ("recentRequesters", recentRequesters as Any), ("availableReactions", availableReactions as Any)])
}
@ -1094,6 +1095,10 @@ public extension Api {
if Int(_1!) & Int(1 << 30) != 0 {if let signature = reader.readInt32() {
_37 = Api.parse(reader, signature: signature) as? Api.ChatReactions
} }
var _38: Api.PeerStories?
if Int(_2!) & Int(1 << 4) != 0 {if let signature = reader.readInt32() {
_38 = Api.parse(reader, signature: signature) as? Api.PeerStories
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
@ -1131,8 +1136,9 @@ public extension Api {
let _c35 = (Int(_1!) & Int(1 << 28) == 0) || _35 != nil
let _c36 = (Int(_1!) & Int(1 << 29) == 0) || _36 != nil
let _c37 = (Int(_1!) & Int(1 << 30) == 0) || _37 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 && _c21 && _c22 && _c23 && _c24 && _c25 && _c26 && _c27 && _c28 && _c29 && _c30 && _c31 && _c32 && _c33 && _c34 && _c35 && _c36 && _c37 {
return Api.ChatFull.channelFull(flags: _1!, flags2: _2!, id: _3!, about: _4!, participantsCount: _5, adminsCount: _6, kickedCount: _7, bannedCount: _8, onlineCount: _9, readInboxMaxId: _10!, readOutboxMaxId: _11!, unreadCount: _12!, chatPhoto: _13!, notifySettings: _14!, exportedInvite: _15, botInfo: _16!, migratedFromChatId: _17, migratedFromMaxId: _18, pinnedMsgId: _19, stickerset: _20, availableMinId: _21, folderId: _22, linkedChatId: _23, location: _24, slowmodeSeconds: _25, slowmodeNextSendDate: _26, statsDc: _27, pts: _28!, call: _29, ttlPeriod: _30, pendingSuggestions: _31, groupcallDefaultJoinAs: _32, themeEmoticon: _33, requestsPending: _34, recentRequesters: _35, defaultSendAs: _36, availableReactions: _37)
let _c38 = (Int(_2!) & Int(1 << 4) == 0) || _38 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 && _c21 && _c22 && _c23 && _c24 && _c25 && _c26 && _c27 && _c28 && _c29 && _c30 && _c31 && _c32 && _c33 && _c34 && _c35 && _c36 && _c37 && _c38 {
return Api.ChatFull.channelFull(flags: _1!, flags2: _2!, id: _3!, about: _4!, participantsCount: _5, adminsCount: _6, kickedCount: _7, bannedCount: _8, onlineCount: _9, readInboxMaxId: _10!, readOutboxMaxId: _11!, unreadCount: _12!, chatPhoto: _13!, notifySettings: _14!, exportedInvite: _15, botInfo: _16!, migratedFromChatId: _17, migratedFromMaxId: _18, pinnedMsgId: _19, stickerset: _20, availableMinId: _21, folderId: _22, linkedChatId: _23, location: _24, slowmodeSeconds: _25, slowmodeNextSendDate: _26, statsDc: _27, pts: _28!, call: _29, ttlPeriod: _30, pendingSuggestions: _31, groupcallDefaultJoinAs: _32, themeEmoticon: _33, requestsPending: _34, recentRequesters: _35, defaultSendAs: _36, availableReactions: _37, stories: _38)
}
else {
return nil

View File

@ -1806,6 +1806,21 @@ public extension Api.functions.auth {
})
}
}
public extension Api.functions.bots {
static func allowSendMessage(bot: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(-248323089)
bot.serialize(buffer, true)
return (FunctionDescription(name: "bots.allowSendMessage", parameters: [("bot", String(describing: bot))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Updates
}
return result
})
}
}
public extension Api.functions.bots {
static func answerWebhookJSONQuery(queryId: Int64, data: Api.DataJSON) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer()
@ -1822,6 +1837,21 @@ public extension Api.functions.bots {
})
}
}
public extension Api.functions.bots {
static func canSendMessage(bot: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer()
buffer.appendInt32(324662502)
bot.serialize(buffer, true)
return (FunctionDescription(name: "bots.canSendMessage", parameters: [("bot", String(describing: bot))]), 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 extension Api.functions.bots {
static func getBotCommands(scope: Api.BotCommandScope, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.BotCommand]>) {
let buffer = Buffer()
@ -1870,6 +1900,23 @@ public extension Api.functions.bots {
})
}
}
public extension Api.functions.bots {
static func invokeWebViewCustomMethod(bot: Api.InputUser, customMethod: String, params: Api.DataJSON) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.DataJSON>) {
let buffer = Buffer()
buffer.appendInt32(142591463)
bot.serialize(buffer, true)
serializeString(customMethod, buffer: buffer, boxed: false)
params.serialize(buffer, true)
return (FunctionDescription(name: "bots.invokeWebViewCustomMethod", parameters: [("bot", String(describing: bot)), ("customMethod", String(describing: customMethod)), ("params", String(describing: params))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.DataJSON? in
let reader = BufferReader(buffer)
var result: Api.DataJSON?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.DataJSON
}
return result
})
}
}
public extension Api.functions.bots {
static func reorderUsernames(bot: Api.InputUser, order: [String]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer()
@ -8602,6 +8649,21 @@ public extension Api.functions.stories {
})
}
}
public extension Api.functions.stories {
static func getChatsToSend() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Chats>) {
let buffer = Buffer()
buffer.appendInt32(-1519744160)
return (FunctionDescription(name: "stories.getChatsToSend", parameters: []), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Chats? in
let reader = BufferReader(buffer)
var result: Api.messages.Chats?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.messages.Chats
}
return result
})
}
}
public extension Api.functions.stories {
static func getPeerStories(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stories.PeerStories>) {
let buffer = Buffer()
@ -8635,12 +8697,13 @@ public extension Api.functions.stories {
}
}
public extension Api.functions.stories {
static func getStoriesArchive(offsetId: Int32, limit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stories.Stories>) {
static func getStoriesArchive(peer: Api.InputPeer, offsetId: Int32, limit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stories.Stories>) {
let buffer = Buffer()
buffer.appendInt32(526108114)
buffer.appendInt32(-1271586794)
peer.serialize(buffer, true)
serializeInt32(offsetId, buffer: buffer, boxed: false)
serializeInt32(limit, buffer: buffer, boxed: false)
return (FunctionDescription(name: "stories.getStoriesArchive", parameters: [("offsetId", String(describing: offsetId)), ("limit", String(describing: limit))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.stories.Stories? in
return (FunctionDescription(name: "stories.getStoriesArchive", parameters: [("peer", String(describing: peer)), ("offsetId", String(describing: offsetId)), ("limit", String(describing: limit))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.stories.Stories? in
let reader = BufferReader(buffer)
var result: Api.stories.Stories?
if let signature = reader.readInt32() {

File diff suppressed because it is too large Load Diff

View File

@ -423,7 +423,7 @@ func mediaAreaFromApiMediaArea(_ mediaArea: Api.MediaArea) -> MediaArea? {
longitude = 0.0
}
return .venue(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), venue: MediaArea.Venue(latitude: latitude, longitude: longitude, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: venueType), queryId: nil, resultId: nil))
case let .mediaAreaSuggestedReaction(coordinates, reaction):
case let .mediaAreaSuggestedReaction(_, coordinates, reaction):
if let reaction = MessageReaction.Reaction(apiReaction: reaction) {
return .reaction(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), reaction: reaction)
} else {
@ -447,7 +447,7 @@ func apiMediaAreasFromMediaAreas(_ mediaAreas: [MediaArea]) -> [Api.MediaArea] {
apiMediaAreas.append(.mediaAreaGeoPoint(coordinates: inputCoordinates, geo: .geoPoint(flags: 0, long: venue.longitude, lat: venue.latitude, accessHash: 0, accuracyRadius: nil)))
}
case let .reaction(_, reaction):
apiMediaAreas.append(.mediaAreaSuggestedReaction(coordinates: inputCoordinates, reaction: reaction.apiReaction))
apiMediaAreas.append(.mediaAreaSuggestedReaction(flags: 0, coordinates: inputCoordinates, reaction: reaction.apiReaction))
}
}
return apiMediaAreas

View File

@ -4616,6 +4616,8 @@ func replayFinalState(
))
if let entry = CodableEntry(updatedItem) {
transaction.setStory(id: StoryId(peerId: peerId, id: id), value: entry)
storyUpdates.append(InternalStoryUpdate.added(peerId: peerId, item: updatedItem))
}
}
}
@ -5075,7 +5077,20 @@ func replayFinalState(
for update in storyUpdates {
switch update {
case let .added(peerId, _):
if shouldKeepUserStoriesInFeed(peerId: peerId, isContact: transaction.isPeerContact(peerId: peerId)) {
var isContactOrMember = false
if transaction.isPeerContact(peerId: peerId) {
isContactOrMember = true
} else if let peer = transaction.getPeer(peerId) as? TelegramChannel {
if peer.participationStatus == .member {
isContactOrMember = true
}
} else if let peer = transaction.getPeer(peerId) as? TelegramGroup {
if case .Member = peer.membership {
isContactOrMember = true
}
}
if shouldKeepUserStoriesInFeed(peerId: peerId, isContactOrMember: isContactOrMember) {
if !transaction.storySubscriptionsContains(key: .hidden, peerId: peerId) && !transaction.storySubscriptionsContains(key: .filtered, peerId: peerId) {
_internal_addSynchronizePeerStoriesOperation(peerId: peerId, transaction: transaction)
}

View File

@ -1271,7 +1271,7 @@ func _internal_deleteStories(account: Account, peerId: PeerId, ids: [Int32]) ->
transaction.setStoryItems(peerId: account.peerId, items: items)
}
account.stateManager.injectStoryUpdates(updates: ids.map { id in
return .deleted(peerId: account.peerId, id: id)
return .deleted(peerId: peerId, id: id)
})
return inputPeer
@ -1400,7 +1400,7 @@ func _internal_updateStoriesArePinned(account: Account, peerId: PeerId, ids: [In
if !updatedItems.isEmpty {
DispatchQueue.main.async {
account.stateManager.injectStoryUpdates(updates: updatedItems.map { updatedItem in
return .added(peerId: account.peerId, item: Stories.StoredItem.item(updatedItem))
return .added(peerId: peerId, item: Stories.StoredItem.item(updatedItem))
})
}
}
@ -1884,14 +1884,16 @@ public func _internal_setStoryNotificationWasDisplayed(transaction: Transaction,
}
func _internal_setStoryReaction(account: Account, peerId: EnginePeer.Id, id: Int32, reaction: MessageReaction.Reaction?) -> Signal<Never, NoError> {
return account.postbox.transaction { transaction -> Api.InputPeer? in
return account.postbox.transaction { transaction -> (Stories.StoredItem?, Api.InputPeer?) in
guard let peer = transaction.getPeer(peerId) else {
return nil
return (nil, nil)
}
guard let inputPeer = apiInputPeer(peer) else {
return nil
return (nil, nil)
}
var updatedItemValue: Stories.StoredItem?
var currentItems = transaction.getStoryItems(peerId: peerId)
for i in 0 ..< currentItems.count {
if currentItems[i].id == id {
@ -1916,6 +1918,7 @@ func _internal_setStoryReaction(account: Account, peerId: EnginePeer.Id, id: Int
isEdited: item.isEdited,
myReaction: reaction
))
updatedItemValue = updatedItem
if let entry = CodableEntry(updatedItem) {
currentItems[i] = StoryItemsTableEntry(value: entry, id: updatedItem.id, expirationTimestamp: updatedItem.expirationTimestamp, isCloseFriends: updatedItem.isCloseFriends)
}
@ -1945,17 +1948,21 @@ func _internal_setStoryReaction(account: Account, peerId: EnginePeer.Id, id: Int
isEdited: item.isEdited,
myReaction: reaction
))
updatedItemValue = updatedItem
if let entry = CodableEntry(updatedItem) {
transaction.setStory(id: StoryId(peerId: peerId, id: id), value: entry)
}
}
return inputPeer
return (updatedItemValue, inputPeer)
}
|> mapToSignal { inputPeer -> Signal<Never, NoError> in
guard let inputPeer = inputPeer else {
|> mapToSignal { storyItem, inputPeer -> Signal<Never, NoError> in
guard let storyItem, let inputPeer = inputPeer else {
return .complete()
}
account.stateManager.injectStoryUpdates(updates: [InternalStoryUpdate.added(peerId: peerId, item: storyItem)])
return account.network.request(Api.functions.stories.sendReaction(flags: 0, peer: inputPeer, storyId: id, reaction: reaction?.apiReaction ?? .reactionEmpty))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.Updates?, NoError> in

View File

@ -618,7 +618,7 @@ public final class PeerStoryListContext {
let signal: Signal<Api.stories.Stories, MTRpcError>
if isArchived {
signal = account.network.request(Api.functions.stories.getStoriesArchive(offsetId: Int32(loadMoreToken), limit: Int32(limit)))
signal = account.network.request(Api.functions.stories.getStoriesArchive(peer: inputPeer, offsetId: Int32(loadMoreToken), limit: Int32(limit)))
} else {
signal = account.network.request(Api.functions.stories.getPinnedStories(peer: inputPeer, offsetId: Int32(loadMoreToken), limit: Int32(limit)))
}
@ -1379,7 +1379,20 @@ public func _internal_pollPeerStories(postbox: Postbox, network: Network, accoun
transaction.setStoryItems(peerId: peerId, items: updatedPeerEntries)
if !updatedPeerEntries.isEmpty, shouldKeepUserStoriesInFeed(peerId: peerId, isContact: transaction.isPeerContact(peerId: peerId)) {
var isContactOrMember = false
if transaction.isPeerContact(peerId: peerId) {
isContactOrMember = true
} else if let peer = transaction.getPeer(peerId) as? TelegramChannel {
if peer.participationStatus == .member {
isContactOrMember = true
}
} else if let peer = transaction.getPeer(peerId) as? TelegramGroup {
if case .Member = peer.membership {
isContactOrMember = true
}
}
if !updatedPeerEntries.isEmpty, shouldKeepUserStoriesInFeed(peerId: peerId, isContactOrMember: isContactOrMember) {
if let user = transaction.getPeer(peerId) as? TelegramUser, let storiesHidden = user.storiesHidden {
if storiesHidden {
if !transaction.storySubscriptionsContains(key: .hidden, peerId: peerId) {

View File

@ -431,14 +431,14 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
switch result {
case let .chatFull(fullChat, chats, users):
switch fullChat {
case let .channelFull(_, _, _, _, _, _, _, _, _, _, _, _, _, notifySettings, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
case let .channelFull(_, _, _, _, _, _, _, _, _, _, _, _, _, notifySettings, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
transaction.updateCurrentPeerNotificationSettings([peerId: TelegramPeerNotificationSettings(apiSettings: notifySettings)])
case .chatFull:
break
}
switch fullChat {
case let .channelFull(flags, flags2, _, about, participantsCount, adminsCount, kickedCount, bannedCount, _, _, _, _, chatPhoto, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId, _, linkedChatId, location, slowmodeSeconds, slowmodeNextSendDate, statsDc, _, inputCall, ttl, pendingSuggestions, groupcallDefaultJoinAs, themeEmoticon, requestsPending, _, defaultSendAs, allowedReactions):
case let .channelFull(flags, flags2, _, about, participantsCount, adminsCount, kickedCount, bannedCount, _, _, _, _, chatPhoto, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId, _, linkedChatId, location, slowmodeSeconds, slowmodeNextSendDate, statsDc, _, inputCall, ttl, pendingSuggestions, groupcallDefaultJoinAs, themeEmoticon, requestsPending, _, defaultSendAs, allowedReactions, _):
var channelFlags = CachedChannelFlags()
if (flags & (1 << 3)) != 0 {
channelFlags.insert(.canDisplayParticipants)

View File

@ -38,11 +38,11 @@ func minTimestampForPeerInclusion(_ peer: Peer) -> Int32? {
}
}
func shouldKeepUserStoriesInFeed(peerId: PeerId, isContact: Bool) -> Bool {
func shouldKeepUserStoriesInFeed(peerId: PeerId, isContactOrMember: Bool) -> Bool {
if peerId.namespace == Namespaces.Peer.CloudUser && (peerId.id._internalGetInt64Value() == 777000 || peerId.id._internalGetInt64Value() == 333000) {
return true
}
return isContact
return isContactOrMember
}
func updatePeers(transaction: Transaction, accountPeerId: PeerId, peers: AccumulatedPeers) {
@ -79,8 +79,8 @@ func updatePeers(transaction: Transaction, accountPeerId: PeerId, peers: Accumul
}
func _internal_updatePeerIsContact(transaction: Transaction, user: TelegramUser, isContact: Bool) {
let previousValue = shouldKeepUserStoriesInFeed(peerId: user.id, isContact: transaction.isPeerContact(peerId: user.id))
let updatedValue = shouldKeepUserStoriesInFeed(peerId: user.id, isContact: isContact)
let previousValue = shouldKeepUserStoriesInFeed(peerId: user.id, isContactOrMember: transaction.isPeerContact(peerId: user.id))
let updatedValue = shouldKeepUserStoriesInFeed(peerId: user.id, isContactOrMember: isContact)
if previousValue != updatedValue, let storiesHidden = user.storiesHidden {
if updatedValue {
@ -126,6 +126,51 @@ func _internal_updatePeerIsContact(transaction: Transaction, user: TelegramUser,
}
}
private func _internal_updateChannelMembership(transaction: Transaction, channel: TelegramChannel, isMember: Bool) {
if isMember {
let storiesHidden = !"".isEmpty
if storiesHidden {
if transaction.storySubscriptionsContains(key: .filtered, peerId: channel.id) {
var (state, peerIds) = transaction.getAllStorySubscriptions(key: .filtered)
peerIds.removeAll(where: { $0 == channel.id })
transaction.replaceAllStorySubscriptions(key: .filtered, state: state, peerIds: peerIds)
}
if !transaction.storySubscriptionsContains(key: .hidden, peerId: channel.id) {
var (state, peerIds) = transaction.getAllStorySubscriptions(key: .hidden)
if !peerIds.contains(channel.id) {
peerIds.append(channel.id)
transaction.replaceAllStorySubscriptions(key: .hidden, state: state, peerIds: peerIds)
}
}
} else {
if transaction.storySubscriptionsContains(key: .hidden, peerId: channel.id) {
var (state, peerIds) = transaction.getAllStorySubscriptions(key: .hidden)
peerIds.removeAll(where: { $0 == channel.id })
transaction.replaceAllStorySubscriptions(key: .hidden, state: state, peerIds: peerIds)
}
if !transaction.storySubscriptionsContains(key: .filtered, peerId: channel.id) {
var (state, peerIds) = transaction.getAllStorySubscriptions(key: .filtered)
if !peerIds.contains(channel.id) {
peerIds.append(channel.id)
transaction.replaceAllStorySubscriptions(key: .filtered, state: state, peerIds: peerIds)
}
}
}
} else {
if transaction.storySubscriptionsContains(key: .filtered, peerId: channel.id) {
var (state, peerIds) = transaction.getAllStorySubscriptions(key: .filtered)
peerIds.removeAll(where: { $0 == channel.id })
transaction.replaceAllStorySubscriptions(key: .filtered, state: state, peerIds: peerIds)
}
if transaction.storySubscriptionsContains(key: .hidden, peerId: channel.id) {
var (state, peerIds) = transaction.getAllStorySubscriptions(key: .hidden)
peerIds.removeAll(where: { $0 == channel.id })
transaction.replaceAllStorySubscriptions(key: .hidden, state: state, peerIds: peerIds)
}
}
}
public func updatePeersCustom(transaction: Transaction, peers: [Peer], update: (Peer?, Peer) -> Peer?) {
transaction.updatePeersInternal(peers, update: { previous, updated in
let peerId = updated.id
@ -134,8 +179,19 @@ public func updatePeersCustom(transaction: Transaction, peers: [Peer], update: (
if let previous = previous as? TelegramUser, let updatedUser = updated as? TelegramUser {
updated = TelegramUser.merge(lhs: previous, rhs: updatedUser)
} else if let previous = previous as? TelegramChannel, let updatedChannel = updated as? TelegramChannel {
updated = mergeChannel(lhs: previous, rhs: updatedChannel)
}
if let updatedChannel = updated as? TelegramChannel {
var wasMember = false
if let previous = previous as? TelegramChannel {
wasMember = previous.participationStatus == .member
updated = mergeChannel(lhs: previous, rhs: updatedChannel)
}
let isMember = updatedChannel.participationStatus == .member
if isMember != wasMember {
_internal_updateChannelMembership(transaction: transaction, channel: updatedChannel, isMember: isMember)
}
}
switch peerId.namespace {

View File

@ -1609,7 +1609,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
}
var headerText: String?
if strongSelf.isArchive && !mappedItems.isEmpty {
if strongSelf.isArchive && !mappedItems.isEmpty && strongSelf.peerId == strongSelf.context.account.peerId {
headerText = strongSelf.presentationData.strings.StoryList_ArchiveDescription
}

View File

@ -1767,13 +1767,17 @@ public final class StoryItemSetContainerComponent: Component {
return true
} else {
var canReply = true
if component.slice.peer.id == component.context.account.peerId {
canReply = false
} else if component.slice.peer.isService {
canReply = false
} else if case .unsupported = component.slice.item.storyItem.media {
canReply = false
var canReply = false
if case .user = component.slice.peer {
canReply = true
if component.slice.peer.id == component.context.account.peerId {
canReply = false
} else if component.slice.peer.isService {
canReply = false
} else if case .unsupported = component.slice.item.storyItem.media {
canReply = false
}
}
if canReply {
@ -1791,13 +1795,17 @@ public final class StoryItemSetContainerComponent: Component {
return nil
}
var canReply = true
if component.slice.peer.id == component.context.account.peerId {
canReply = false
} else if component.slice.peer.isService {
canReply = false
} else if case .unsupported = component.slice.item.storyItem.media {
canReply = false
var canReply = false
if case .user = component.slice.peer {
canReply = true
if component.slice.peer.id == component.context.account.peerId {
canReply = false
} else if component.slice.peer.isService {
canReply = false
} else if case .unsupported = component.slice.item.storyItem.media {
canReply = false
}
}
if canReply {
@ -2572,6 +2580,15 @@ public final class StoryItemSetContainerComponent: Component {
let startTime23 = CFAbsoluteTimeGetCurrent()
if component.slice.peer.id != component.context.account.peerId {
var haveLikeOptions = false
if case .user = component.slice.peer {
haveLikeOptions = true
if component.slice.peer.isService {
haveLikeOptions = false
}
}
var isChannel = false
if case .channel = component.slice.peer {
isChannel = true
@ -2690,7 +2707,7 @@ public final class StoryItemSetContainerComponent: Component {
}
self.performLikeAction()
},
likeOptionsAction: component.slice.peer.isService ? nil : { [weak self] sourceView, gesture in
likeOptionsAction: !haveLikeOptions ? nil : { [weak self] sourceView, gesture in
gesture?.cancel()
guard let self else {
@ -5141,6 +5158,8 @@ public final class StoryItemSetContainerComponent: Component {
}
if component.slice.peer.id == component.context.account.peerId {
self.performMyMoreAction(sourceView: sourceView, gesture: gesture)
} else if case let .channel(channel) = component.slice.peer, channel.hasPermission(.sendSomething) {
self.performMyChannelMoreAction(sourceView: sourceView, gesture: gesture)
} else {
self.performOtherMoreAction(sourceView: sourceView, gesture: gesture)
}
@ -5556,6 +5575,151 @@ public final class StoryItemSetContainerComponent: Component {
controller.present(contextController, in: .window(.root))
}
private func performMyChannelMoreAction(sourceView: UIView, gesture: ContextGesture?) {
guard let component = self.component, let controller = component.controller() else {
return
}
self.dismissAllTooltips()
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: component.theme)
var items: [ContextMenuItem] = []
items.append(.action(ContextMenuActionItem(text: component.strings.Story_Context_Edit, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Edit"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)
guard let self else {
return
}
self.openStoryEditing()
})))
items.append(.separator)
//TODO:localize
items.append(.action(ContextMenuActionItem(text: component.slice.item.storyItem.isPinned ? "Remove from Posts" : "Save to Posts", icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: component.slice.item.storyItem.isPinned ? "Stories/Context Menu/Unpin" : "Stories/Context Menu/Pin"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)
guard let self, let component = self.component else {
return
}
let _ = component.context.engine.messages.updateStoriesArePinned(peerId: component.slice.peer.id, ids: [component.slice.item.storyItem.id: component.slice.item.storyItem], isPinned: !component.slice.item.storyItem.isPinned).start()
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: component.theme)
//TODO:localize
if component.slice.item.storyItem.isPinned {
self.component?.presentController(UndoOverlayController(
presentationData: presentationData,
content: .info(title: nil, text: "Story removed from the channel's profile", timeout: nil),
elevatedLayout: false,
animateInAsReplacement: false,
blurred: true,
action: { _ in return false }
), nil)
} else {
self.component?.presentController(UndoOverlayController(
presentationData: presentationData,
content: .info(title: "Story saved to the channel's profile", text: "Saved stories can be viewed by others on the channel's profile until an admin removes them.", timeout: nil),
elevatedLayout: false,
animateInAsReplacement: false,
blurred: true,
action: { _ in return false }
), nil)
}
})))
let saveText: String = component.strings.Story_Context_SaveToGallery
items.append(.action(ContextMenuActionItem(text: saveText, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Save"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)
guard let self else {
return
}
self.requestSave()
})))
if case let .user(accountUser) = component.slice.peer {
items.append(.action(ContextMenuActionItem(text: component.strings.Story_ContextStealthMode, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: accountUser.isPremium ? "Chat/Context Menu/Eye" : "Chat/Context Menu/EyeLocked"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)
guard let self else {
return
}
if accountUser.isPremium {
self.sendMessageContext.requestStealthMode(view: self)
} else {
self.presentStealthModeUpgradeScreen()
}
})))
}
if component.slice.item.storyItem.isPublic && (component.slice.peer.addressName != nil || !component.slice.peer._asPeer().usernames.isEmpty) && (component.slice.item.storyItem.expirationTimestamp > Int32(Date().timeIntervalSince1970) || component.slice.item.storyItem.isPinned) {
items.append(.action(ContextMenuActionItem(text: component.strings.Story_Context_CopyLink, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Link"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)
guard let self, let component = self.component else {
return
}
let _ = (component.context.engine.messages.exportStoryLink(peerId: component.slice.peer.id, id: component.slice.item.storyItem.id)
|> deliverOnMainQueue).start(next: { [weak self] link in
guard let self, let component = self.component else {
return
}
if let link {
UIPasteboard.general.string = link
component.presentController(UndoOverlayController(
presentationData: presentationData,
content: .linkCopied(text: component.strings.Story_ToastLinkCopied),
elevatedLayout: false,
animateInAsReplacement: false,
blurred: true,
action: { _ in return false }
), nil)
}
})
})))
items.append(.action(ContextMenuActionItem(text: component.strings.Story_Context_Share, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)
guard let self else {
return
}
self.sendMessageContext.performShareAction(view: self)
})))
}
let (tip, tipSignal) = self.getLinkedStickerPacks()
let contextItems = ContextController.Items(content: .list(items), tip: tip, tipSignal: tipSignal)
let contextController = ContextController(presentationData: presentationData, source: .reference(HeaderContextReferenceContentSource(controller: controller, sourceView: sourceView, position: .bottom)), items: .single(contextItems), gesture: gesture)
contextController.dismissed = { [weak self] in
guard let self else {
return
}
self.contextController = nil
self.updateIsProgressPaused()
}
self.contextController = contextController
self.updateIsProgressPaused()
controller.present(contextController, in: .window(.root))
}
private func performOtherMoreAction(sourceView: UIView, gesture: ContextGesture?) {
guard let component = self.component else {
return

View File

@ -786,6 +786,16 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen
let requestsContextPromise = Promise<PeerInvitationImportersContext?>(nil)
let requestsStatePromise = Promise<PeerInvitationImportersState?>(nil)
let storyListContext = PeerStoryListContext(account: context.account, peerId: peerId, isArchived: false)
let hasStories: Signal<Bool?, NoError> = storyListContext.state
|> map { state -> Bool? in
if !state.hasCache {
return nil
}
return !state.items.isEmpty
}
|> distinctUntilChanged
return combineLatest(
context.account.viewTracker.peerView(peerId, updateData: true),
peerInfoAvailableMediaPanes(context: context, peerId: peerId, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder),
@ -794,9 +804,19 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen
invitationsContextPromise.get(),
invitationsStatePromise.get(),
requestsContextPromise.get(),
requestsStatePromise.get()
requestsStatePromise.get(),
hasStories
)
|> map { peerView, availablePanes, globalNotificationSettings, status, currentInvitationsContext, invitations, currentRequestsContext, requests -> PeerInfoScreenData in
|> map { peerView, availablePanes, globalNotificationSettings, status, currentInvitationsContext, invitations, currentRequestsContext, requests, hasStories -> PeerInfoScreenData in
var availablePanes = availablePanes
if let hasStories {
if hasStories {
availablePanes?.insert(.stories, at: 0)
}
} else {
availablePanes = nil
}
var discussionPeer: Peer?
if case let .known(maybeLinkedDiscussionPeerId) = (peerView.cachedData as? CachedChannelData)?.linkedDiscussionPeerId, let linkedDiscussionPeerId = maybeLinkedDiscussionPeerId, let peer = peerView.peers[linkedDiscussionPeerId] {
discussionPeer = peer
@ -835,7 +855,7 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen
groupsInCommon: nil,
linkedDiscussionPeer: discussionPeer,
members: nil,
storyListContext: nil,
storyListContext: storyListContext,
encryptionKeyFingerprint: nil,
globalSettings: nil,
invitations: invitations,

View File

@ -3864,7 +3864,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|> deliverOnMainQueue).start(next: { [weak self] translationState in
self?.translationState = translationState
})
} else if peerId.namespace == Namespaces.Peer.CloudUser {
}
if peerId.namespace == Namespaces.Peer.CloudChannel || peerId.namespace == Namespaces.Peer.CloudUser {
self.storiesReady.set(false)
let expiringStoryList = PeerExpiringStoryListContext(account: context.account, peerId: peerId)
self.expiringStoryList = expiringStoryList
@ -5318,6 +5320,16 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
}
} else if let channel = peer as? TelegramChannel {
if let cachedData = strongSelf.data?.cachedData as? CachedChannelData {
if channel.hasPermission(.sendSomething) {
//TODO:localize
items.append(.action(ContextMenuActionItem(text: "Archived Stories", icon: { theme in
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Statistics"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, f in
f(.dismissWithoutContent)
self?.openStoryArchive()
})))
}
if cachedData.flags.contains(.canViewStats) {
items.append(.action(ContextMenuActionItem(text: presentationData.strings.ChannelInfo_Stats, icon: { theme in
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Statistics"), color: theme.contextMenu.primaryColor)
@ -6495,6 +6507,10 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
})
}
private func openStoryArchive() {
self.controller?.push(PeerInfoStoryGridScreen(context: self.context, peerId: self.peerId, scope: .archive))
}
private func openStats() {
guard let controller = self.controller, let data = self.data, let peer = data.peer, let cachedData = data.cachedData else {
return