Update API

This commit is contained in:
Ilya Laktyushin 2026-02-17 10:25:42 +04:00
parent 4864bb1ae4
commit 9c16af25c0
14 changed files with 186 additions and 74 deletions

View file

@ -15801,3 +15801,15 @@ Error: %8$@";
"FormattedDate.LongDate_m10" = "October %1$@, %2$@";
"FormattedDate.LongDate_m11" = "November %1$@, %2$@";
"FormattedDate.LongDate_m12" = "December %1$@, %2$@";
"Gift.Sell.Confirm.Title" = "Confirm Sale";
"Gift.Sell.Confirm.Text" = "Do you want to list **%1$@** for sale at %2$@?";
"Gift.Sell.Confirm.ListFor_1" = "List for %@ Star";
"Gift.Sell.Confirm.ListFor_any" = "List for %@ Stars";
"Gift.Sell.Confirm.ListForTon" = "List for %@ TON";
"Notification.CopyProtection.Enabled" = "%1$@ disabled sharing in this chat";
"Notification.CopyProtection.EnabledYou" = "You disabled sharing in this chat";
"Notification.CopyProtection.Disabled" = "%1$@ enabled sharing in this chat";
"Notification.CopyProtection.DisabledYou" = "You enabled sharing in this chat";
"Notification.CopyProtection.StillEnabled" = "Sharing in this chat is still disabled";

View file

@ -185,7 +185,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1798033689] = { return Api.ChannelMessagesFilter.parse_channelMessagesFilterEmpty($0) }
dict[466961494] = { return Api.ChannelParticipant.parse_channelParticipant($0) }
dict[885242707] = { return Api.ChannelParticipant.parse_channelParticipantAdmin($0) }
dict[1844969806] = { return Api.ChannelParticipant.parse_channelParticipantBanned($0) }
dict[-705647215] = { return Api.ChannelParticipant.parse_channelParticipantBanned($0) }
dict[803602899] = { return Api.ChannelParticipant.parse_channelParticipantCreator($0) }
dict[453242886] = { return Api.ChannelParticipant.parse_channelParticipantLeft($0) }
dict[-1454929382] = { return Api.ChannelParticipant.parse_channelParticipantSelf($0) }
@ -609,6 +609,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1615153660] = { return Api.MessageAction.parse_messageActionHistoryClear($0) }
dict[1345295095] = { return Api.MessageAction.parse_messageActionInviteToGroupCall($0) }
dict[-1333866363] = { return Api.MessageAction.parse_messageActionNewCreatorPending($0) }
dict[1042781114] = { return Api.MessageAction.parse_messageActionNoForwardsRequest($0) }
dict[-1082301070] = { return Api.MessageAction.parse_messageActionNoForwardsToggle($0) }
dict[-2068281992] = { return Api.MessageAction.parse_messageActionPaidMessagesPrice($0) }
dict[-1407246387] = { return Api.MessageAction.parse_messageActionPaidMessagesRefunded($0) }
dict[1102307842] = { return Api.MessageAction.parse_messageActionPaymentRefunded($0) }
@ -1174,7 +1176,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1094555409] = { return Api.Update.parse_updateNotifySettings($0) }
dict[-1955438642] = { return Api.Update.parse_updatePaidReactionPrivacy($0) }
dict[-337610926] = { return Api.Update.parse_updatePeerBlocked($0) }
dict[1463202714] = { return Api.Update.parse_updatePeerHistoryNoForwards($0) }
dict[-1147422299] = { return Api.Update.parse_updatePeerHistoryTTL($0) }
dict[-1263546448] = { return Api.Update.parse_updatePeerLocated($0) }
dict[1786671974] = { return Api.Update.parse_updatePeerSettings($0) }

View file

@ -1798,6 +1798,24 @@ public extension Api {
self.newCreatorId = newCreatorId
}
}
public class Cons_messageActionNoForwardsRequest {
public var flags: Int32
public var prevValue: Api.Bool
public var newValue: Api.Bool
public init(flags: Int32, prevValue: Api.Bool, newValue: Api.Bool) {
self.flags = flags
self.prevValue = prevValue
self.newValue = newValue
}
}
public class Cons_messageActionNoForwardsToggle {
public var prevValue: Api.Bool
public var newValue: Api.Bool
public init(prevValue: Api.Bool, newValue: Api.Bool) {
self.prevValue = prevValue
self.newValue = newValue
}
}
public class Cons_messageActionPaidMessagesPrice {
public var flags: Int32
public var stars: Int64
@ -2145,6 +2163,8 @@ public extension Api {
case messageActionHistoryClear
case messageActionInviteToGroupCall(Cons_messageActionInviteToGroupCall)
case messageActionNewCreatorPending(Cons_messageActionNewCreatorPending)
case messageActionNoForwardsRequest(Cons_messageActionNoForwardsRequest)
case messageActionNoForwardsToggle(Cons_messageActionNoForwardsToggle)
case messageActionPaidMessagesPrice(Cons_messageActionPaidMessagesPrice)
case messageActionPaidMessagesRefunded(Cons_messageActionPaidMessagesRefunded)
case messageActionPaymentRefunded(Cons_messageActionPaymentRefunded)
@ -2456,6 +2476,21 @@ public extension Api {
}
serializeInt64(_data.newCreatorId, buffer: buffer, boxed: false)
break
case .messageActionNoForwardsRequest(let _data):
if boxed {
buffer.appendInt32(1042781114)
}
serializeInt32(_data.flags, buffer: buffer, boxed: false)
_data.prevValue.serialize(buffer, true)
_data.newValue.serialize(buffer, true)
break
case .messageActionNoForwardsToggle(let _data):
if boxed {
buffer.appendInt32(-1082301070)
}
_data.prevValue.serialize(buffer, true)
_data.newValue.serialize(buffer, true)
break
case .messageActionPaidMessagesPrice(let _data):
if boxed {
buffer.appendInt32(-2068281992)
@ -2882,6 +2917,10 @@ public extension Api {
return ("messageActionInviteToGroupCall", [("call", _data.call as Any), ("users", _data.users as Any)])
case .messageActionNewCreatorPending(let _data):
return ("messageActionNewCreatorPending", [("newCreatorId", _data.newCreatorId as Any)])
case .messageActionNoForwardsRequest(let _data):
return ("messageActionNoForwardsRequest", [("flags", _data.flags as Any), ("prevValue", _data.prevValue as Any), ("newValue", _data.newValue as Any)])
case .messageActionNoForwardsToggle(let _data):
return ("messageActionNoForwardsToggle", [("prevValue", _data.prevValue as Any), ("newValue", _data.newValue as Any)])
case .messageActionPaidMessagesPrice(let _data):
return ("messageActionPaidMessagesPrice", [("flags", _data.flags as Any), ("stars", _data.stars as Any)])
case .messageActionPaidMessagesRefunded(let _data):
@ -3440,6 +3479,45 @@ public extension Api {
return nil
}
}
public static func parse_messageActionNoForwardsRequest(_ reader: BufferReader) -> MessageAction? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.Bool?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Bool
}
var _3: Api.Bool?
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.Bool
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.MessageAction.messageActionNoForwardsRequest(Cons_messageActionNoForwardsRequest(flags: _1!, prevValue: _2!, newValue: _3!))
}
else {
return nil
}
}
public static func parse_messageActionNoForwardsToggle(_ reader: BufferReader) -> MessageAction? {
var _1: Api.Bool?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.Bool
}
var _2: Api.Bool?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Bool
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.MessageAction.messageActionNoForwardsToggle(Cons_messageActionNoForwardsToggle(prevValue: _1!, newValue: _2!))
}
else {
return nil
}
}
public static func parse_messageActionPaidMessagesPrice(_ reader: BufferReader) -> MessageAction? {
var _1: Int32?
_1 = reader.readInt32()

View file

@ -981,14 +981,6 @@ public extension Api {
self.peerId = peerId
}
}
public class Cons_updatePeerHistoryNoForwards {
public var flags: Int32
public var peer: Api.Peer
public init(flags: Int32, peer: Api.Peer) {
self.flags = flags
self.peer = peer
}
}
public class Cons_updatePeerHistoryTTL {
public var flags: Int32
public var peer: Api.Peer
@ -1552,7 +1544,6 @@ public extension Api {
case updateNotifySettings(Cons_updateNotifySettings)
case updatePaidReactionPrivacy(Cons_updatePaidReactionPrivacy)
case updatePeerBlocked(Cons_updatePeerBlocked)
case updatePeerHistoryNoForwards(Cons_updatePeerHistoryNoForwards)
case updatePeerHistoryTTL(Cons_updatePeerHistoryTTL)
case updatePeerLocated(Cons_updatePeerLocated)
case updatePeerSettings(Cons_updatePeerSettings)
@ -2519,13 +2510,6 @@ public extension Api {
serializeInt32(_data.flags, buffer: buffer, boxed: false)
_data.peerId.serialize(buffer, true)
break
case .updatePeerHistoryNoForwards(let _data):
if boxed {
buffer.appendInt32(1463202714)
}
serializeInt32(_data.flags, buffer: buffer, boxed: false)
_data.peer.serialize(buffer, true)
break
case .updatePeerHistoryTTL(let _data):
if boxed {
buffer.appendInt32(-1147422299)
@ -3232,8 +3216,6 @@ public extension Api {
return ("updatePaidReactionPrivacy", [("`private`", _data.`private` as Any)])
case .updatePeerBlocked(let _data):
return ("updatePeerBlocked", [("flags", _data.flags as Any), ("peerId", _data.peerId as Any)])
case .updatePeerHistoryNoForwards(let _data):
return ("updatePeerHistoryNoForwards", [("flags", _data.flags as Any), ("peer", _data.peer as Any)])
case .updatePeerHistoryTTL(let _data):
return ("updatePeerHistoryTTL", [("flags", _data.flags as Any), ("peer", _data.peer as Any), ("ttlPeriod", _data.ttlPeriod as Any)])
case .updatePeerLocated(let _data):
@ -5220,22 +5202,6 @@ public extension Api {
return nil
}
}
public static func parse_updatePeerHistoryNoForwards(_ reader: BufferReader) -> Update? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.Peer?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Peer
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.Update.updatePeerHistoryNoForwards(Cons_updatePeerHistoryNoForwards(flags: _1!, peer: _2!))
}
else {
return nil
}
}
public static func parse_updatePeerHistoryTTL(_ reader: BufferReader) -> Update? {
var _1: Int32?
_1 = reader.readInt32()

View file

@ -203,12 +203,14 @@ public extension Api {
public var kickedBy: Int64
public var date: Int32
public var bannedRights: Api.ChatBannedRights
public init(flags: Int32, peer: Api.Peer, kickedBy: Int64, date: Int32, bannedRights: Api.ChatBannedRights) {
public var rank: String?
public init(flags: Int32, peer: Api.Peer, kickedBy: Int64, date: Int32, bannedRights: Api.ChatBannedRights, rank: String?) {
self.flags = flags
self.peer = peer
self.kickedBy = kickedBy
self.date = date
self.bannedRights = bannedRights
self.rank = rank
}
}
public class Cons_channelParticipantCreator {
@ -286,13 +288,16 @@ public extension Api {
break
case .channelParticipantBanned(let _data):
if boxed {
buffer.appendInt32(1844969806)
buffer.appendInt32(-705647215)
}
serializeInt32(_data.flags, buffer: buffer, boxed: false)
_data.peer.serialize(buffer, true)
serializeInt64(_data.kickedBy, buffer: buffer, boxed: false)
serializeInt32(_data.date, buffer: buffer, boxed: false)
_data.bannedRights.serialize(buffer, true)
if Int(_data.flags) & Int(1 << 2) != 0 {
serializeString(_data.rank!, buffer: buffer, boxed: false)
}
break
case .channelParticipantCreator(let _data):
if boxed {
@ -336,7 +341,7 @@ public extension Api {
case .channelParticipantAdmin(let _data):
return ("channelParticipantAdmin", [("flags", _data.flags as Any), ("userId", _data.userId as Any), ("inviterId", _data.inviterId as Any), ("promotedBy", _data.promotedBy as Any), ("date", _data.date as Any), ("adminRights", _data.adminRights as Any), ("rank", _data.rank as Any)])
case .channelParticipantBanned(let _data):
return ("channelParticipantBanned", [("flags", _data.flags as Any), ("peer", _data.peer as Any), ("kickedBy", _data.kickedBy as Any), ("date", _data.date as Any), ("bannedRights", _data.bannedRights as Any)])
return ("channelParticipantBanned", [("flags", _data.flags as Any), ("peer", _data.peer as Any), ("kickedBy", _data.kickedBy as Any), ("date", _data.date as Any), ("bannedRights", _data.bannedRights as Any), ("rank", _data.rank as Any)])
case .channelParticipantCreator(let _data):
return ("channelParticipantCreator", [("flags", _data.flags as Any), ("userId", _data.userId as Any), ("adminRights", _data.adminRights as Any), ("rank", _data.rank as Any)])
case .channelParticipantLeft(let _data):
@ -423,13 +428,18 @@ public extension Api {
if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights
}
var _6: String?
if Int(_1!) & Int(1 << 2) != 0 {
_6 = parseString(reader)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.ChannelParticipant.channelParticipantBanned(Cons_channelParticipantBanned(flags: _1!, peer: _2!, kickedBy: _3!, date: _4!, bannedRights: _5!))
let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.ChannelParticipant.channelParticipantBanned(Cons_channelParticipantBanned(flags: _1!, peer: _2!, kickedBy: _3!, date: _4!, bannedRights: _5!, rank: _6))
}
else {
return nil

View file

@ -9510,12 +9510,16 @@ public extension Api.functions.messages {
}
}
public extension Api.functions.messages {
static func toggleNoForwards(peer: Api.InputPeer, enabled: Api.Bool) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
static func toggleNoForwards(flags: Int32, peer: Api.InputPeer, enabled: Api.Bool, requestMsgId: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(-1323389022)
buffer.appendInt32(-1308091851)
serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
enabled.serialize(buffer, true)
return (FunctionDescription(name: "messages.toggleNoForwards", parameters: [("peer", String(describing: peer)), ("enabled", String(describing: enabled))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
if Int(flags) & Int(1 << 0) != 0 {
serializeInt32(requestMsgId!, buffer: buffer, boxed: false)
}
return (FunctionDescription(name: "messages.toggleNoForwards", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("enabled", String(describing: enabled)), ("requestMsgId", String(describing: requestMsgId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {

View file

@ -215,7 +215,7 @@ extension ChannelParticipant {
let (flags, userId, restrictedBy, date, bannedRights) = (channelParticipantBannedData.flags, channelParticipantBannedData.peer, channelParticipantBannedData.kickedBy, channelParticipantBannedData.date, channelParticipantBannedData.bannedRights)
let hasLeft = (flags & (1 << 0)) != 0
let banInfo = ChannelParticipantBannedInfo(rights: TelegramChatBannedRights(apiBannedRights: bannedRights), restrictedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(restrictedBy)), timestamp: date, isMember: !hasLeft)
self = .member(id: userId.peerId, invitedAt: date, adminInfo: nil, banInfo: banInfo, rank: nil, subscriptionUntilDate: nil)
self = .member(id: userId.peerId, invitedAt: date, adminInfo: nil, banInfo: banInfo, rank: channelParticipantBannedData.rank, subscriptionUntilDate: nil)
case let .channelParticipantAdmin(channelParticipantAdminData):
let (flags, userId, _, promotedBy, date, adminRights, rank) = (channelParticipantAdminData.flags, channelParticipantAdminData.userId, channelParticipantAdminData.inviterId, channelParticipantAdminData.promotedBy, channelParticipantAdminData.date, channelParticipantAdminData.adminRights, channelParticipantAdminData.rank)
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), invitedAt: date, adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(apiAdminRights: adminRights) ?? TelegramChatAdminRights(rights: []), promotedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(promotedBy)), canBeEditedByAccountPeer: (flags & (1 << 0)) != 0), banInfo: nil, rank: rank, subscriptionUntilDate: nil)

View file

@ -240,7 +240,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
}
switch action {
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionGiftStars, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe, .messageActionStarGift, .messageActionStarGiftUnique, .messageActionPaidMessagesRefunded, .messageActionPaidMessagesPrice, .messageActionTodoCompletions, .messageActionTodoAppendTasks, .messageActionSuggestedPostApproval, .messageActionGiftTon, .messageActionSuggestedPostSuccess, .messageActionSuggestedPostRefund, .messageActionSuggestBirthday, .messageActionStarGiftPurchaseOffer, .messageActionStarGiftPurchaseOfferDeclined:
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionGiftStars, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe, .messageActionStarGift, .messageActionStarGiftUnique, .messageActionPaidMessagesRefunded, .messageActionPaidMessagesPrice, .messageActionTodoCompletions, .messageActionTodoAppendTasks, .messageActionSuggestedPostApproval, .messageActionGiftTon, .messageActionSuggestedPostSuccess, .messageActionSuggestedPostRefund, .messageActionSuggestBirthday, .messageActionStarGiftPurchaseOffer, .messageActionStarGiftPurchaseOfferDeclined, .messageActionNoForwardsToggle, .messageActionNoForwardsRequest:
break
case let .messageActionChannelMigrateFrom(messageActionChannelMigrateFromData):
let chatId = messageActionChannelMigrateFromData.chatId

View file

@ -349,16 +349,20 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
return nil
}
return TelegramMediaAction(action: .starGiftPurchaseOfferDeclined(gift: gift, amount: CurrencyAmount(apiAmount: price), hasExpired: (flags & (1 << 0)) != 0))
case let .messageActionNewCreatorPending(messageActionNewCreatorPending):
case let .messageActionNewCreatorPending(messageActionNewCreatorPendingData):
return TelegramMediaAction(action: .groupCreatorChange(TelegramMediaActionType.GroupCreatorChange(
kind: .pending,
targetPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(messageActionNewCreatorPending.newCreatorId))
targetPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(messageActionNewCreatorPendingData.newCreatorId))
)))
case let .messageActionChangeCreator(messageActionChangeCreator):
case let .messageActionChangeCreator(messageActionChangeCreatorData):
return TelegramMediaAction(action: .groupCreatorChange(TelegramMediaActionType.GroupCreatorChange(
kind: .applied,
targetPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(messageActionChangeCreator.newCreatorId))
targetPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(messageActionChangeCreatorData.newCreatorId))
)))
case let .messageActionNoForwardsToggle(messageActionNoForwardsToggleData):
return TelegramMediaAction(action: .copyProtectionToggle(previousValue: messageActionNoForwardsToggleData.prevValue == .boolTrue, newValue: messageActionNoForwardsToggleData.newValue == .boolTrue))
case let .messageActionNoForwardsRequest(messageActionNoForwardsRequestData):
return TelegramMediaAction(action: .copyProtectionRequest(hasExpired: (messageActionNoForwardsRequestData.flags & (1 << 0)) != 0, previousValue: messageActionNoForwardsRequestData.prevValue == .boolTrue, newValue: messageActionNoForwardsRequestData.newValue == .boolTrue))
}
}

View file

@ -2025,26 +2025,6 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
updatedState.updateStarGiftAuctionMyState(giftId: giftId, state: GiftAuctionContext.State.MyState(apiAuctionUserState: userState))
case let .updateEmojiGameInfo(updateEmojiGameInfoData):
updatedState.updateEmojiGameInfo(info: EmojiGameInfo(apiEmojiGameInfo: updateEmojiGameInfoData.info))
case let .updatePeerHistoryNoForwards(updatePeerHistoryNoForwardsData):
let (flags, peer) = (updatePeerHistoryNoForwardsData.flags, updatePeerHistoryNoForwardsData.peer)
let peerId = peer.peerId
updatedState.updateCachedPeerData(peerId, { current in
if let previous = current as? CachedUserData {
var updatedFlags = previous.flags
if (flags & (1 << 0)) != 0 {
updatedFlags.insert(.myCopyProtectionEnabled)
} else {
updatedFlags.remove(.myCopyProtectionEnabled)
}
if (flags & (1 << 1)) != 0 {
updatedFlags.insert(.copyProtectionEnabled)
} else {
updatedFlags.remove(.copyProtectionEnabled)
}
return previous.withUpdatedFlags(updatedFlags)
}
return current
})
default:
break
}
@ -4321,6 +4301,19 @@ func replayFinalState(
}
})
}
case let .copyProtectionToggle(_, newValue):
transaction.updatePeerCachedData(peerIds: [message.id.peerId], update: { peerId, current in
if let previous = current as? CachedUserData {
var updatedFlags = previous.flags
if newValue {
updatedFlags.insert(.copyProtectionEnabled)
} else {
updatedFlags.remove(.copyProtectionEnabled)
}
return previous.withUpdatedFlags(updatedFlags)
}
return current
})
default:
break
}

View file

@ -302,6 +302,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
case starGiftPurchaseOffer(gift: StarGift, amount: CurrencyAmount, expireDate: Int32, isAccepted: Bool, isDeclined: Bool)
case starGiftPurchaseOfferDeclined(gift: StarGift, amount: CurrencyAmount, hasExpired: Bool)
case groupCreatorChange(GroupCreatorChange)
case copyProtectionToggle(previousValue: Bool, newValue: Bool)
case copyProtectionRequest(hasExpired: Bool, previousValue: Bool, newValue: Bool)
public init(decoder: PostboxDecoder) {
let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0)
@ -475,6 +477,10 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
self = .starGiftPurchaseOfferDeclined(gift: decoder.decodeObjectForKey("gift", decoder: { StarGift(decoder: $0) }) as! StarGift, amount: decoder.decodeCodable(CurrencyAmount.self, forKey: "amount")!, hasExpired: decoder.decodeBoolForKey("hasExpired", orElse: false))
case 59:
self = .groupCreatorChange(decoder.decodeCodable(GroupCreatorChange.self, forKey: "d") ?? GroupCreatorChange(kind: .pending, targetPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(0))))
case 60:
self = .copyProtectionToggle(previousValue: decoder.decodeBoolForKey("previousValue", orElse: false), newValue: decoder.decodeBoolForKey("newValue", orElse: false))
case 61:
self = .copyProtectionRequest(hasExpired: decoder.decodeBoolForKey("hasExpired", orElse: false), previousValue: decoder.decodeBoolForKey("previousValue", orElse: false), newValue: decoder.decodeBoolForKey("newValue", orElse: false))
default:
self = .unknown
}
@ -969,6 +975,15 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
case let .groupCreatorChange(groupCreatorChange):
encoder.encodeInt32(59, forKey: "_rawValue")
encoder.encodeCodable(groupCreatorChange, forKey: "d")
case let .copyProtectionToggle(previousValue, newValue):
encoder.encodeInt32(60, forKey: "_rawValue")
encoder.encodeBool(previousValue, forKey: "previousValue")
encoder.encodeBool(newValue, forKey: "newValue")
case let .copyProtectionRequest(hasExpired, previousValue, newValue):
encoder.encodeInt32(61, forKey: "_rawValue")
encoder.encodeBool(hasExpired, forKey: "hasExpired")
encoder.encodeBool(previousValue, forKey: "previousValue")
encoder.encodeBool(newValue, forKey: "newValue")
}
}

View file

@ -4,10 +4,14 @@ import SwiftSignalKit
import TelegramApi
import MtProtoKit
func _internal_toggleMessageCopyProtection(account: Account, peerId: PeerId, enabled: Bool) -> Signal<Void, NoError> {
func _internal_toggleMessageCopyProtection(account: Account, peerId: PeerId, enabled: Bool, requestMessageId: EngineMessage.Id?) -> Signal<Void, NoError> {
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
return account.network.request(Api.functions.messages.toggleNoForwards(peer: inputPeer, enabled: enabled ? .boolTrue : .boolFalse)) |> `catch` { _ in .complete() } |> map { updates -> Void in
var flags: Int32 = 0
if let _ = requestMessageId {
flags = (1 << 0)
}
return account.network.request(Api.functions.messages.toggleNoForwards(flags: flags, peer: inputPeer, enabled: enabled ? .boolTrue : .boolFalse, requestMsgId: requestMessageId?.id)) |> `catch` { _ in .complete() } |> map { updates -> Void in
account.stateManager.addUpdates(updates)
}
} else {

View file

@ -505,8 +505,8 @@ public extension TelegramEngine {
return _internal_toggleShouldChannelMessagesSignatures(account: self.account, peerId: peerId, signaturesEnabled: signaturesEnabled, profilesEnabled: profilesEnabled)
}
public func toggleMessageCopyProtection(peerId: PeerId, enabled: Bool) -> Signal<Void, NoError> {
return _internal_toggleMessageCopyProtection(account: self.account, peerId: peerId, enabled: enabled)
public func toggleMessageCopyProtection(peerId: PeerId, enabled: Bool, requestMessageId: EngineMessage.Id? = nil) -> Signal<Void, NoError> {
return _internal_toggleMessageCopyProtection(account: self.account, peerId: peerId, enabled: enabled, requestMessageId: requestMessageId)
}
public func toggleChannelJoinToSend(peerId: PeerId, enabled: Bool) -> Signal<Never, UpdateChannelJoinToSendError> {

View file

@ -1754,6 +1754,31 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
case .applied:
attributedString = addAttributesToStringWithRanges(strings.Notification_GroupCreatorChangeApplied(authorName, targetName)._tuple, body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id), (1, groupCreatorChange.targetPeerId)]))
}
case let .copyProtectionToggle(previousValue, newValue):
//TODO:localize
if previousValue == newValue && newValue {
attributedString = NSAttributedString(string: strings.Notification_CopyProtection_StillEnabled, font: titleFont, textColor: primaryTextColor)
} else if message.author?.id == accountPeerId {
if newValue {
attributedString = NSAttributedString(string: strings.Notification_CopyProtection_EnabledYou, font: titleFont, textColor: primaryTextColor)
} else {
attributedString = NSAttributedString(string: strings.Notification_CopyProtection_DisabledYou, font: titleFont, textColor: primaryTextColor)
}
} else {
let peerName = message.peers[message.id.peerId].flatMap { EnginePeer($0) }?.compactDisplayTitle ?? ""
let peerIds: [(Int, EnginePeer.Id?)] = [(0, message.id.peerId)]
let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
if newValue {
attributedString = addAttributesToStringWithRanges(strings.Notification_CopyProtection_Enabled(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)
} else {
attributedString = addAttributesToStringWithRanges(strings.Notification_CopyProtection_Disabled(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)
}
}
case let .copyProtectionRequest(hasExpired, previousValue, newValue):
let _ = hasExpired
let _ = previousValue
let _ = newValue
attributedString = nil
case .unknown:
attributedString = nil
}