InvertMediaAttribute

This commit is contained in:
Mikhail Filimonov 2024-05-17 09:04:51 +04:00
parent 62ff5b04ec
commit 63c36a394e
6 changed files with 46 additions and 0 deletions

View File

@ -219,6 +219,7 @@ private var declaredEncodables: Void = {
declareEncodable(TelegramMediaGiveaway.self, f: { TelegramMediaGiveaway(decoder: $0) })
declareEncodable(TelegramMediaGiveawayResults.self, f: { TelegramMediaGiveawayResults(decoder: $0) })
declareEncodable(WebpagePreviewMessageAttribute.self, f: { WebpagePreviewMessageAttribute(decoder: $0) })
declareEncodable(InvertMediaMessageAttribute.self, f: { InvertMediaMessageAttribute(decoder: $0) })
declareEncodable(DerivedDataMessageAttribute.self, f: { DerivedDataMessageAttribute(decoder: $0) })
declareEncodable(TelegramApplicationIcons.self, f: { TelegramApplicationIcons(decoder: $0) })
declareEncodable(OutgoingQuickReplyMessageAttribute.self, f: { OutgoingQuickReplyMessageAttribute(decoder: $0) })

View File

@ -781,6 +781,12 @@ extension StoreMessage {
attributes.append(WebpagePreviewMessageAttribute(leadingPreview: leadingPreview, forceLargeMedia: webpageAttributes.forceLargeMedia, isManuallyAdded: webpageAttributes.isManuallyAdded, isSafe: webpageAttributes.isSafe))
}
}
let leadingPreview = (flags & (1 << 27)) != 0
if leadingPreview {
attributes.append(InvertMediaMessageAttribute())
}
}
}

View File

@ -0,0 +1,23 @@
import Foundation
import Postbox
import TelegramApi
public class InvertMediaMessageAttribute: MessageAttribute, Equatable {
public let associatedPeerIds: [PeerId] = []
public let associatedMediaIds: [MediaId] = []
public init() {
}
required public init(decoder: PostboxDecoder) {
}
public func encode(_ encoder: PostboxEncoder) {
}
public static func ==(lhs: InvertMediaMessageAttribute, rhs: InvertMediaMessageAttribute) -> Bool {
return true
}
}

View File

@ -248,6 +248,8 @@ private func filterMessageAttributesForOutgoingMessage(_ attributes: [MessageAtt
return true
case _ as WebpagePreviewMessageAttribute:
return true
case _ as InvertMediaMessageAttribute:
return true
case _ as EffectMessageAttribute:
return true
default:

View File

@ -1328,6 +1328,9 @@ public final class PendingMessageManager {
flags |= 1 << 16
}
}
if message.invertMedia {
flags |= 1 << 16
}
var quickReplyShortcut: Api.InputQuickReplyShortcut?
if let quickReply {
@ -1409,6 +1412,9 @@ public final class PendingMessageManager {
flags |= 1 << 16
}
}
if message.invertMedia {
flags |= 1 << 16
}
var quickReplyShortcut: Api.InputQuickReplyShortcut?
if let quickReply {

View File

@ -523,6 +523,14 @@ public extension Message {
}
return nil
}
var invertMedia: Bool {
for attribute in self.attributes {
if let _ = attribute as? InvertMediaMessageAttribute {
return true
}
}
return false
}
}
public extension Message {