Update invoice API

This commit is contained in:
Ali 2022-11-01 20:24:01 +04:00
parent efe0566b79
commit 5a445389ba
30 changed files with 177 additions and 77 deletions

View File

@ -8186,16 +8186,16 @@ Sorry for the inconvenience.";
"ChatList.DeleteTopicConfirmationText" = "This will delete the topic with all its messages"; "ChatList.DeleteTopicConfirmationText" = "This will delete the topic with all its messages";
"ChatList.DeleteTopicConfirmationAction" = "Delete Topic"; "ChatList.DeleteTopicConfirmationAction" = "Delete Topic";
"Notification.TopicCreated" = "Topic created"; "Notification.ForumTopicCreated" = "Topic created";
"Notification.TopicClosed" = "Topic closed"; "Notification.ForumTopicClosed" = "Topic closed";
"Notification.TopicReopened" = "Topic reopened"; "Notification.ForumTopicReopened" = "Topic reopened";
"Notification.TopicClosedAuthor" = "%1$@ closed topic"; "Notification.ForumTopicClosedAuthor" = "%1$@ closed topic";
"Notification.TopicReopenedAuthor" = "%1$@ reopened topic"; "Notification.ForumTopicReopenedAuthor" = "%1$@ reopened topic";
"Notification.TopicRenamed" = "Topic renamed to \"%1$@\""; "Notification.ForumTopicRenamed" = "Topic renamed to \"%1$@\"";
"Notification.TopicRenamedAuthor" = "%1$@ changed the topic title to \"%2$@\""; "Notification.ForumTopicRenamedAuthor" = "%1$@ changed the topic title to \"%2$@\"";
"Notification.TopicIconChanged" = "Topic icon changed to %1$@"; "Notification.ForumTopicIconChanged" = "Topic icon changed to %1$@";
"Notification.TopicIconChangedAuthor" = "%1$@ changed the topic icon to %2$@"; "Notification.ForumTopicIconChangedAuthor" = "%1$@ changed the topic icon to %2$@";
"Notification.TopicRenamedIconChangedAuthor" = "%1$@ changed the topic title and icon to %2$@ %3$@"; "Notification.ForumTopicRenamedIconChangedAuthor" = "%1$@ changed the topic title and icon to %2$@ %3$@";
"Notification.OverviewTopicCreated" = "%1$@ %2$@ was created"; "Notification.OverviewTopicCreated" = "%1$@ %2$@ was created";
"Notification.OverviewTopicClosed" = "%1$@ closed %2$@ %3$@"; "Notification.OverviewTopicClosed" = "%1$@ closed %2$@ %3$@";
"Notification.OverviewTopicReopened" = "%1$@ reopened %2$@ %3$@"; "Notification.OverviewTopicReopened" = "%1$@ reopened %2$@ %3$@";

View File

@ -11,6 +11,7 @@ swift_library(
], ],
deps = [ deps = [
"//submodules/TelegramCore:TelegramCore", "//submodules/TelegramCore:TelegramCore",
"//submodules/Postbox:Postbox",
], ],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",

View File

@ -1,10 +1,20 @@
import Foundation import Foundation
import TelegramCore import TelegramCore
import Postbox
public extension Message {
func isRestricted(platform: String, contentSettings: ContentSettings) -> Bool {
if let attribute = self.restrictedContentAttribute {
return attribute.platformText(platform: platform, contentSettings: contentSettings) != nil
}
return false
}
}
public extension RestrictedContentMessageAttribute { public extension RestrictedContentMessageAttribute {
func platformText(platform: String, contentSettings: ContentSettings) -> String? { func platformText(platform: String, contentSettings: ContentSettings) -> String? {
for rule in self.rules { for rule in self.rules {
if rule.platform == "all" || rule.platform == "ios" { if rule.platform == "all" || rule.platform == "ios" || contentSettings.addContentRestrictionReasons.contains(rule.platform) {
if !contentSettings.ignoreContentRestrictionReasons.contains(rule.reason) { if !contentSettings.ignoreContentRestrictionReasons.contains(rule.reason) {
return rule.text return rule.text
} }

View File

@ -5364,16 +5364,17 @@ public extension Api.functions.messages {
} }
} }
public extension Api.functions.messages { public extension Api.functions.messages {
static func prolongWebView(flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, queryId: Int64, replyToMsgId: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) { static func prolongWebView(flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, queryId: Int64, replyToMsgId: Int32?, topMsgId: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(-362824498) buffer.appendInt32(2146648841)
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true) peer.serialize(buffer, true)
bot.serialize(buffer, true) bot.serialize(buffer, true)
serializeInt64(queryId, buffer: buffer, boxed: false) serializeInt64(queryId, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 9) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)} if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)}
return (FunctionDescription(name: "messages.prolongWebView", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("bot", String(describing: bot)), ("queryId", String(describing: queryId)), ("replyToMsgId", String(describing: replyToMsgId)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in return (FunctionDescription(name: "messages.prolongWebView", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("bot", String(describing: bot)), ("queryId", String(describing: queryId)), ("replyToMsgId", String(describing: replyToMsgId)), ("topMsgId", String(describing: topMsgId)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.Bool? var result: Api.Bool?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {
@ -5718,9 +5719,9 @@ public extension Api.functions.messages {
} }
} }
public extension Api.functions.messages { public extension Api.functions.messages {
static func requestWebView(flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, url: String?, startParam: String?, themeParams: Api.DataJSON?, platform: String, replyToMsgId: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.WebViewResult>) { static func requestWebView(flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, url: String?, startParam: String?, themeParams: Api.DataJSON?, platform: String, replyToMsgId: Int32?, topMsgId: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.WebViewResult>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(-58219204) buffer.appendInt32(395003915)
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true) peer.serialize(buffer, true)
bot.serialize(buffer, true) bot.serialize(buffer, true)
@ -5729,8 +5730,9 @@ public extension Api.functions.messages {
if Int(flags) & Int(1 << 2) != 0 {themeParams!.serialize(buffer, true)} if Int(flags) & Int(1 << 2) != 0 {themeParams!.serialize(buffer, true)}
serializeString(platform, buffer: buffer, boxed: false) serializeString(platform, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 9) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)} if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)}
return (FunctionDescription(name: "messages.requestWebView", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("bot", String(describing: bot)), ("url", String(describing: url)), ("startParam", String(describing: startParam)), ("themeParams", String(describing: themeParams)), ("platform", String(describing: platform)), ("replyToMsgId", String(describing: replyToMsgId)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.WebViewResult? in return (FunctionDescription(name: "messages.requestWebView", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("bot", String(describing: bot)), ("url", String(describing: url)), ("startParam", String(describing: startParam)), ("themeParams", String(describing: themeParams)), ("platform", String(describing: platform)), ("replyToMsgId", String(describing: replyToMsgId)), ("topMsgId", String(describing: topMsgId)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.WebViewResult? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.WebViewResult? var result: Api.WebViewResult?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {
@ -6542,11 +6544,13 @@ public extension Api.functions.messages {
} }
} }
public extension Api.functions.messages { public extension Api.functions.messages {
static func unpinAllMessages(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.AffectedHistory>) { static func unpinAllMessages(flags: Int32, peer: Api.InputPeer, topMsgId: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.AffectedHistory>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(-265962357) buffer.appendInt32(-299714136)
serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true) peer.serialize(buffer, true)
return (FunctionDescription(name: "messages.unpinAllMessages", parameters: [("peer", String(describing: peer))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.AffectedHistory? in if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
return (FunctionDescription(name: "messages.unpinAllMessages", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("topMsgId", String(describing: topMsgId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.AffectedHistory? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.messages.AffectedHistory? var result: Api.messages.AffectedHistory?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {

View File

@ -478,7 +478,7 @@ extension ChatContextResultMessage {
if let replyMarkup = replyMarkup { if let replyMarkup = replyMarkup {
parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup) parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup)
} }
self = .invoice(media: TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: nil, currency: currency, totalAmount: totalAmount, startParam: "", extendedMedia: nil, flags: parsedFlags), replyMarkup: parsedReplyMarkup) self = .invoice(media: TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: nil, currency: currency, totalAmount: totalAmount, startParam: "", extendedMedia: nil, flags: parsedFlags, version: TelegramMediaInvoice.lastVersion), replyMarkup: parsedReplyMarkup)
} }
} }
} }

View File

@ -336,7 +336,7 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI
extendedMedia = nil extendedMedia = nil
} }
return (TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: receiptMsgId.flatMap { MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) }, currency: currency, totalAmount: totalAmount, startParam: startParam, extendedMedia: extendedMedia, flags: parsedFlags), nil, nil) return (TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: receiptMsgId.flatMap { MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) }, currency: currency, totalAmount: totalAmount, startParam: startParam, extendedMedia: extendedMedia, flags: parsedFlags, version: TelegramMediaInvoice.lastVersion), nil, nil)
case let .messageMediaPoll(poll, results): case let .messageMediaPoll(poll, results):
switch poll { switch poll {
case let .poll(id, flags, question, answers, closePeriod, _): case let .poll(id, flags, question, answers, closePeriod, _):

View File

@ -4,22 +4,30 @@ import TelegramApi
import SwiftSignalKit import SwiftSignalKit
public struct ContentSettings: Equatable { public struct ContentSettings: Equatable {
public static var `default` = ContentSettings(ignoreContentRestrictionReasons: []) public static var `default` = ContentSettings(ignoreContentRestrictionReasons: [], addContentRestrictionReasons: [])
public var ignoreContentRestrictionReasons: Set<String> public var ignoreContentRestrictionReasons: Set<String>
public var addContentRestrictionReasons: [String]
public init(ignoreContentRestrictionReasons: Set<String>) { public init(ignoreContentRestrictionReasons: Set<String>, addContentRestrictionReasons: [String]) {
self.ignoreContentRestrictionReasons = ignoreContentRestrictionReasons self.ignoreContentRestrictionReasons = ignoreContentRestrictionReasons
self.addContentRestrictionReasons = addContentRestrictionReasons
} }
} }
extension ContentSettings { extension ContentSettings {
init(appConfiguration: AppConfiguration) { init(appConfiguration: AppConfiguration) {
var reasons: [String] = [] var reasons: [String] = []
if let data = appConfiguration.data, let reasonsData = data["ignore_restriction_reasons"] as? [String] { var addContentRestrictionReasons: [String] = []
reasons = reasonsData if let data = appConfiguration.data {
if let reasonsData = data["ignore_restriction_reasons"] as? [String] {
reasons = reasonsData
}
if let addContentRestrictionReasonsData = data["restriction_add_platforms"] as? [String] {
addContentRestrictionReasons = addContentRestrictionReasonsData
}
} }
self.init(ignoreContentRestrictionReasons: Set(reasons)) self.init(ignoreContentRestrictionReasons: Set(reasons), addContentRestrictionReasons: addContentRestrictionReasons)
} }
} }

View File

@ -17,7 +17,7 @@ public struct TelegramMediaInvoiceFlags: OptionSet {
} }
public enum TelegramExtendedMedia: PostboxCoding, Equatable { public enum TelegramExtendedMedia: PostboxCoding, Equatable {
public static func == (lhs: TelegramExtendedMedia, rhs: TelegramExtendedMedia) -> Bool { public static func ==(lhs: TelegramExtendedMedia, rhs: TelegramExtendedMedia) -> Bool {
switch lhs { switch lhs {
case let .preview(lhsDimensions, lhsImmediateThumbnailData, lhsVideoDuration): case let .preview(lhsDimensions, lhsImmediateThumbnailData, lhsVideoDuration):
if case let .preview(rhsDimensions, rhsImmediateThumbnailData, rhsVideoDuration) = rhs, lhsDimensions == rhsDimensions, lhsImmediateThumbnailData == rhsImmediateThumbnailData, lhsVideoDuration == rhsVideoDuration { if case let .preview(rhsDimensions, rhsImmediateThumbnailData, rhsVideoDuration) = rhs, lhsDimensions == rhsDimensions, lhsImmediateThumbnailData == rhsImmediateThumbnailData, lhsVideoDuration == rhsVideoDuration {
@ -88,6 +88,8 @@ public enum TelegramExtendedMedia: PostboxCoding, Equatable {
} }
public final class TelegramMediaInvoice: Media { public final class TelegramMediaInvoice: Media {
public static let lastVersion: Int32 = 1
public var peerIds: [PeerId] = [] public var peerIds: [PeerId] = []
public var id: MediaId? = nil public var id: MediaId? = nil
@ -102,7 +104,9 @@ public final class TelegramMediaInvoice: Media {
public let flags: TelegramMediaInvoiceFlags public let flags: TelegramMediaInvoiceFlags
public let extendedMedia: TelegramExtendedMedia? public let extendedMedia: TelegramExtendedMedia?
public init(title: String, description: String, photo: TelegramMediaWebFile?, receiptMessageId: MessageId?, currency: String, totalAmount: Int64, startParam: String, extendedMedia: TelegramExtendedMedia?, flags: TelegramMediaInvoiceFlags) { public let version: Int32
public init(title: String, description: String, photo: TelegramMediaWebFile?, receiptMessageId: MessageId?, currency: String, totalAmount: Int64, startParam: String, extendedMedia: TelegramExtendedMedia?, flags: TelegramMediaInvoiceFlags, version: Int32) {
self.title = title self.title = title
self.description = description self.description = description
self.photo = photo self.photo = photo
@ -112,6 +116,7 @@ public final class TelegramMediaInvoice: Media {
self.startParam = startParam self.startParam = startParam
self.flags = flags self.flags = flags
self.extendedMedia = extendedMedia self.extendedMedia = extendedMedia
self.version = version
} }
public init(decoder: PostboxDecoder) { public init(decoder: PostboxDecoder) {
@ -129,6 +134,8 @@ public final class TelegramMediaInvoice: Media {
} else { } else {
self.receiptMessageId = nil self.receiptMessageId = nil
} }
self.version = decoder.decodeInt32ForKey("vrs", orElse: 0)
} }
public func encode(_ encoder: PostboxEncoder) { public func encode(_ encoder: PostboxEncoder) {
@ -160,6 +167,8 @@ public final class TelegramMediaInvoice: Media {
encoder.encodeNil(forKey: "r.n") encoder.encodeNil(forKey: "r.n")
encoder.encodeNil(forKey: "r.i") encoder.encodeNil(forKey: "r.i")
} }
encoder.encodeInt32(self.version, forKey: "vrs")
} }
public func isEqual(to other: Media) -> Bool { public func isEqual(to other: Media) -> Bool {
@ -199,6 +208,10 @@ public final class TelegramMediaInvoice: Media {
return false return false
} }
if self.version != other.version {
return false
}
return true return true
} }
@ -216,6 +229,8 @@ public final class TelegramMediaInvoice: Media {
totalAmount: self.totalAmount, totalAmount: self.totalAmount,
startParam: self.startParam, startParam: self.startParam,
extendedMedia: extendedMedia, extendedMedia: extendedMedia,
flags: self.flags) flags: self.flags,
version: self.version
)
} }
} }

View File

@ -57,10 +57,10 @@ public enum RequestWebViewError {
case generic case generic
} }
private func keepWebViewSignal(network: Network, stateManager: AccountStateManager, flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, queryId: Int64, replyToMessageId: MessageId?, sendAs: Api.InputPeer?) -> Signal<Never, KeepWebViewError> { private func keepWebViewSignal(network: Network, stateManager: AccountStateManager, flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, queryId: Int64, replyToMessageId: MessageId?, threadId: Int64?, sendAs: Api.InputPeer?) -> Signal<Never, KeepWebViewError> {
let signal = Signal<Never, KeepWebViewError> { subscriber in let signal = Signal<Never, KeepWebViewError> { subscriber in
let poll = Signal<Never, KeepWebViewError> { subscriber in let poll = Signal<Never, KeepWebViewError> { subscriber in
let signal: Signal<Never, KeepWebViewError> = network.request(Api.functions.messages.prolongWebView(flags: flags, peer: peer, bot: bot, queryId: queryId, replyToMsgId: replyToMessageId?.id, sendAs: sendAs)) let signal: Signal<Never, KeepWebViewError> = network.request(Api.functions.messages.prolongWebView(flags: flags, peer: peer, bot: bot, queryId: queryId, replyToMsgId: replyToMessageId?.id, topMsgId: threadId.flatMap(Int32.init(clamping:)), sendAs: sendAs))
|> mapError { _ -> KeepWebViewError in |> mapError { _ -> KeepWebViewError in
return .generic return .generic
} }
@ -99,7 +99,7 @@ private func keepWebViewSignal(network: Network, stateManager: AccountStateManag
return signal return signal
} }
func _internal_requestWebView(postbox: Postbox, network: Network, stateManager: AccountStateManager, peerId: PeerId, botId: PeerId, url: String?, payload: String?, themeParams: [String: Any]?, fromMenu: Bool, replyToMessageId: MessageId?) -> Signal<RequestWebViewResult, RequestWebViewError> { func _internal_requestWebView(postbox: Postbox, network: Network, stateManager: AccountStateManager, peerId: PeerId, botId: PeerId, url: String?, payload: String?, themeParams: [String: Any]?, fromMenu: Bool, replyToMessageId: MessageId?, threadId: Int64?) -> Signal<RequestWebViewResult, RequestWebViewError> {
var serializedThemeParams: Api.DataJSON? var serializedThemeParams: Api.DataJSON?
if let themeParams = themeParams, let data = try? JSONSerialization.data(withJSONObject: themeParams, options: []), let dataString = String(data: data, encoding: .utf8) { if let themeParams = themeParams, let data = try? JSONSerialization.data(withJSONObject: themeParams, options: []), let dataString = String(data: data, encoding: .utf8) {
serializedThemeParams = .dataJSON(data: dataString) serializedThemeParams = .dataJSON(data: dataString)
@ -128,17 +128,20 @@ func _internal_requestWebView(postbox: Postbox, network: Network, stateManager:
if fromMenu { if fromMenu {
flags |= (1 << 4) flags |= (1 << 4)
} }
if threadId != nil {
flags |= (1 << 9)
}
// if _ { // if _ {
// flags |= (1 << 13) // flags |= (1 << 13)
// } // }
return network.request(Api.functions.messages.requestWebView(flags: flags, peer: inputPeer, bot: inputBot, url: url, startParam: payload, themeParams: serializedThemeParams, platform: botWebViewPlatform, replyToMsgId: replyToMsgId, sendAs: nil)) return network.request(Api.functions.messages.requestWebView(flags: flags, peer: inputPeer, bot: inputBot, url: url, startParam: payload, themeParams: serializedThemeParams, platform: botWebViewPlatform, replyToMsgId: replyToMsgId, topMsgId: threadId.flatMap(Int32.init(clamping:)), sendAs: nil))
|> mapError { _ -> RequestWebViewError in |> mapError { _ -> RequestWebViewError in
return .generic return .generic
} }
|> mapToSignal { result -> Signal<RequestWebViewResult, RequestWebViewError> in |> mapToSignal { result -> Signal<RequestWebViewResult, RequestWebViewError> in
switch result { switch result {
case let .webViewResultUrl(queryId, url): case let .webViewResultUrl(queryId, url):
return .single(RequestWebViewResult(queryId: queryId, url: url, keepAliveSignal: keepWebViewSignal(network: network, stateManager: stateManager, flags: flags, peer: inputPeer, bot: inputBot, queryId: queryId, replyToMessageId: replyToMessageId, sendAs: nil))) return .single(RequestWebViewResult(queryId: queryId, url: url, keepAliveSignal: keepWebViewSignal(network: network, stateManager: stateManager, flags: flags, peer: inputPeer, bot: inputBot, queryId: queryId, replyToMessageId: replyToMessageId, threadId: threadId, sendAs: nil)))
} }
} }
} }

View File

@ -106,8 +106,8 @@ public extension TelegramEngine {
return _internal_requestUpdatePinnedMessage(account: self.account, peerId: peerId, update: update) return _internal_requestUpdatePinnedMessage(account: self.account, peerId: peerId, update: update)
} }
public func requestUnpinAllMessages(peerId: PeerId) -> Signal<Never, UpdatePinnedMessageError> { public func requestUnpinAllMessages(peerId: PeerId, threadId: Int64?) -> Signal<Never, UpdatePinnedMessageError> {
return _internal_requestUnpinAllMessages(account: self.account, peerId: peerId) return _internal_requestUnpinAllMessages(account: self.account, peerId: peerId, threadId: threadId)
} }
public func fetchChannelReplyThreadMessage(messageId: MessageId, atMessageId: MessageId?) -> Signal<ChatReplyThreadMessage, FetchChannelReplyThreadMessageError> { public func fetchChannelReplyThreadMessage(messageId: MessageId, atMessageId: MessageId?) -> Signal<ChatReplyThreadMessage, FetchChannelReplyThreadMessageError> {
@ -382,8 +382,8 @@ public extension TelegramEngine {
return _internal_rateAudioTranscription(postbox: self.account.postbox, network: self.account.network, messageId: messageId, id: id, isGood: isGood) return _internal_rateAudioTranscription(postbox: self.account.postbox, network: self.account.network, messageId: messageId, id: id, isGood: isGood)
} }
public func requestWebView(peerId: PeerId, botId: PeerId, url: String?, payload: String?, themeParams: [String: Any]?, fromMenu: Bool, replyToMessageId: MessageId?) -> Signal<RequestWebViewResult, RequestWebViewError> { public func requestWebView(peerId: PeerId, botId: PeerId, url: String?, payload: String?, themeParams: [String: Any]?, fromMenu: Bool, replyToMessageId: MessageId?, threadId: Int64?) -> Signal<RequestWebViewResult, RequestWebViewError> {
return _internal_requestWebView(postbox: self.account.postbox, network: self.account.network, stateManager: self.account.stateManager, peerId: peerId, botId: botId, url: url, payload: payload, themeParams: themeParams, fromMenu: fromMenu, replyToMessageId: replyToMessageId) return _internal_requestWebView(postbox: self.account.postbox, network: self.account.network, stateManager: self.account.stateManager, peerId: peerId, botId: botId, url: url, payload: payload, themeParams: themeParams, fromMenu: fromMenu, replyToMessageId: replyToMessageId, threadId: threadId)
} }
public func requestSimpleWebView(botId: PeerId, url: String, themeParams: [String: Any]?) -> Signal<String, RequestSimpleWebViewError> { public func requestSimpleWebView(botId: PeerId, url: String, themeParams: [String: Any]?) -> Signal<String, RequestSimpleWebViewError> {

View File

@ -109,7 +109,7 @@ func _internal_requestUpdatePinnedMessage(account: Account, peerId: PeerId, upda
} }
} }
func _internal_requestUnpinAllMessages(account: Account, peerId: PeerId) -> Signal<Never, UpdatePinnedMessageError> { func _internal_requestUnpinAllMessages(account: Account, peerId: PeerId, threadId: Int64?) -> Signal<Never, UpdatePinnedMessageError> {
return account.postbox.transaction { transaction -> (Peer?, CachedPeerData?) in return account.postbox.transaction { transaction -> (Peer?, CachedPeerData?) in
return (transaction.getPeer(peerId), transaction.getPeerCachedData(peerId: peerId)) return (transaction.getPeer(peerId), transaction.getPeerCachedData(peerId: peerId))
} }
@ -147,7 +147,11 @@ func _internal_requestUnpinAllMessages(account: Account, peerId: PeerId) -> Sign
case restart case restart
} }
let request: Signal<Never, InternalError> = account.network.request(Api.functions.messages.unpinAllMessages(peer: inputPeer)) var flags: Int32 = 0
if threadId != nil {
flags |= (1 << 0)
}
let request: Signal<Never, InternalError> = account.network.request(Api.functions.messages.unpinAllMessages(flags: flags, peer: inputPeer, topMsgId: threadId.flatMap(Int32.init(clamping:))))
|> mapError { error -> InternalError in |> mapError { error -> InternalError in
return .error(error.errorDescription) return .error(error.errorDescription)
} }

View File

@ -239,7 +239,7 @@ func _internal_fetchBotPaymentInvoice(postbox: Postbox, network: Network, source
parsedFlags.insert(.shippingAddressRequested) parsedFlags.insert(.shippingAddressRequested)
} }
return TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: nil, currency: parsedInvoice.currency, totalAmount: 0, startParam: "", extendedMedia: nil, flags: parsedFlags) return TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: nil, currency: parsedInvoice.currency, totalAmount: 0, startParam: "", extendedMedia: nil, flags: parsedFlags, version: TelegramMediaInvoice.lastVersion)
} }
} }
|> mapError { _ -> BotPaymentFormRequestError in } |> mapError { _ -> BotPaymentFormRequestError in }
@ -613,7 +613,8 @@ func _internal_requestBotPaymentReceipt(account: Account, messageId: MessageId)
totalAmount: totalAmount, totalAmount: totalAmount,
startParam: "", startParam: "",
extendedMedia: nil, extendedMedia: nil,
flags: [] flags: [],
version: TelegramMediaInvoice.lastVersion
) )
let botPaymentId = PeerId.init(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)) let botPaymentId = PeerId.init(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId))

View File

@ -355,6 +355,15 @@ public extension Message {
} }
return nil return nil
} }
var restrictedContentAttribute: RestrictedContentMessageAttribute? {
for attribute in self.attributes {
if let attribute = attribute as? RestrictedContentMessageAttribute {
return attribute
}
}
return nil
}
} }
public func _internal_parseMediaAttachment(data: Data) -> Media? { public func _internal_parseMediaAttachment(data: Data) -> Media? {

View File

@ -684,7 +684,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
let maybeFileId = iconFileId ?? 0 let maybeFileId = iconFileId ?? 0
attributedString = addAttributesToStringWithRanges(strings.Notification_OverviewTopicCreated(".", title)._tuple, body: bodyAttributes, argumentAttributes: [0: MarkdownAttributeSet(font: titleFont, textColor: primaryTextColor, additionalAttributes: [ChatTextInputAttributes.customEmoji.rawValue: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: maybeFileId, file: nil, topicInfo: maybeFileId == 0 ? EngineMessageHistoryThread.Info(title: title, icon: nil, iconColor: iconColor) : nil)])]) attributedString = addAttributesToStringWithRanges(strings.Notification_OverviewTopicCreated(".", title)._tuple, body: bodyAttributes, argumentAttributes: [0: MarkdownAttributeSet(font: titleFont, textColor: primaryTextColor, additionalAttributes: [ChatTextInputAttributes.customEmoji.rawValue: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: maybeFileId, file: nil, topicInfo: maybeFileId == 0 ? EngineMessageHistoryThread.Info(title: title, icon: nil, iconColor: iconColor) : nil)])])
} else { } else {
attributedString = NSAttributedString(string: strings.Notification_TopicCreated, font: titleFont, textColor: primaryTextColor) attributedString = NSAttributedString(string: strings.Notification_ForumTopicCreated, font: titleFont, textColor: primaryTextColor)
} }
case let .topicEdited(components): case let .topicEdited(components):
if let isClosed = components.compactMap({ item -> Bool? in if let isClosed = components.compactMap({ item -> Bool? in
@ -712,16 +712,16 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
} }
} else { } else {
if isClosed { if isClosed {
attributedString = addAttributesToStringWithRanges(strings.Notification_TopicClosedAuthor(EnginePeer.user(user).displayTitle(strings: strings, displayOrder: nameDisplayOrder))._tuple, body: bodyAttributes, argumentAttributes: [0: peerMentionAttributes(primaryTextColor: primaryTextColor, peerId: user.id)]) attributedString = addAttributesToStringWithRanges(strings.Notification_ForumTopicClosedAuthor(EnginePeer.user(user).displayTitle(strings: strings, displayOrder: nameDisplayOrder))._tuple, body: bodyAttributes, argumentAttributes: [0: peerMentionAttributes(primaryTextColor: primaryTextColor, peerId: user.id)])
} else { } else {
attributedString = addAttributesToStringWithRanges(strings.Notification_TopicReopenedAuthor(EnginePeer.user(user).displayTitle(strings: strings, displayOrder: nameDisplayOrder))._tuple, body: bodyAttributes, argumentAttributes: [0: peerMentionAttributes(primaryTextColor: primaryTextColor, peerId: user.id)]) attributedString = addAttributesToStringWithRanges(strings.Notification_ForumTopicReopenedAuthor(EnginePeer.user(user).displayTitle(strings: strings, displayOrder: nameDisplayOrder))._tuple, body: bodyAttributes, argumentAttributes: [0: peerMentionAttributes(primaryTextColor: primaryTextColor, peerId: user.id)])
} }
} }
} else { } else {
if isClosed { if isClosed {
attributedString = NSAttributedString(string: strings.Notification_TopicClosed, font: titleFont, textColor: primaryTextColor) attributedString = NSAttributedString(string: strings.Notification_ForumTopicClosed, font: titleFont, textColor: primaryTextColor)
} else { } else {
attributedString = NSAttributedString(string: strings.Notification_TopicReopened, font: titleFont, textColor: primaryTextColor) attributedString = NSAttributedString(string: strings.Notification_ForumTopicReopened, font: titleFont, textColor: primaryTextColor)
} }
} }
} else if let maybeFileId = components.compactMap({ item -> Int64? in } else if let maybeFileId = components.compactMap({ item -> Int64? in
@ -744,12 +744,12 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
if let info = message.associatedThreadInfo { if let info = message.associatedThreadInfo {
iconColor = info.iconColor iconColor = info.iconColor
} }
attributedString = addAttributesToStringWithRanges(strings.Notification_TopicRenamedIconChangedAuthor(EnginePeer.user(user).displayTitle(strings: strings, displayOrder: nameDisplayOrder), ".", title)._tuple, body: bodyAttributes, argumentAttributes: [ attributedString = addAttributesToStringWithRanges(strings.Notification_ForumTopicRenamedIconChangedAuthor(EnginePeer.user(user).displayTitle(strings: strings, displayOrder: nameDisplayOrder), ".", title)._tuple, body: bodyAttributes, argumentAttributes: [
0: peerMentionAttributes(primaryTextColor: primaryTextColor, peerId: user.id), 0: peerMentionAttributes(primaryTextColor: primaryTextColor, peerId: user.id),
1: MarkdownAttributeSet(font: titleFont, textColor: primaryTextColor, additionalAttributes: [ChatTextInputAttributes.customEmoji.rawValue: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: maybeFileId, file: nil, topicInfo: maybeFileId == 0 ? EngineMessageHistoryThread.Info(title: title, icon: nil, iconColor: iconColor) : nil)]) 1: MarkdownAttributeSet(font: titleFont, textColor: primaryTextColor, additionalAttributes: [ChatTextInputAttributes.customEmoji.rawValue: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: maybeFileId, file: nil, topicInfo: maybeFileId == 0 ? EngineMessageHistoryThread.Info(title: title, icon: nil, iconColor: iconColor) : nil)])
]) ])
} else { } else {
attributedString = NSAttributedString(string: strings.Notification_TopicRenamed(title).string, font: titleFont, textColor: primaryTextColor) attributedString = NSAttributedString(string: strings.Notification_ForumTopicRenamed(title).string, font: titleFont, textColor: primaryTextColor)
} }
} else if let title = components.compactMap({ item -> String? in } else if let title = components.compactMap({ item -> String? in
switch item { switch item {
@ -760,9 +760,9 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
} }
}).first { }).first {
if case let .user(user) = message.author { if case let .user(user) = message.author {
attributedString = addAttributesToStringWithRanges(strings.Notification_TopicRenamedAuthor(EnginePeer.user(user).displayTitle(strings: strings, displayOrder: nameDisplayOrder), title)._tuple, body: bodyAttributes, argumentAttributes: [0: peerMentionAttributes(primaryTextColor: primaryTextColor, peerId: user.id)]) attributedString = addAttributesToStringWithRanges(strings.Notification_ForumTopicRenamedAuthor(EnginePeer.user(user).displayTitle(strings: strings, displayOrder: nameDisplayOrder), title)._tuple, body: bodyAttributes, argumentAttributes: [0: peerMentionAttributes(primaryTextColor: primaryTextColor, peerId: user.id)])
} else { } else {
attributedString = NSAttributedString(string: strings.Notification_TopicRenamed(title).string, font: titleFont, textColor: primaryTextColor) attributedString = NSAttributedString(string: strings.Notification_ForumTopicRenamed(title).string, font: titleFont, textColor: primaryTextColor)
} }
} else if let maybeFileId = components.compactMap({ item -> Int64? in } else if let maybeFileId = components.compactMap({ item -> Int64? in
switch item { switch item {
@ -779,9 +779,9 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
title = info.title title = info.title
} }
if case let .user(user) = message.author { if case let .user(user) = message.author {
attributedString = addAttributesToStringWithRanges(strings.Notification_TopicIconChangedAuthor(EnginePeer.user(user).displayTitle(strings: strings, displayOrder: nameDisplayOrder), ".")._tuple, body: bodyAttributes, argumentAttributes: [0: peerMentionAttributes(primaryTextColor: primaryTextColor, peerId: user.id), 1: MarkdownAttributeSet(font: titleFont, textColor: primaryTextColor, additionalAttributes: [ChatTextInputAttributes.customEmoji.rawValue: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: maybeFileId, file: nil, topicInfo: maybeFileId == 0 ? EngineMessageHistoryThread.Info(title: title, icon: nil, iconColor: iconColor) : nil)])]) attributedString = addAttributesToStringWithRanges(strings.Notification_ForumTopicIconChangedAuthor(EnginePeer.user(user).displayTitle(strings: strings, displayOrder: nameDisplayOrder), ".")._tuple, body: bodyAttributes, argumentAttributes: [0: peerMentionAttributes(primaryTextColor: primaryTextColor, peerId: user.id), 1: MarkdownAttributeSet(font: titleFont, textColor: primaryTextColor, additionalAttributes: [ChatTextInputAttributes.customEmoji.rawValue: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: maybeFileId, file: nil, topicInfo: maybeFileId == 0 ? EngineMessageHistoryThread.Info(title: title, icon: nil, iconColor: iconColor) : nil)])])
} else { } else {
attributedString = addAttributesToStringWithRanges(strings.Notification_TopicIconChanged(".")._tuple, body: bodyAttributes, argumentAttributes: [0: MarkdownAttributeSet(font: titleFont, textColor: primaryTextColor, additionalAttributes: [ChatTextInputAttributes.customEmoji.rawValue: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: maybeFileId, file: nil, topicInfo: maybeFileId == 0 ? EngineMessageHistoryThread.Info(title: title, icon: nil, iconColor: iconColor) : nil)])]) attributedString = addAttributesToStringWithRanges(strings.Notification_ForumTopicIconChanged(".")._tuple, body: bodyAttributes, argumentAttributes: [0: MarkdownAttributeSet(font: titleFont, textColor: primaryTextColor, additionalAttributes: [ChatTextInputAttributes.customEmoji.rawValue: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: maybeFileId, file: nil, topicInfo: maybeFileId == 0 ? EngineMessageHistoryThread.Info(title: title, icon: nil, iconColor: iconColor) : nil)])])
} }
} }
case .unknown: case .unknown:

View File

@ -3934,7 +3934,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: true, isSimple: false) let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: true, isSimple: false)
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, openUrl: { [weak self] url in let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url in
self?.openUrl(url, concealed: true, forceExternal: true) self?.openUrl(url, concealed: true, forceExternal: true)
}, getInputContainerNode: { [weak self] in }, getInputContainerNode: { [weak self] in
if let strongSelf = self, let layout = strongSelf.validLayout, case .compact = layout.metrics.widthClass { if let strongSelf = self, let layout = strongSelf.validLayout, case .compact = layout.metrics.widthClass {
@ -3978,7 +3978,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return return
} }
let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: false, isSimple: true) let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: false, isSimple: true)
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, openUrl: { [weak self] url in let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url in
self?.openUrl(url, concealed: true, forceExternal: true) self?.openUrl(url, concealed: true, forceExternal: true)
}, getNavigationController: { [weak self] in }, getNavigationController: { [weak self] in
return self?.effectiveNavigationController return self?.effectiveNavigationController
@ -3993,7 +3993,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
})) }))
} else { } else {
strongSelf.messageActionCallbackDisposable.set(((strongSelf.context.engine.messages.requestWebView(peerId: peerId, botId: peerId, url: !url.isEmpty ? url : nil, payload: nil, themeParams: generateWebAppThemeParams(strongSelf.presentationData.theme), fromMenu: buttonText == "Menu", replyToMessageId: nil) strongSelf.messageActionCallbackDisposable.set(((strongSelf.context.engine.messages.requestWebView(peerId: peerId, botId: peerId, url: !url.isEmpty ? url : nil, payload: nil, themeParams: generateWebAppThemeParams(strongSelf.presentationData.theme), fromMenu: buttonText == "Menu", replyToMessageId: nil, threadId: strongSelf.chatLocation.threadId)
|> afterDisposed { |> afterDisposed {
updateProgress() updateProgress()
}) })
@ -4002,7 +4002,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return return
} }
let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: result.url, queryId: result.queryId, payload: nil, buttonText: buttonText, keepAliveSignal: result.keepAliveSignal, fromMenu: false, isSimple: false) let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: result.url, queryId: result.queryId, payload: nil, buttonText: buttonText, keepAliveSignal: result.keepAliveSignal, fromMenu: false, isSimple: false)
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, openUrl: { [weak self] url in let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url in
self?.openUrl(url, concealed: true, forceExternal: true) self?.openUrl(url, concealed: true, forceExternal: true)
}, completion: { [weak self] in }, completion: { [weak self] in
self?.chatDisplayNode.historyNode.scrollToEndOfHistory() self?.chatDisplayNode.historyNode.scrollToEndOfHistory()
@ -12195,7 +12195,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
case let .app(bot, botName, _): case let .app(bot, botName, _):
let params = WebAppParameters(peerId: peer.id, botId: bot.id, botName: botName, url: nil, queryId: nil, payload: botPayload, buttonText: nil, keepAliveSignal: nil, fromMenu: false, isSimple: false) let params = WebAppParameters(peerId: peer.id, botId: bot.id, botName: botName, url: nil, queryId: nil, payload: botPayload, buttonText: nil, keepAliveSignal: nil, fromMenu: false, isSimple: false)
let replyMessageId = strongSelf.presentationInterfaceState.interfaceState.replyMessageId let replyMessageId = strongSelf.presentationInterfaceState.interfaceState.replyMessageId
let controller = WebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, replyToMessageId: replyMessageId) let controller = WebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, replyToMessageId: replyMessageId, threadId: strongSelf.chatLocation.threadId)
controller.openUrl = { [weak self] url in controller.openUrl = { [weak self] url in
self?.openUrl(url, concealed: true, forceExternal: true) self?.openUrl(url, concealed: true, forceExternal: true)
} }
@ -17028,7 +17028,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
switch action { switch action {
case .commit: case .commit:
let _ = (strongSelf.context.engine.messages.requestUnpinAllMessages(peerId: peerId) let _ = (strongSelf.context.engine.messages.requestUnpinAllMessages(peerId: peerId, threadId: strongSelf.chatLocation.threadId)
|> deliverOnMainQueue).start(error: { _ in |> deliverOnMainQueue).start(error: { _ in
}, completed: { }, completed: {
guard let strongSelf = self else { guard let strongSelf = self else {

View File

@ -2042,6 +2042,9 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
} }
} else if let invoice = media as? TelegramMediaInvoice, let extendedMedia = invoice.extendedMedia, case .preview = extendedMedia { } else if let invoice = media as? TelegramMediaInvoice, let extendedMedia = invoice.extendedMedia, case .preview = extendedMedia {
messageIdsWithInactiveExtendedMedia.insert(message.id) messageIdsWithInactiveExtendedMedia.insert(message.id)
if invoice.version != TelegramMediaInvoice.lastVersion {
contentRequiredValidation = true
}
} }
} }
if contentRequiredValidation { if contentRequiredValidation {

View File

@ -1077,7 +1077,10 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
var edited = false var edited = false
var viewCount: Int? = nil var viewCount: Int? = nil
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message)
if item.message.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in item.message.attributes { for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute, isEmoji { if let attribute = attribute as? EditedMessageAttribute, isEmoji {
edited = !attribute.isHidden edited = !attribute.isHidden

View File

@ -338,7 +338,10 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
} }
var viewCount: Int? var viewCount: Int?
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: associatedData.accountPeer, message: message) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: associatedData.accountPeer, message: message)
if message.isRestricted(platform: "ios", contentSettings: context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in message.attributes { for attribute in message.attributes {
if let attribute = attribute as? EditedMessageAttribute { if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden edited = !attribute.isHidden

View File

@ -1465,6 +1465,10 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
} }
} }
if firstMessage.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
replyMarkup = nil
}
if let forwardInfo = firstMessage.forwardInfo, forwardInfo.psaType != nil { if let forwardInfo = firstMessage.forwardInfo, forwardInfo.psaType != nil {
inlineBotNameString = nil inlineBotNameString = nil
} }
@ -1759,7 +1763,10 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
} }
var viewCount: Int? var viewCount: Int?
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: message) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: message)
if message.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in message.attributes { for attribute in message.attributes {
if let attribute = attribute as? EditedMessageAttribute { if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden edited = !attribute.isHidden

View File

@ -172,7 +172,10 @@ class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
} }
var viewCount: Int? var viewCount: Int?
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message)
if item.message.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in item.message.attributes { for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute { if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden edited = !attribute.isHidden

View File

@ -781,7 +781,10 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
} }
var viewCount: Int? var viewCount: Int?
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: arguments.associatedData.accountPeer, message: arguments.topMessage) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: arguments.associatedData.accountPeer, message: arguments.topMessage)
if arguments.topMessage.isRestricted(platform: "ios", contentSettings: arguments.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in arguments.message.attributes { for attribute in arguments.message.attributes {
if let attribute = attribute as? EditedMessageAttribute { if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden edited = !attribute.isHidden

View File

@ -463,7 +463,10 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
let sentViaBot = false let sentViaBot = false
var viewCount: Int? = nil var viewCount: Int? = nil
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message)
if item.message.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in item.message.attributes { for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute { if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden edited = !attribute.isHidden

View File

@ -183,7 +183,10 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
} }
var viewCount: Int? var viewCount: Int?
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message)
if item.message.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in item.message.attributes { for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute { if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden edited = !attribute.isHidden

View File

@ -218,7 +218,10 @@ class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
} }
var viewCount: Int? var viewCount: Int?
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message)
if item.message.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in item.message.attributes { for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute { if let attribute = attribute as? EditedMessageAttribute {
if case .mosaic = preparePosition { if case .mosaic = preparePosition {

View File

@ -1053,7 +1053,10 @@ class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode {
} }
var viewCount: Int? var viewCount: Int?
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message)
if item.message.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in item.message.attributes { for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute { if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden edited = !attribute.isHidden

View File

@ -53,7 +53,10 @@ class ChatMessageRestrictedBubbleContentNode: ChatMessageBubbleContentNode {
var viewCount: Int? var viewCount: Int?
var rawText = "" var rawText = ""
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message)
if item.message.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in item.message.attributes { for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute { if let attribute = attribute as? EditedMessageAttribute {
edited = !attribute.isHidden edited = !attribute.isHidden

View File

@ -520,7 +520,10 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
var edited = false var edited = false
var viewCount: Int? = nil var viewCount: Int? = nil
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.message)
if item.message.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in item.message.attributes { for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute, isEmoji { if let attribute = attribute as? EditedMessageAttribute, isEmoji {
edited = !attribute.isHidden edited = !attribute.isHidden

View File

@ -157,7 +157,10 @@ class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
} }
var viewCount: Int? var viewCount: Int?
var dateReplies = 0 var dateReplies = 0
let dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.topMessage) var dateReactionsAndPeers = mergedMessageReactionsAndPeers(accountPeer: item.associatedData.accountPeer, message: item.topMessage)
if item.message.isRestricted(platform: "ios", contentSettings: item.context.currentContentSettings.with { $0 }) {
dateReactionsAndPeers = ([], [])
}
for attribute in item.message.attributes { for attribute in item.message.attributes {
if let attribute = attribute as? EditedMessageAttribute { if let attribute = attribute as? EditedMessageAttribute {

View File

@ -317,7 +317,7 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode {
messageUpdated = true messageUpdated = true
} }
if let message = interfaceState.pinnedMessage { if let message = interfaceState.pinnedMessage, !message.message.isRestricted(platform: "ios", contentSettings: self.context.currentContentSettings.with { $0 }) {
for attribute in message.message.attributes { for attribute in message.message.attributes {
if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), attribute.rows.count == 1, attribute.rows[0].buttons.count == 1 { if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), attribute.rows.count == 1, attribute.rows[0].buttons.count == 1 {
actionTitle = attribute.rows[0].buttons[0].title actionTitle = attribute.rows[0].buttons[0].title

View File

@ -350,7 +350,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
}) })
} }
} else { } else {
let _ = (context.engine.messages.requestWebView(peerId: controller.peerId, botId: controller.botId, url: controller.url, payload: controller.payload, themeParams: generateWebAppThemeParams(presentationData.theme), fromMenu: controller.fromMenu, replyToMessageId: controller.replyToMessageId) let _ = (context.engine.messages.requestWebView(peerId: controller.peerId, botId: controller.botId, url: controller.url, payload: controller.payload, themeParams: generateWebAppThemeParams(presentationData.theme), fromMenu: controller.fromMenu, replyToMessageId: controller.replyToMessageId, threadId: controller.threadId)
|> deliverOnMainQueue).start(next: { [weak self] result in |> deliverOnMainQueue).start(next: { [weak self] result in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
@ -985,6 +985,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
private let isSimple: Bool private let isSimple: Bool
private let keepAliveSignal: Signal<Never, KeepWebViewError>? private let keepAliveSignal: Signal<Never, KeepWebViewError>?
private let replyToMessageId: MessageId? private let replyToMessageId: MessageId?
private let threadId: Int64?
private var presentationData: PresentationData private var presentationData: PresentationData
fileprivate let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? fileprivate let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?
@ -994,7 +995,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
public var getNavigationController: () -> NavigationController? = { return nil } public var getNavigationController: () -> NavigationController? = { return nil }
public var completion: () -> Void = {} public var completion: () -> Void = {}
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, params: WebAppParameters, replyToMessageId: MessageId?) { public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, params: WebAppParameters, replyToMessageId: MessageId?, threadId: Int64?) {
self.context = context self.context = context
self.peerId = params.peerId self.peerId = params.peerId
self.botId = params.botId self.botId = params.botId
@ -1007,6 +1008,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
self.isSimple = params.isSimple self.isSimple = params.isSimple
self.keepAliveSignal = params.keepAliveSignal self.keepAliveSignal = params.keepAliveSignal
self.replyToMessageId = replyToMessageId self.replyToMessageId = replyToMessageId
self.threadId = threadId
self.updatedPresentationData = updatedPresentationData self.updatedPresentationData = updatedPresentationData
self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 } self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 }
@ -1285,13 +1287,13 @@ private final class WebAppContextReferenceContentSource: ContextReferenceContent
} }
} }
public func standaloneWebAppController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, params: WebAppParameters, openUrl: @escaping (String) -> Void, getInputContainerNode: @escaping () -> (CGFloat, ASDisplayNode, () -> AttachmentController.InputPanelTransition?)? = { return nil }, completion: @escaping () -> Void = {}, willDismiss: @escaping () -> Void = {}, didDismiss: @escaping () -> Void = {}, getNavigationController: @escaping () -> NavigationController? = { return nil }, getSourceRect: (() -> CGRect?)? = nil) -> ViewController { public func standaloneWebAppController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, params: WebAppParameters, threadId: Int64?, openUrl: @escaping (String) -> Void, getInputContainerNode: @escaping () -> (CGFloat, ASDisplayNode, () -> AttachmentController.InputPanelTransition?)? = { return nil }, completion: @escaping () -> Void = {}, willDismiss: @escaping () -> Void = {}, didDismiss: @escaping () -> Void = {}, getNavigationController: @escaping () -> NavigationController? = { return nil }, getSourceRect: (() -> CGRect?)? = nil) -> ViewController {
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: .peer(id: params.peerId), buttons: [.standalone], initialButton: .standalone, fromMenu: params.fromMenu, hasTextInput: false, makeEntityInputView: { let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: .peer(id: params.peerId), buttons: [.standalone], initialButton: .standalone, fromMenu: params.fromMenu, hasTextInput: false, makeEntityInputView: {
return nil return nil
}) })
controller.getInputContainerNode = getInputContainerNode controller.getInputContainerNode = getInputContainerNode
controller.requestController = { _, present in controller.requestController = { _, present in
let webAppController = WebAppController(context: context, updatedPresentationData: updatedPresentationData, params: params, replyToMessageId: nil) let webAppController = WebAppController(context: context, updatedPresentationData: updatedPresentationData, params: params, replyToMessageId: nil, threadId: threadId)
webAppController.openUrl = openUrl webAppController.openUrl = openUrl
webAppController.completion = completion webAppController.completion = completion
webAppController.getNavigationController = getNavigationController webAppController.getNavigationController = getNavigationController