mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Update API
This commit is contained in:
parent
a50a537774
commit
9ec01a7f24
@ -11901,3 +11901,5 @@ Sorry for the inconvenience.";
|
||||
|
||||
"Stickers.RemoveFromRecent" = "Remove from Recents";
|
||||
"Conversation.StickerRemovedFromRecent" = "Sticker was removed from Recents.";
|
||||
|
||||
"Conversation.ViewStickers" = "VIEW STICKERS";
|
||||
|
@ -857,7 +857,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1239335713] = { return Api.ShippingOption.parse_shippingOption($0) }
|
||||
dict[-2010155333] = { return Api.SimpleWebViewResult.parse_simpleWebViewResultUrl($0) }
|
||||
dict[-425595208] = { return Api.SmsJob.parse_smsJob($0) }
|
||||
dict[-1611532106] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
||||
dict[-1108478618] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
||||
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
|
||||
dict[-884757282] = { return Api.StatsAbsValueAndPrev.parse_statsAbsValueAndPrev($0) }
|
||||
dict[-1237848657] = { return Api.StatsDateRangeDays.parse_statsDateRangeDays($0) }
|
||||
@ -1071,6 +1071,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[555358088] = { return Api.WebPage.parse_webPageEmpty($0) }
|
||||
dict[1930545681] = { return Api.WebPage.parse_webPageNotModified($0) }
|
||||
dict[-1328464313] = { return Api.WebPage.parse_webPagePending($0) }
|
||||
dict[1355547603] = { return Api.WebPageAttribute.parse_webPageAttributeStickerSet($0) }
|
||||
dict[781501415] = { return Api.WebPageAttribute.parse_webPageAttributeStory($0) }
|
||||
dict[1421174295] = { return Api.WebPageAttribute.parse_webPageAttributeTheme($0) }
|
||||
dict[211046684] = { return Api.WebViewMessageSent.parse_webViewMessageSent($0) }
|
||||
@ -1351,7 +1352,7 @@ public extension Api {
|
||||
return parser(reader)
|
||||
}
|
||||
else {
|
||||
telegramApiLog("Type constructor \(String(UInt32(bitPattern: signature), radix: 16, uppercase: false)) not found")
|
||||
telegramApiLog("Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -478,13 +478,13 @@ public extension Api {
|
||||
}
|
||||
public extension Api {
|
||||
enum SponsoredMessage: TypeConstructorDescription {
|
||||
case sponsoredMessage(flags: Int32, randomId: Buffer, url: String, title: String, message: String, entities: [Api.MessageEntity]?, photo: Api.Photo?, buttonText: String, sponsorInfo: String?, additionalInfo: String?)
|
||||
case sponsoredMessage(flags: Int32, randomId: Buffer, url: String, title: String, message: String, entities: [Api.MessageEntity]?, photo: Api.Photo?, color: Api.PeerColor?, buttonText: String, sponsorInfo: String?, additionalInfo: String?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .sponsoredMessage(let flags, let randomId, let url, let title, let message, let entities, let photo, let buttonText, let sponsorInfo, let additionalInfo):
|
||||
case .sponsoredMessage(let flags, let randomId, let url, let title, let message, let entities, let photo, let color, let buttonText, let sponsorInfo, let additionalInfo):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1611532106)
|
||||
buffer.appendInt32(-1108478618)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeBytes(randomId, buffer: buffer, boxed: false)
|
||||
@ -497,6 +497,7 @@ public extension Api {
|
||||
item.serialize(buffer, true)
|
||||
}}
|
||||
if Int(flags) & Int(1 << 6) != 0 {photo!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 13) != 0 {color!.serialize(buffer, true)}
|
||||
serializeString(buttonText, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 7) != 0 {serializeString(sponsorInfo!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 8) != 0 {serializeString(additionalInfo!, buffer: buffer, boxed: false)}
|
||||
@ -506,8 +507,8 @@ public extension Api {
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .sponsoredMessage(let flags, let randomId, let url, let title, let message, let entities, let photo, let buttonText, let sponsorInfo, let additionalInfo):
|
||||
return ("sponsoredMessage", [("flags", flags as Any), ("randomId", randomId as Any), ("url", url as Any), ("title", title as Any), ("message", message as Any), ("entities", entities as Any), ("photo", photo as Any), ("buttonText", buttonText as Any), ("sponsorInfo", sponsorInfo as Any), ("additionalInfo", additionalInfo as Any)])
|
||||
case .sponsoredMessage(let flags, let randomId, let url, let title, let message, let entities, let photo, let color, let buttonText, let sponsorInfo, let additionalInfo):
|
||||
return ("sponsoredMessage", [("flags", flags as Any), ("randomId", randomId as Any), ("url", url as Any), ("title", title as Any), ("message", message as Any), ("entities", entities as Any), ("photo", photo as Any), ("color", color as Any), ("buttonText", buttonText as Any), ("sponsorInfo", sponsorInfo as Any), ("additionalInfo", additionalInfo as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,12 +531,16 @@ public extension Api {
|
||||
if Int(_1!) & Int(1 << 6) != 0 {if let signature = reader.readInt32() {
|
||||
_7 = Api.parse(reader, signature: signature) as? Api.Photo
|
||||
} }
|
||||
var _8: String?
|
||||
_8 = parseString(reader)
|
||||
var _8: Api.PeerColor?
|
||||
if Int(_1!) & Int(1 << 13) != 0 {if let signature = reader.readInt32() {
|
||||
_8 = Api.parse(reader, signature: signature) as? Api.PeerColor
|
||||
} }
|
||||
var _9: String?
|
||||
if Int(_1!) & Int(1 << 7) != 0 {_9 = parseString(reader) }
|
||||
_9 = parseString(reader)
|
||||
var _10: String?
|
||||
if Int(_1!) & Int(1 << 8) != 0 {_10 = parseString(reader) }
|
||||
if Int(_1!) & Int(1 << 7) != 0 {_10 = parseString(reader) }
|
||||
var _11: String?
|
||||
if Int(_1!) & Int(1 << 8) != 0 {_11 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
@ -543,11 +548,12 @@ public extension Api {
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 1) == 0) || _6 != nil
|
||||
let _c7 = (Int(_1!) & Int(1 << 6) == 0) || _7 != nil
|
||||
let _c8 = _8 != nil
|
||||
let _c9 = (Int(_1!) & Int(1 << 7) == 0) || _9 != nil
|
||||
let _c10 = (Int(_1!) & Int(1 << 8) == 0) || _10 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 {
|
||||
return Api.SponsoredMessage.sponsoredMessage(flags: _1!, randomId: _2!, url: _3!, title: _4!, message: _5!, entities: _6, photo: _7, buttonText: _8!, sponsorInfo: _9, additionalInfo: _10)
|
||||
let _c8 = (Int(_1!) & Int(1 << 13) == 0) || _8 != nil
|
||||
let _c9 = _9 != nil
|
||||
let _c10 = (Int(_1!) & Int(1 << 7) == 0) || _10 != nil
|
||||
let _c11 = (Int(_1!) & Int(1 << 8) == 0) || _11 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 {
|
||||
return Api.SponsoredMessage.sponsoredMessage(flags: _1!, randomId: _2!, url: _3!, title: _4!, message: _5!, entities: _6, photo: _7, color: _8, buttonText: _9!, sponsorInfo: _10, additionalInfo: _11)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -1,10 +1,22 @@
|
||||
public extension Api {
|
||||
indirect enum WebPageAttribute: TypeConstructorDescription {
|
||||
case webPageAttributeStickerSet(flags: Int32, stickers: [Api.Document])
|
||||
case webPageAttributeStory(flags: Int32, peer: Api.Peer, id: Int32, story: Api.StoryItem?)
|
||||
case webPageAttributeTheme(flags: Int32, documents: [Api.Document]?, settings: Api.ThemeSettings?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .webPageAttributeStickerSet(let flags, let stickers):
|
||||
if boxed {
|
||||
buffer.appendInt32(1355547603)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(stickers.count))
|
||||
for item in stickers {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .webPageAttributeStory(let flags, let peer, let id, let story):
|
||||
if boxed {
|
||||
buffer.appendInt32(781501415)
|
||||
@ -31,6 +43,8 @@ public extension Api {
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .webPageAttributeStickerSet(let flags, let stickers):
|
||||
return ("webPageAttributeStickerSet", [("flags", flags as Any), ("stickers", stickers as Any)])
|
||||
case .webPageAttributeStory(let flags, let peer, let id, let story):
|
||||
return ("webPageAttributeStory", [("flags", flags as Any), ("peer", peer as Any), ("id", id as Any), ("story", story as Any)])
|
||||
case .webPageAttributeTheme(let flags, let documents, let settings):
|
||||
@ -38,6 +52,22 @@ public extension Api {
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_webPageAttributeStickerSet(_ reader: BufferReader) -> WebPageAttribute? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: [Api.Document]?
|
||||
if let _ = reader.readInt32() {
|
||||
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.WebPageAttribute.webPageAttributeStickerSet(flags: _1!, stickers: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_webPageAttributeStory(_ reader: BufferReader) -> WebPageAttribute? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
@ -1330,43 +1360,3 @@ public extension Api.account {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.account {
|
||||
enum TmpPassword: TypeConstructorDescription {
|
||||
case tmpPassword(tmpPassword: Buffer, validUntil: Int32)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .tmpPassword(let tmpPassword, let validUntil):
|
||||
if boxed {
|
||||
buffer.appendInt32(-614138572)
|
||||
}
|
||||
serializeBytes(tmpPassword, buffer: buffer, boxed: false)
|
||||
serializeInt32(validUntil, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .tmpPassword(let tmpPassword, let validUntil):
|
||||
return ("tmpPassword", [("tmpPassword", tmpPassword as Any), ("validUntil", validUntil as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_tmpPassword(_ reader: BufferReader) -> TmpPassword? {
|
||||
var _1: Buffer?
|
||||
_1 = parseBytes(reader)
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.account.TmpPassword.tmpPassword(tmpPassword: _1!, validUntil: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,43 @@
|
||||
public extension Api.account {
|
||||
enum TmpPassword: TypeConstructorDescription {
|
||||
case tmpPassword(tmpPassword: Buffer, validUntil: Int32)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .tmpPassword(let tmpPassword, let validUntil):
|
||||
if boxed {
|
||||
buffer.appendInt32(-614138572)
|
||||
}
|
||||
serializeBytes(tmpPassword, buffer: buffer, boxed: false)
|
||||
serializeInt32(validUntil, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .tmpPassword(let tmpPassword, let validUntil):
|
||||
return ("tmpPassword", [("tmpPassword", tmpPassword as Any), ("validUntil", validUntil as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_tmpPassword(_ reader: BufferReader) -> TmpPassword? {
|
||||
var _1: Buffer?
|
||||
_1 = parseBytes(reader)
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.account.TmpPassword.tmpPassword(tmpPassword: _1!, validUntil: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.account {
|
||||
enum WallPapers: TypeConstructorDescription {
|
||||
case wallPapers(hash: Int64, wallpapers: [Api.WallPaper])
|
||||
|
@ -12,6 +12,17 @@ func telegramMediaWebpageAttributeFromApiWebpageAttribute(_ attribute: Api.WebPa
|
||||
files = documents.compactMap { telegramMediaFileFromApiDocument($0) }
|
||||
}
|
||||
return .theme(TelegraMediaWebpageThemeAttribute(files: files, settings: settings.flatMap { TelegramThemeSettings(apiThemeSettings: $0) }))
|
||||
case let .webPageAttributeStickerSet(apiFlags, stickers):
|
||||
var flags = TelegramMediaWebpageStickerPackAttribute.Flags()
|
||||
if (apiFlags & (1 << 0)) != 0 {
|
||||
flags.insert(.isEmoji)
|
||||
}
|
||||
if (apiFlags & (1 << 1)) != 0 {
|
||||
flags.insert(.isTemplate)
|
||||
}
|
||||
var files: [TelegramMediaFile] = []
|
||||
files = stickers.compactMap { telegramMediaFileFromApiDocument($0) }
|
||||
return .stickerPack(TelegramMediaWebpageStickerPackAttribute(flags: flags, files: files))
|
||||
case .webPageAttributeStory:
|
||||
return nil
|
||||
}
|
||||
|
@ -145,7 +145,11 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post
|
||||
if let mediaReference = mediaReference {
|
||||
finalMediaReference = mediaReference
|
||||
} else if file.isSticker {
|
||||
if let partialReference = file.partialReference {
|
||||
finalMediaReference = partialReference.mediaReference(file)
|
||||
} else {
|
||||
finalMediaReference = .standalone(media: file)
|
||||
}
|
||||
} else {
|
||||
finalMediaReference = .savedGif(media: file)
|
||||
}
|
||||
|
@ -3,16 +3,20 @@ import Postbox
|
||||
private enum TelegramMediaWebpageAttributeTypes: Int32 {
|
||||
case unsupported
|
||||
case theme
|
||||
case stickerPack
|
||||
}
|
||||
|
||||
public enum TelegramMediaWebpageAttribute: PostboxCoding, Equatable {
|
||||
case unsupported
|
||||
case theme(TelegraMediaWebpageThemeAttribute)
|
||||
case stickerPack(TelegramMediaWebpageStickerPackAttribute)
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
switch decoder.decodeInt32ForKey("r", orElse: 0) {
|
||||
case TelegramMediaWebpageAttributeTypes.theme.rawValue:
|
||||
self = .theme(decoder.decodeObjectForKey("a", decoder: { TelegraMediaWebpageThemeAttribute(decoder: $0) }) as! TelegraMediaWebpageThemeAttribute)
|
||||
case TelegramMediaWebpageAttributeTypes.stickerPack.rawValue:
|
||||
self = .stickerPack(decoder.decodeObjectForKey("a", decoder: { TelegramMediaWebpageStickerPackAttribute(decoder: $0) }) as! TelegramMediaWebpageStickerPackAttribute)
|
||||
default:
|
||||
self = .unsupported
|
||||
}
|
||||
@ -25,6 +29,9 @@ public enum TelegramMediaWebpageAttribute: PostboxCoding, Equatable {
|
||||
case let .theme(attribute):
|
||||
encoder.encodeInt32(TelegramMediaWebpageAttributeTypes.theme.rawValue, forKey: "r")
|
||||
encoder.encodeObject(attribute, forKey: "a")
|
||||
case let .stickerPack(attribute):
|
||||
encoder.encodeInt32(TelegramMediaWebpageAttributeTypes.stickerPack.rawValue, forKey: "r")
|
||||
encoder.encodeObject(attribute, forKey: "a")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,6 +76,57 @@ public final class TelegraMediaWebpageThemeAttribute: PostboxCoding, Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
public final class TelegramMediaWebpageStickerPackAttribute: PostboxCoding, Equatable {
|
||||
public struct Flags: OptionSet {
|
||||
public var rawValue: Int32
|
||||
|
||||
public init() {
|
||||
self.rawValue = 0
|
||||
}
|
||||
|
||||
public init(rawValue: Int32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static let isEmoji = Flags(rawValue: 1 << 0)
|
||||
public static let isTemplate = Flags(rawValue: 1 << 1)
|
||||
}
|
||||
|
||||
public static func == (lhs: TelegramMediaWebpageStickerPackAttribute, rhs: TelegramMediaWebpageStickerPackAttribute) -> Bool {
|
||||
if lhs.flags != rhs.flags {
|
||||
return false
|
||||
}
|
||||
if lhs.files.count != rhs.files.count {
|
||||
return false
|
||||
} else {
|
||||
for i in 0 ..< lhs.files.count {
|
||||
if !lhs.files[i].isEqual(to: rhs.files[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
public let flags: Flags
|
||||
public let files: [TelegramMediaFile]
|
||||
|
||||
public init(flags: Flags, files: [TelegramMediaFile]) {
|
||||
self.flags = flags
|
||||
self.files = files
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.flags = Flags(rawValue: decoder.decodeInt32ForKey("flags", orElse: 0))
|
||||
self.files = decoder.decodeObjectArrayForKey("files")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt32(self.flags.rawValue, forKey: "flags")
|
||||
encoder.encodeObjectArray(self.files, forKey: "files")
|
||||
}
|
||||
}
|
||||
|
||||
public final class TelegramMediaWebpageLoadedContent: PostboxCoding, Equatable {
|
||||
public let url: String
|
||||
public let displayUrl: String
|
||||
|
@ -12,6 +12,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
case text
|
||||
case textEntities
|
||||
case media
|
||||
case color
|
||||
case backgroundEmojiId
|
||||
case url
|
||||
case buttonText
|
||||
case sponsorInfo
|
||||
@ -30,6 +32,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
public let text: String
|
||||
public let textEntities: [MessageTextEntity]
|
||||
public let media: [Media]
|
||||
public let color: PeerNameColor?
|
||||
public let backgroundEmojiId: Int64?
|
||||
public let url: String
|
||||
public let buttonText: String
|
||||
public let sponsorInfo: String?
|
||||
@ -43,6 +47,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
text: String,
|
||||
textEntities: [MessageTextEntity],
|
||||
media: [Media],
|
||||
color: PeerNameColor?,
|
||||
backgroundEmojiId: Int64?,
|
||||
url: String,
|
||||
buttonText: String,
|
||||
sponsorInfo: String?,
|
||||
@ -55,6 +61,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
self.text = text
|
||||
self.textEntities = textEntities
|
||||
self.media = media
|
||||
self.color = color
|
||||
self.backgroundEmojiId = backgroundEmojiId
|
||||
self.url = url
|
||||
self.buttonText = buttonText
|
||||
self.sponsorInfo = sponsorInfo
|
||||
@ -81,6 +89,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
self.media = mediaData.compactMap { data -> Media? in
|
||||
return PostboxDecoder(buffer: MemoryBuffer(data: data)).decodeRootObject() as? Media
|
||||
}
|
||||
self.color = try container.decodeIfPresent(Int32.self, forKey: .color).flatMap { PeerNameColor(rawValue: $0) }
|
||||
self.backgroundEmojiId = try container.decodeIfPresent(Int64.self, forKey: .backgroundEmojiId)
|
||||
|
||||
self.url = try container.decode(String.self, forKey: .url)
|
||||
self.buttonText = try container.decode(String.self, forKey: .buttonText)
|
||||
@ -107,6 +117,9 @@ private class AdMessagesHistoryContextImpl {
|
||||
}
|
||||
try container.encode(mediaData, forKey: .media)
|
||||
|
||||
try container.encodeIfPresent(self.color?.rawValue, forKey: .color)
|
||||
try container.encodeIfPresent(self.backgroundEmojiId, forKey: .backgroundEmojiId)
|
||||
|
||||
try container.encode(self.url, forKey: .url)
|
||||
try container.encode(self.buttonText, forKey: .buttonText)
|
||||
|
||||
@ -197,8 +210,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
defaultBannedRights: nil,
|
||||
usernames: [],
|
||||
storiesHidden: nil,
|
||||
nameColor: .blue,
|
||||
backgroundEmojiId: nil,
|
||||
nameColor: self.color ?? .blue,
|
||||
backgroundEmojiId: self.backgroundEmojiId,
|
||||
profileColor: nil,
|
||||
profileBackgroundEmojiId: nil,
|
||||
emojiStatus: nil,
|
||||
@ -408,7 +421,7 @@ private class AdMessagesHistoryContextImpl {
|
||||
|
||||
for message in messages {
|
||||
switch message {
|
||||
case let .sponsoredMessage(flags, randomId, url, title, message, entities, photo, buttonText, sponsorInfo, additionalInfo):
|
||||
case let .sponsoredMessage(flags, randomId, url, title, message, entities, photo, color, buttonText, sponsorInfo, additionalInfo):
|
||||
var parsedEntities: [MessageTextEntity] = []
|
||||
if let entities = entities {
|
||||
parsedEntities = messageTextEntitiesFromApiEntities(entities)
|
||||
@ -417,8 +430,17 @@ private class AdMessagesHistoryContextImpl {
|
||||
let isRecommended = (flags & (1 << 5)) != 0
|
||||
let canReport = (flags & (1 << 12)) != 0
|
||||
|
||||
let photo = photo.flatMap { telegramMediaImageFromApiPhoto($0) }
|
||||
var nameColorIndex: Int32?
|
||||
var backgroundEmojiId: Int64?
|
||||
if let color = color {
|
||||
switch color {
|
||||
case let .peerColor(_, color, backgroundEmojiIdValue):
|
||||
nameColorIndex = color
|
||||
backgroundEmojiId = backgroundEmojiIdValue
|
||||
}
|
||||
}
|
||||
|
||||
let photo = photo.flatMap { telegramMediaImageFromApiPhoto($0) }
|
||||
parsedMessages.append(CachedMessage(
|
||||
opaqueId: randomId.makeData(),
|
||||
messageType: isRecommended ? .recommended : .sponsored,
|
||||
@ -426,6 +448,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
text: message,
|
||||
textEntities: parsedEntities,
|
||||
media: photo.flatMap { [$0] } ?? [],
|
||||
color: nameColorIndex.flatMap { PeerNameColor(rawValue: $0) },
|
||||
backgroundEmojiId: backgroundEmojiId,
|
||||
url: url,
|
||||
buttonText: buttonText,
|
||||
sponsorInfo: sponsorInfo,
|
||||
|
@ -466,6 +466,8 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent
|
||||
actionTitle = item.presentationData.strings.Conversation_BoostChannel
|
||||
case "telegram_group_boost":
|
||||
actionTitle = item.presentationData.strings.Conversation_BoostChannel
|
||||
case "telegram_stickerset":
|
||||
actionTitle = item.presentationData.strings.Conversation_ViewStickers
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user