# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
This commit is contained in:
overtake 2019-03-14 18:18:55 +04:00
commit 1af54d6fb3
27 changed files with 458 additions and 141 deletions

View File

@ -2348,7 +2348,7 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
transaction.updateMessage(id, update: { currentMessage in transaction.updateMessage(id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
var attributes = currentMessage.attributes var attributes = currentMessage.attributes
loop: for j in 0 ..< attributes.count { loop: for j in 0 ..< attributes.count {
@ -2442,7 +2442,7 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
} }
switch set { switch set {
case let .stickerSet(flags, _, _, _, _, _, _, _): case let .stickerSet(flags, _, _, _, _, _, _, _, _):
if (flags & (1 << 3)) != 0 { if (flags & (1 << 3)) != 0 {
namespace = Namespaces.ItemCollection.CloudMaskPacks namespace = Namespaces.ItemCollection.CloudMaskPacks
} else { } else {

View File

@ -339,7 +339,7 @@ public final class AccountViewTracker {
transaction.updateMessage(messageId, update: { currentMessage in transaction.updateMessage(messageId, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
var media = currentMessage.media var media = currentMessage.media
for i in 0 ..< media.count { for i in 0 ..< media.count {
@ -528,7 +528,7 @@ public final class AccountViewTracker {
transaction.updateMessage(messageIds[i], update: { currentMessage in transaction.updateMessage(messageIds[i], update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
var attributes = currentMessage.attributes var attributes = currentMessage.attributes
loop: for j in 0 ..< attributes.count { loop: for j in 0 ..< attributes.count {

View File

@ -105,6 +105,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1000708810] = { return Api.help.AppUpdate.parse_noAppUpdate($0) } dict[-1000708810] = { return Api.help.AppUpdate.parse_noAppUpdate($0) }
dict[-209337866] = { return Api.LangPackDifference.parse_langPackDifference($0) } dict[-209337866] = { return Api.LangPackDifference.parse_langPackDifference($0) }
dict[-1590738760] = { return Api.WallPaperSettings.parse_wallPaperSettings($0) } dict[-1590738760] = { return Api.WallPaperSettings.parse_wallPaperSettings($0) }
dict[1152191385] = { return Api.EmojiURL.parse_EmojiURL($0) }
dict[-791039645] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) } dict[-791039645] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) }
dict[-1736378792] = { return Api.InputCheckPasswordSRP.parse_inputCheckPasswordEmpty($0) } dict[-1736378792] = { return Api.InputCheckPasswordSRP.parse_inputCheckPasswordEmpty($0) }
dict[-763367294] = { return Api.InputCheckPasswordSRP.parse_inputCheckPasswordSRP($0) } dict[-763367294] = { return Api.InputCheckPasswordSRP.parse_inputCheckPasswordSRP($0) }
@ -157,6 +158,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1343122938] = { return Api.PrivacyKey.parse_privacyKeyChatInvite($0) } dict[1343122938] = { return Api.PrivacyKey.parse_privacyKeyChatInvite($0) }
dict[1030105979] = { return Api.PrivacyKey.parse_privacyKeyPhoneCall($0) } dict[1030105979] = { return Api.PrivacyKey.parse_privacyKeyPhoneCall($0) }
dict[961092808] = { return Api.PrivacyKey.parse_privacyKeyPhoneP2P($0) } dict[961092808] = { return Api.PrivacyKey.parse_privacyKeyPhoneP2P($0) }
dict[1777096355] = { return Api.PrivacyKey.parse_privacyKeyForwards($0) }
dict[-1777000467] = { return Api.PrivacyKey.parse_privacyKeyProfilePhoto($0) }
dict[522914557] = { return Api.Update.parse_updateNewMessage($0) } dict[522914557] = { return Api.Update.parse_updateNewMessage($0) }
dict[1318109142] = { return Api.Update.parse_updateMessageID($0) } dict[1318109142] = { return Api.Update.parse_updateMessageID($0) }
dict[-1576161051] = { return Api.Update.parse_updateDeleteMessages($0) } dict[-1576161051] = { return Api.Update.parse_updateDeleteMessages($0) }
@ -286,7 +289,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1098628881] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaVenue($0) } dict[1098628881] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaVenue($0) }
dict[-1494368259] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaContact($0) } dict[-1494368259] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaContact($0) }
dict[2002815875] = { return Api.KeyboardButtonRow.parse_keyboardButtonRow($0) } dict[2002815875] = { return Api.KeyboardButtonRow.parse_keyboardButtonRow($0) }
dict[1434820921] = { return Api.StickerSet.parse_stickerSet($0) } dict[1787870391] = { return Api.StickerSet.parse_stickerSet($0) }
dict[354925740] = { return Api.SecureSecretSettings.parse_secureSecretSettings($0) } dict[354925740] = { return Api.SecureSecretSettings.parse_secureSecretSettings($0) }
dict[539045032] = { return Api.photos.Photo.parse_photo($0) } dict[539045032] = { return Api.photos.Photo.parse_photo($0) }
dict[-208488460] = { return Api.InputContact.parse_inputPhoneContact($0) } dict[-208488460] = { return Api.InputContact.parse_inputPhoneContact($0) }
@ -413,11 +416,14 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1107622874] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyChatInvite($0) } dict[-1107622874] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyChatInvite($0) }
dict[-88417185] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneCall($0) } dict[-88417185] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneCall($0) }
dict[-610373422] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneP2P($0) } dict[-610373422] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneP2P($0) }
dict[-1529000952] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyForwards($0) }
dict[1461304012] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyProfilePhoto($0) }
dict[235081943] = { return Api.help.RecentMeUrls.parse_recentMeUrls($0) } dict[235081943] = { return Api.help.RecentMeUrls.parse_recentMeUrls($0) }
dict[-1606526075] = { return Api.ReplyMarkup.parse_replyKeyboardHide($0) } dict[-1606526075] = { return Api.ReplyMarkup.parse_replyKeyboardHide($0) }
dict[-200242528] = { return Api.ReplyMarkup.parse_replyKeyboardForceReply($0) } dict[-200242528] = { return Api.ReplyMarkup.parse_replyKeyboardForceReply($0) }
dict[889353612] = { return Api.ReplyMarkup.parse_replyKeyboardMarkup($0) } dict[889353612] = { return Api.ReplyMarkup.parse_replyKeyboardMarkup($0) }
dict[1218642516] = { return Api.ReplyMarkup.parse_replyInlineMarkup($0) } dict[1218642516] = { return Api.ReplyMarkup.parse_replyInlineMarkup($0) }
dict[1556570557] = { return Api.EmojiKeywordsDifference.parse_emojiKeywordsDifference($0) }
dict[1493171408] = { return Api.HighScore.parse_highScore($0) } dict[1493171408] = { return Api.HighScore.parse_highScore($0) }
dict[-305282981] = { return Api.TopPeer.parse_topPeer($0) } dict[-305282981] = { return Api.TopPeer.parse_topPeer($0) }
dict[986597452] = { return Api.contacts.Link.parse_link($0) } dict[986597452] = { return Api.contacts.Link.parse_link($0) }
@ -564,7 +570,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1036396922] = { return Api.InputWebFileLocation.parse_inputWebFileLocation($0) } dict[-1036396922] = { return Api.InputWebFileLocation.parse_inputWebFileLocation($0) }
dict[1430205163] = { return Api.InputWebFileLocation.parse_inputWebFileGeoMessageLocation($0) } dict[1430205163] = { return Api.InputWebFileLocation.parse_inputWebFileGeoMessageLocation($0) }
dict[-1625153079] = { return Api.InputWebFileLocation.parse_inputWebFileGeoPointLocation($0) } dict[-1625153079] = { return Api.InputWebFileLocation.parse_inputWebFileGeoPointLocation($0) }
dict[1436466797] = { return Api.MessageFwdHeader.parse_messageFwdHeader($0) } dict[-332168592] = { return Api.MessageFwdHeader.parse_messageFwdHeader($0) }
dict[398898678] = { return Api.help.Support.parse_support($0) } dict[398898678] = { return Api.help.Support.parse_support($0) }
dict[1474492012] = { return Api.MessagesFilter.parse_inputMessagesFilterEmpty($0) } dict[1474492012] = { return Api.MessagesFilter.parse_inputMessagesFilterEmpty($0) }
dict[-1777752804] = { return Api.MessagesFilter.parse_inputMessagesFilterPhotos($0) } dict[-1777752804] = { return Api.MessagesFilter.parse_inputMessagesFilterPhotos($0) }
@ -587,6 +593,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[364538944] = { return Api.messages.Dialogs.parse_dialogs($0) } dict[364538944] = { return Api.messages.Dialogs.parse_dialogs($0) }
dict[1910543603] = { return Api.messages.Dialogs.parse_dialogsSlice($0) } dict[1910543603] = { return Api.messages.Dialogs.parse_dialogsSlice($0) }
dict[-253500010] = { return Api.messages.Dialogs.parse_dialogsNotModified($0) } dict[-253500010] = { return Api.messages.Dialogs.parse_dialogsNotModified($0) }
dict[-709641735] = { return Api.EmojiKeyword.parse_emojiKeyword($0) }
dict[594408994] = { return Api.EmojiKeyword.parse_emojiKeywordDeleted($0) }
dict[-290921362] = { return Api.upload.CdnFile.parse_cdnFileReuploadNeeded($0) } dict[-290921362] = { return Api.upload.CdnFile.parse_cdnFileReuploadNeeded($0) }
dict[-1449145777] = { return Api.upload.CdnFile.parse_cdnFile($0) } dict[-1449145777] = { return Api.upload.CdnFile.parse_cdnFile($0) }
dict[415997816] = { return Api.help.InviteText.parse_inviteText($0) } dict[415997816] = { return Api.help.InviteText.parse_inviteText($0) }
@ -844,6 +852,8 @@ struct Api {
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.WallPaperSettings: case let _1 as Api.WallPaperSettings:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.EmojiURL:
_1.serialize(buffer, boxed)
case let _1 as Api.channels.ChannelParticipant: case let _1 as Api.channels.ChannelParticipant:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.InputCheckPasswordSRP: case let _1 as Api.InputCheckPasswordSRP:
@ -1024,6 +1034,8 @@ struct Api {
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.ReplyMarkup: case let _1 as Api.ReplyMarkup:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.EmojiKeywordsDifference:
_1.serialize(buffer, boxed)
case let _1 as Api.HighScore: case let _1 as Api.HighScore:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.TopPeer: case let _1 as Api.TopPeer:
@ -1184,6 +1196,8 @@ struct Api {
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.messages.Dialogs: case let _1 as Api.messages.Dialogs:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.EmojiKeyword:
_1.serialize(buffer, boxed)
case let _1 as Api.upload.CdnFile: case let _1 as Api.upload.CdnFile:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.help.InviteText: case let _1 as Api.help.InviteText:

View File

@ -2882,6 +2882,40 @@ extension Api {
} }
} }
}
enum EmojiURL: TypeConstructorDescription {
case EmojiURL(url: String)
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .EmojiURL(let url):
if boxed {
buffer.appendInt32(1152191385)
}
serializeString(url, buffer: buffer, boxed: false)
break
}
}
func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .EmojiURL(let url):
return ("EmojiURL", [("url", url)])
}
}
static func parse_EmojiURL(_ reader: BufferReader) -> EmojiURL? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.EmojiURL.EmojiURL(url: _1!)
}
else {
return nil
}
}
} }
enum InputCheckPasswordSRP: TypeConstructorDescription { enum InputCheckPasswordSRP: TypeConstructorDescription {
case inputCheckPasswordEmpty case inputCheckPasswordEmpty
@ -3678,6 +3712,8 @@ extension Api {
case privacyKeyChatInvite case privacyKeyChatInvite
case privacyKeyPhoneCall case privacyKeyPhoneCall
case privacyKeyPhoneP2P case privacyKeyPhoneP2P
case privacyKeyForwards
case privacyKeyProfilePhoto
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
@ -3704,6 +3740,18 @@ extension Api {
buffer.appendInt32(961092808) buffer.appendInt32(961092808)
} }
break
case .privacyKeyForwards:
if boxed {
buffer.appendInt32(1777096355)
}
break
case .privacyKeyProfilePhoto:
if boxed {
buffer.appendInt32(-1777000467)
}
break break
} }
} }
@ -3718,6 +3766,10 @@ extension Api {
return ("privacyKeyPhoneCall", []) return ("privacyKeyPhoneCall", [])
case .privacyKeyPhoneP2P: case .privacyKeyPhoneP2P:
return ("privacyKeyPhoneP2P", []) return ("privacyKeyPhoneP2P", [])
case .privacyKeyForwards:
return ("privacyKeyForwards", [])
case .privacyKeyProfilePhoto:
return ("privacyKeyProfilePhoto", [])
} }
} }
@ -3733,6 +3785,12 @@ extension Api {
static func parse_privacyKeyPhoneP2P(_ reader: BufferReader) -> PrivacyKey? { static func parse_privacyKeyPhoneP2P(_ reader: BufferReader) -> PrivacyKey? {
return Api.PrivacyKey.privacyKeyPhoneP2P return Api.PrivacyKey.privacyKeyPhoneP2P
} }
static func parse_privacyKeyForwards(_ reader: BufferReader) -> PrivacyKey? {
return Api.PrivacyKey.privacyKeyForwards
}
static func parse_privacyKeyProfilePhoto(_ reader: BufferReader) -> PrivacyKey? {
return Api.PrivacyKey.privacyKeyProfilePhoto
}
} }
enum Update: TypeConstructorDescription { enum Update: TypeConstructorDescription {
@ -7296,13 +7354,13 @@ extension Api {
} }
enum StickerSet: TypeConstructorDescription { enum StickerSet: TypeConstructorDescription {
case stickerSet(flags: Int32, installedDate: Int32?, id: Int64, accessHash: Int64, title: String, shortName: String, count: Int32, hash: Int32) case stickerSet(flags: Int32, installedDate: Int32?, id: Int64, accessHash: Int64, title: String, shortName: String, thumb: Api.PhotoSize?, count: Int32, hash: Int32)
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .stickerSet(let flags, let installedDate, let id, let accessHash, let title, let shortName, let count, let hash): case .stickerSet(let flags, let installedDate, let id, let accessHash, let title, let shortName, let thumb, let count, let hash):
if boxed { if boxed {
buffer.appendInt32(1434820921) buffer.appendInt32(1787870391)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(installedDate!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(installedDate!, buffer: buffer, boxed: false)}
@ -7310,6 +7368,7 @@ extension Api {
serializeInt64(accessHash, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false)
serializeString(shortName, buffer: buffer, boxed: false) serializeString(shortName, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 4) != 0 {thumb!.serialize(buffer, true)}
serializeInt32(count, buffer: buffer, boxed: false) serializeInt32(count, buffer: buffer, boxed: false)
serializeInt32(hash, buffer: buffer, boxed: false) serializeInt32(hash, buffer: buffer, boxed: false)
break break
@ -7318,8 +7377,8 @@ extension Api {
func descriptionFields() -> (String, [(String, Any)]) { func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .stickerSet(let flags, let installedDate, let id, let accessHash, let title, let shortName, let count, let hash): case .stickerSet(let flags, let installedDate, let id, let accessHash, let title, let shortName, let thumb, let count, let hash):
return ("stickerSet", [("flags", flags), ("installedDate", installedDate), ("id", id), ("accessHash", accessHash), ("title", title), ("shortName", shortName), ("count", count), ("hash", hash)]) return ("stickerSet", [("flags", flags), ("installedDate", installedDate), ("id", id), ("accessHash", accessHash), ("title", title), ("shortName", shortName), ("thumb", thumb), ("count", count), ("hash", hash)])
} }
} }
@ -7336,20 +7395,25 @@ extension Api {
_5 = parseString(reader) _5 = parseString(reader)
var _6: String? var _6: String?
_6 = parseString(reader) _6 = parseString(reader)
var _7: Int32? var _7: Api.PhotoSize?
_7 = reader.readInt32() if Int(_1!) & Int(1 << 4) != 0 {if let signature = reader.readInt32() {
_7 = Api.parse(reader, signature: signature) as? Api.PhotoSize
} }
var _8: Int32? var _8: Int32?
_8 = reader.readInt32() _8 = reader.readInt32()
var _9: Int32?
_9 = reader.readInt32()
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = _3 != nil let _c3 = _3 != nil
let _c4 = _4 != nil let _c4 = _4 != nil
let _c5 = _5 != nil let _c5 = _5 != nil
let _c6 = _6 != nil let _c6 = _6 != nil
let _c7 = _7 != nil let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil
let _c8 = _8 != nil let _c8 = _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { let _c9 = _9 != nil
return Api.StickerSet.stickerSet(flags: _1!, installedDate: _2, id: _3!, accessHash: _4!, title: _5!, shortName: _6!, count: _7!, hash: _8!) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
return Api.StickerSet.stickerSet(flags: _1!, installedDate: _2, id: _3!, accessHash: _4!, title: _5!, shortName: _6!, thumb: _7, count: _8!, hash: _9!)
} }
else { else {
return nil return nil
@ -10094,6 +10158,8 @@ extension Api {
case inputPrivacyKeyChatInvite case inputPrivacyKeyChatInvite
case inputPrivacyKeyPhoneCall case inputPrivacyKeyPhoneCall
case inputPrivacyKeyPhoneP2P case inputPrivacyKeyPhoneP2P
case inputPrivacyKeyForwards
case inputPrivacyKeyProfilePhoto
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
@ -10120,6 +10186,18 @@ extension Api {
buffer.appendInt32(-610373422) buffer.appendInt32(-610373422)
} }
break
case .inputPrivacyKeyForwards:
if boxed {
buffer.appendInt32(-1529000952)
}
break
case .inputPrivacyKeyProfilePhoto:
if boxed {
buffer.appendInt32(1461304012)
}
break break
} }
} }
@ -10134,6 +10212,10 @@ extension Api {
return ("inputPrivacyKeyPhoneCall", []) return ("inputPrivacyKeyPhoneCall", [])
case .inputPrivacyKeyPhoneP2P: case .inputPrivacyKeyPhoneP2P:
return ("inputPrivacyKeyPhoneP2P", []) return ("inputPrivacyKeyPhoneP2P", [])
case .inputPrivacyKeyForwards:
return ("inputPrivacyKeyForwards", [])
case .inputPrivacyKeyProfilePhoto:
return ("inputPrivacyKeyProfilePhoto", [])
} }
} }
@ -10149,6 +10231,12 @@ extension Api {
static func parse_inputPrivacyKeyPhoneP2P(_ reader: BufferReader) -> InputPrivacyKey? { static func parse_inputPrivacyKeyPhoneP2P(_ reader: BufferReader) -> InputPrivacyKey? {
return Api.InputPrivacyKey.inputPrivacyKeyPhoneP2P return Api.InputPrivacyKey.inputPrivacyKeyPhoneP2P
} }
static func parse_inputPrivacyKeyForwards(_ reader: BufferReader) -> InputPrivacyKey? {
return Api.InputPrivacyKey.inputPrivacyKeyForwards
}
static func parse_inputPrivacyKeyProfilePhoto(_ reader: BufferReader) -> InputPrivacyKey? {
return Api.InputPrivacyKey.inputPrivacyKeyProfilePhoto
}
} }
enum ReplyMarkup: TypeConstructorDescription { enum ReplyMarkup: TypeConstructorDescription {
@ -10260,6 +10348,58 @@ extension Api {
} }
} }
}
enum EmojiKeywordsDifference: TypeConstructorDescription {
case emojiKeywordsDifference(langCode: String, fromVersion: Int32, version: Int32, keywords: [Api.EmojiKeyword])
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .emojiKeywordsDifference(let langCode, let fromVersion, let version, let keywords):
if boxed {
buffer.appendInt32(1556570557)
}
serializeString(langCode, buffer: buffer, boxed: false)
serializeInt32(fromVersion, buffer: buffer, boxed: false)
serializeInt32(version, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(keywords.count))
for item in keywords {
item.serialize(buffer, true)
}
break
}
}
func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .emojiKeywordsDifference(let langCode, let fromVersion, let version, let keywords):
return ("emojiKeywordsDifference", [("langCode", langCode), ("fromVersion", fromVersion), ("version", version), ("keywords", keywords)])
}
}
static func parse_emojiKeywordsDifference(_ reader: BufferReader) -> EmojiKeywordsDifference? {
var _1: String?
_1 = parseString(reader)
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: [Api.EmojiKeyword]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.EmojiKeyword.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.EmojiKeywordsDifference.emojiKeywordsDifference(langCode: _1!, fromVersion: _2!, version: _3!, keywords: _4!)
}
else {
return nil
}
}
} }
enum HighScore: TypeConstructorDescription { enum HighScore: TypeConstructorDescription {
case highScore(pos: Int32, userId: Int32, score: Int32) case highScore(pos: Int32, userId: Int32, score: Int32)
@ -14526,16 +14666,17 @@ extension Api {
} }
enum MessageFwdHeader: TypeConstructorDescription { enum MessageFwdHeader: TypeConstructorDescription {
case messageFwdHeader(flags: Int32, fromId: Int32?, date: Int32, channelId: Int32?, channelPost: Int32?, postAuthor: String?, savedFromPeer: Api.Peer?, savedFromMsgId: Int32?) case messageFwdHeader(flags: Int32, fromId: Int32?, fromName: String?, date: Int32, channelId: Int32?, channelPost: Int32?, postAuthor: String?, savedFromPeer: Api.Peer?, savedFromMsgId: Int32?)
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .messageFwdHeader(let flags, let fromId, let date, let channelId, let channelPost, let postAuthor, let savedFromPeer, let savedFromMsgId): case .messageFwdHeader(let flags, let fromId, let fromName, let date, let channelId, let channelPost, let postAuthor, let savedFromPeer, let savedFromMsgId):
if boxed { if boxed {
buffer.appendInt32(1436466797) buffer.appendInt32(-332168592)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(fromId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(fromId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 5) != 0 {serializeString(fromName!, buffer: buffer, boxed: false)}
serializeInt32(date, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(channelId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {serializeInt32(channelId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(channelPost!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 2) != 0 {serializeInt32(channelPost!, buffer: buffer, boxed: false)}
@ -14548,8 +14689,8 @@ extension Api {
func descriptionFields() -> (String, [(String, Any)]) { func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .messageFwdHeader(let flags, let fromId, let date, let channelId, let channelPost, let postAuthor, let savedFromPeer, let savedFromMsgId): case .messageFwdHeader(let flags, let fromId, let fromName, let date, let channelId, let channelPost, let postAuthor, let savedFromPeer, let savedFromMsgId):
return ("messageFwdHeader", [("flags", flags), ("fromId", fromId), ("date", date), ("channelId", channelId), ("channelPost", channelPost), ("postAuthor", postAuthor), ("savedFromPeer", savedFromPeer), ("savedFromMsgId", savedFromMsgId)]) return ("messageFwdHeader", [("flags", flags), ("fromId", fromId), ("fromName", fromName), ("date", date), ("channelId", channelId), ("channelPost", channelPost), ("postAuthor", postAuthor), ("savedFromPeer", savedFromPeer), ("savedFromMsgId", savedFromMsgId)])
} }
} }
@ -14558,30 +14699,33 @@ extension Api {
_1 = reader.readInt32() _1 = reader.readInt32()
var _2: Int32? var _2: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() } if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() }
var _3: Int32? var _3: String?
_3 = reader.readInt32() if Int(_1!) & Int(1 << 5) != 0 {_3 = parseString(reader) }
var _4: Int32? var _4: Int32?
if Int(_1!) & Int(1 << 1) != 0 {_4 = reader.readInt32() } _4 = reader.readInt32()
var _5: Int32? var _5: Int32?
if Int(_1!) & Int(1 << 2) != 0 {_5 = reader.readInt32() } if Int(_1!) & Int(1 << 1) != 0 {_5 = reader.readInt32() }
var _6: String? var _6: Int32?
if Int(_1!) & Int(1 << 3) != 0 {_6 = parseString(reader) } if Int(_1!) & Int(1 << 2) != 0 {_6 = reader.readInt32() }
var _7: Api.Peer? var _7: String?
if Int(_1!) & Int(1 << 3) != 0 {_7 = parseString(reader) }
var _8: Api.Peer?
if Int(_1!) & Int(1 << 4) != 0 {if let signature = reader.readInt32() { if Int(_1!) & Int(1 << 4) != 0 {if let signature = reader.readInt32() {
_7 = Api.parse(reader, signature: signature) as? Api.Peer _8 = Api.parse(reader, signature: signature) as? Api.Peer
} } } }
var _8: Int32? var _9: Int32?
if Int(_1!) & Int(1 << 4) != 0 {_8 = reader.readInt32() } if Int(_1!) & Int(1 << 4) != 0 {_9 = reader.readInt32() }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = _3 != nil let _c3 = (Int(_1!) & Int(1 << 5) == 0) || _3 != nil
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil let _c7 = (Int(_1!) & Int(1 << 3) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 4) == 0) || _8 != nil let _c8 = (Int(_1!) & Int(1 << 4) == 0) || _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { let _c9 = (Int(_1!) & Int(1 << 4) == 0) || _9 != nil
return Api.MessageFwdHeader.messageFwdHeader(flags: _1!, fromId: _2, date: _3!, channelId: _4, channelPost: _5, postAuthor: _6, savedFromPeer: _7, savedFromMsgId: _8) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
return Api.MessageFwdHeader.messageFwdHeader(flags: _1!, fromId: _2, fromName: _3, date: _4!, channelId: _5, channelPost: _6, postAuthor: _7, savedFromPeer: _8, savedFromMsgId: _9)
} }
else { else {
return nil return nil
@ -14826,6 +14970,80 @@ extension Api {
return Api.MessagesFilter.inputMessagesFilterContacts return Api.MessagesFilter.inputMessagesFilterContacts
} }
}
enum EmojiKeyword: TypeConstructorDescription {
case emojiKeyword(keyword: String, emoticons: [String])
case emojiKeywordDeleted(keyword: String, emoticons: [String])
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .emojiKeyword(let keyword, let emoticons):
if boxed {
buffer.appendInt32(-709641735)
}
serializeString(keyword, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(emoticons.count))
for item in emoticons {
serializeString(item, buffer: buffer, boxed: false)
}
break
case .emojiKeywordDeleted(let keyword, let emoticons):
if boxed {
buffer.appendInt32(594408994)
}
serializeString(keyword, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(emoticons.count))
for item in emoticons {
serializeString(item, buffer: buffer, boxed: false)
}
break
}
}
func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .emojiKeyword(let keyword, let emoticons):
return ("emojiKeyword", [("keyword", keyword), ("emoticons", emoticons)])
case .emojiKeywordDeleted(let keyword, let emoticons):
return ("emojiKeywordDeleted", [("keyword", keyword), ("emoticons", emoticons)])
}
}
static func parse_emojiKeyword(_ reader: BufferReader) -> EmojiKeyword? {
var _1: String?
_1 = parseString(reader)
var _2: [String]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.EmojiKeyword.emojiKeyword(keyword: _1!, emoticons: _2!)
}
else {
return nil
}
}
static func parse_emojiKeywordDeleted(_ reader: BufferReader) -> EmojiKeyword? {
var _1: String?
_1 = parseString(reader)
var _2: [String]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.EmojiKeyword.emojiKeywordDeleted(keyword: _1!, emoticons: _2!)
}
else {
return nil
}
}
} }
enum BotInlineMessage: TypeConstructorDescription { enum BotInlineMessage: TypeConstructorDescription {
case botInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?) case botInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?)

View File

@ -2846,6 +2846,49 @@ extension Api {
return result return result
}) })
} }
static func getEmojiKeywords(langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.EmojiKeywordsDifference>) {
let buffer = Buffer()
buffer.appendInt32(899735650)
serializeString(langCode, buffer: buffer, boxed: false)
return (FunctionDescription(name: "messages.getEmojiKeywords", parameters: [("langCode", langCode)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.EmojiKeywordsDifference? in
let reader = BufferReader(buffer)
var result: Api.EmojiKeywordsDifference?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.EmojiKeywordsDifference
}
return result
})
}
static func getEmojiKeywordsDifference(langCode: String, fromVersion: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.EmojiKeywordsDifference>) {
let buffer = Buffer()
buffer.appendInt32(352892591)
serializeString(langCode, buffer: buffer, boxed: false)
serializeInt32(fromVersion, buffer: buffer, boxed: false)
return (FunctionDescription(name: "messages.getEmojiKeywordsDifference", parameters: [("langCode", langCode), ("fromVersion", fromVersion)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.EmojiKeywordsDifference? in
let reader = BufferReader(buffer)
var result: Api.EmojiKeywordsDifference?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.EmojiKeywordsDifference
}
return result
})
}
static func getEmojiURL(langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.EmojiURL>) {
let buffer = Buffer()
buffer.appendInt32(-709817306)
serializeString(langCode, buffer: buffer, boxed: false)
return (FunctionDescription(name: "messages.getEmojiURL", parameters: [("langCode", langCode)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.EmojiURL? in
let reader = BufferReader(buffer)
var result: Api.EmojiURL?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.EmojiURL
}
return result
})
}
} }
struct channels { struct channels {
static func readHistory(channel: Api.InputChannel, maxId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) { static func readHistory(channel: Api.InputChannel, maxId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {

View File

@ -25,7 +25,7 @@ func applyMaxReadIndexInteractively(transaction: Transaction, stateManager: Acco
transaction.updateMessage(message.id, update: { currentMessage in transaction.updateMessage(message.id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
let updatedAttributes = currentMessage.attributes.map({ currentAttribute -> MessageAttribute in let updatedAttributes = currentMessage.attributes.map({ currentAttribute -> MessageAttribute in
if let currentAttribute = currentAttribute as? AutoremoveTimeoutMessageAttribute { if let currentAttribute = currentAttribute as? AutoremoveTimeoutMessageAttribute {
@ -94,7 +94,7 @@ func applySecretOutgoingMessageReadActions(transaction: Transaction, id: Message
transaction.updateMessage(message.id, update: { currentMessage in transaction.updateMessage(message.id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
let updatedAttributes = currentMessage.attributes.map({ currentAttribute -> MessageAttribute in let updatedAttributes = currentMessage.attributes.map({ currentAttribute -> MessageAttribute in
if let currentAttribute = currentAttribute as? AutoremoveTimeoutMessageAttribute { if let currentAttribute = currentAttribute as? AutoremoveTimeoutMessageAttribute {

View File

@ -75,10 +75,12 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
let media: [Media] let media: [Media]
var attributes: [MessageAttribute] var attributes: [MessageAttribute]
let text: String let text: String
let forwardInfo: StoreMessageForwardInfo?
if let apiMessage = apiMessage, let updatedMessage = StoreMessage(apiMessage: apiMessage) { if let apiMessage = apiMessage, let updatedMessage = StoreMessage(apiMessage: apiMessage) {
media = updatedMessage.media media = updatedMessage.media
attributes = updatedMessage.attributes attributes = updatedMessage.attributes
text = updatedMessage.text text = updatedMessage.text
forwardInfo = updatedMessage.forwardInfo
} else if case let .updateShortSentMessage(_, _, _, _, _, apiMedia, entities) = result { } else if case let .updateShortSentMessage(_, _, _, _, _, apiMedia, entities) = result {
let (mediaValue, _) = textMediaAndExpirationTimerFromApiMedia(apiMedia, currentMessage.id.peerId) let (mediaValue, _) = textMediaAndExpirationTimerFromApiMedia(apiMedia, currentMessage.id.peerId)
if let mediaValue = mediaValue { if let mediaValue = mediaValue {
@ -100,10 +102,13 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
attributes = updatedAttributes attributes = updatedAttributes
text = currentMessage.text text = currentMessage.text
forwardInfo = currentMessage.forwardInfo.flatMap(StoreMessageForwardInfo.init)
} else { } else {
media = currentMessage.media media = currentMessage.media
attributes = currentMessage.attributes attributes = currentMessage.attributes
text = currentMessage.text text = currentMessage.text
forwardInfo = currentMessage.forwardInfo.flatMap(StoreMessageForwardInfo.init)
} }
if let channelPts = channelPts { if let channelPts = channelPts {
@ -116,16 +121,11 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
attributes.append(ChannelMessageStateVersionAttribute(pts: channelPts)) attributes.append(ChannelMessageStateVersionAttribute(pts: channelPts))
} }
var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
}
if let fromMedia = currentMessage.media.first, let toMedia = media.first { if let fromMedia = currentMessage.media.first, let toMedia = media.first {
applyMediaResourceChanges(from: fromMedia, to: toMedia, postbox: postbox) applyMediaResourceChanges(from: fromMedia, to: toMedia, postbox: postbox)
} }
if storeForwardInfo == nil { if forwardInfo == nil {
for media in media { for media in media {
if let file = media as? TelegramMediaFile { if let file = media as? TelegramMediaFile {
if file.isSticker { if file.isSticker {
@ -147,7 +147,7 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
let (tags, globalTags) = tagsForStoreMessage(incoming: currentMessage.flags.contains(.Incoming), attributes: attributes, media: media, textEntities: entitiesAttribute?.entities) let (tags, globalTags) = tagsForStoreMessage(incoming: currentMessage.flags.contains(.Incoming), attributes: attributes, media: media, textEntities: entitiesAttribute?.entities)
return .update(StoreMessage(id: updatedId, globallyUniqueId: nil, groupingKey: currentMessage.groupingKey, timestamp: updatedTimestamp ?? currentMessage.timestamp, flags: [], tags: tags, globalTags: globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: text, attributes: attributes, media: media)) return .update(StoreMessage(id: updatedId, globallyUniqueId: nil, groupingKey: currentMessage.groupingKey, timestamp: updatedTimestamp ?? currentMessage.timestamp, flags: [], tags: tags, globalTags: globalTags, localTags: currentMessage.localTags, forwardInfo: forwardInfo, authorId: currentMessage.author?.id, text: text, attributes: attributes, media: media))
}) })
for file in sentStickers { for file in sentStickers {
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentStickers, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 20) transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentStickers, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 20)
@ -229,7 +229,7 @@ func applyUpdateGroupMessages(postbox: Postbox, stateManager: AccountStateManage
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
if let fromMedia = currentMessage.media.first, let toMedia = media.first { if let fromMedia = currentMessage.media.first, let toMedia = media.first {

View File

@ -405,7 +405,7 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
attributes.append(contentsOf: filterMessageAttributesForForwardedMessage(sourceMessage.attributes)) attributes.append(contentsOf: filterMessageAttributesForForwardedMessage(sourceMessage.attributes))
if let sourceForwardInfo = sourceMessage.forwardInfo { if let sourceForwardInfo = sourceMessage.forwardInfo {
forwardInfo = StoreMessageForwardInfo(authorId: sourceForwardInfo.author.id, sourceId: sourceForwardInfo.source?.id, sourceMessageId: sourceForwardInfo.sourceMessageId, date: sourceForwardInfo.date, authorSignature: sourceForwardInfo.authorSignature) forwardInfo = StoreMessageForwardInfo(authorId: sourceForwardInfo.author?.id, sourceId: sourceForwardInfo.source?.id, sourceMessageId: sourceForwardInfo.sourceMessageId, date: sourceForwardInfo.date, authorSignature: sourceForwardInfo.authorSignature)
} else { } else {
if sourceMessage.id.peerId != account.peerId { if sourceMessage.id.peerId != account.peerId {
var hasHiddenForwardMedia = false var hasHiddenForwardMedia = false

View File

@ -460,7 +460,7 @@ private func validateBatch(postbox: Postbox, network: Network, accountPeerId: Pe
} else { } else {
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
var attributes = currentMessage.attributes var attributes = currentMessage.attributes
if let channelPts = channelPts { if let channelPts = channelPts {
@ -520,7 +520,7 @@ private func validateBatch(postbox: Postbox, network: Network, accountPeerId: Pe
transaction.updateMessage(id, update: { currentMessage in transaction.updateMessage(id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
var attributes = currentMessage.attributes var attributes = currentMessage.attributes
for i in (0 ..< attributes.count).reversed() { for i in (0 ..< attributes.count).reversed() {

View File

@ -45,7 +45,7 @@ func updatedRemoteStickerPack(postbox: Postbox, network: Network, reference: Sti
case let .stickerSet(set, packs, documents): case let .stickerSet(set, packs, documents):
let namespace: ItemCollectionId.Namespace let namespace: ItemCollectionId.Namespace
switch set { switch set {
case let .stickerSet(flags, _, _, _, _, _, _, _): case let .stickerSet(flags, _, _, _, _, _, _, _, _):
if (flags & (1 << 3)) != 0 { if (flags & (1 << 3)) != 0 {
namespace = Namespaces.ItemCollection.CloudMaskPacks namespace = Namespaces.ItemCollection.CloudMaskPacks
} else { } else {

View File

@ -71,7 +71,7 @@ func managedAutoremoveMessageOperations(postbox: Postbox) -> Signal<Void, NoErro
transaction.updateMessage(message.id, update: { currentMessage in transaction.updateMessage(message.id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
var updatedMedia = currentMessage.media var updatedMedia = currentMessage.media
for i in 0 ..< updatedMedia.count { for i in 0 ..< updatedMedia.count {

View File

@ -174,7 +174,7 @@ private func synchronizeConsumeMessageContents(transaction: Transaction, postbox
transaction.updateMessage(id, update: { currentMessage in transaction.updateMessage(id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
var attributes = currentMessage.attributes var attributes = currentMessage.attributes
loop: for j in 0 ..< attributes.count { loop: for j in 0 ..< attributes.count {
@ -200,7 +200,7 @@ private func synchronizeConsumeMessageContents(transaction: Transaction, postbox
transaction.updateMessage(id, update: { currentMessage in transaction.updateMessage(id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
var attributes = currentMessage.attributes var attributes = currentMessage.attributes
loop: for j in 0 ..< attributes.count { loop: for j in 0 ..< attributes.count {

View File

@ -1162,7 +1162,7 @@ private func sendMessage(auxiliaryMethods: AccountAuxiliaryMethods, postbox: Pos
} }
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
var updatedMedia = currentMessage.media var updatedMedia = currentMessage.media
@ -1244,7 +1244,7 @@ private func sendServiceActionMessage(postbox: Postbox, network: Network, peerId
resultTimestamp = timestamp resultTimestamp = timestamp
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: timestamp, flags: flags, tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media)) return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: timestamp, flags: flags, tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media))
}) })

View File

@ -90,7 +90,7 @@ public func markMessageContentAsConsumedInteractively(postbox: Postbox, messageI
transaction.updateMessage(message.id, update: { currentMessage in transaction.updateMessage(message.id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: updatedAttributes, media: currentMessage.media)) return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: updatedAttributes, media: currentMessage.media))
}) })
@ -149,7 +149,7 @@ func markMessageContentAsConsumedRemotely(transaction: Transaction, messageId: M
transaction.updateMessage(message.id, update: { currentMessage in transaction.updateMessage(message.id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: updatedTags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: updatedAttributes, media: updatedMedia)) return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: updatedTags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: updatedAttributes, media: updatedMedia))
}) })

View File

@ -7,11 +7,11 @@ import SwiftSignalKit
import Postbox import Postbox
#endif #endif
public final class NotificationExceptionsList : Equatable { public final class NotificationExceptionsList: Equatable {
public let peers:[PeerId: Peer] public let peers: [PeerId: Peer]
public let settings: [PeerId: TelegramPeerNotificationSettings] public let settings: [PeerId: TelegramPeerNotificationSettings]
init(_ peers:[PeerId: Peer], _ settings: [PeerId : TelegramPeerNotificationSettings]) { init(peers: [PeerId: Peer], settings: [PeerId: TelegramPeerNotificationSettings]) {
self.peers = peers self.peers = peers
self.settings = settings self.settings = settings
} }
@ -21,50 +21,49 @@ public final class NotificationExceptionsList : Equatable {
} }
} }
public func notificationExceptionsList(network: Network) -> Signal<NotificationExceptionsList, NoError> { public func notificationExceptionsList(network: Network) -> Signal<NotificationExceptionsList, NoError> {
return network.request(Api.functions.account.getNotifyExceptions(flags: 1 << 1, peer: nil)) |> retryRequest |> map { result in return network.request(Api.functions.account.getNotifyExceptions(flags: 1 << 1, peer: nil)) |> retryRequest |> map { result in
switch result { switch result {
case let .updates(updates, users, chats, _, _): case let .updates(updates, users, chats, _, _):
var peers:[PeerId: Peer] = [:] var peers:[PeerId: Peer] = [:]
var settings:[PeerId : TelegramPeerNotificationSettings] = [:] var settings:[PeerId : TelegramPeerNotificationSettings] = [:]
for user in users { for user in users {
let peer = TelegramUser(user: user) let peer = TelegramUser(user: user)
peers[peer.id] = peer
}
for chat in chats {
if let peer = parseTelegramGroupOrChannel(chat: chat) {
peers[peer.id] = peer peers[peer.id] = peer
} }
} for chat in chats {
if let peer = parseTelegramGroupOrChannel(chat: chat) {
for update in updates { peers[peer.id] = peer
switch update {
case let .updateNotifySettings(apiPeer, notifySettings):
switch apiPeer {
case let .notifyPeer(notifyPeer):
let peerId: PeerId
switch notifyPeer {
case let .peerUser(userId):
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
case let .peerChat(chatId):
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
case let .peerChannel(channelId):
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
}
settings[peerId] = TelegramPeerNotificationSettings(apiSettings: notifySettings)
default:
break
} }
default:
break
} }
}
for update in updates {
return NotificationExceptionsList(peers, settings) switch update {
default: case let .updateNotifySettings(apiPeer, notifySettings):
return NotificationExceptionsList([:], [:]) switch apiPeer {
case let .notifyPeer(notifyPeer):
let peerId: PeerId
switch notifyPeer {
case let .peerUser(userId):
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
case let .peerChat(chatId):
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
case let .peerChannel(channelId):
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
}
settings[peerId] = TelegramPeerNotificationSettings(apiSettings: notifySettings)
default:
break
}
default:
break
}
}
return NotificationExceptionsList(peers: peers, settings: settings)
default:
return NotificationExceptionsList(peers: [:], settings: [:])
} }
} }
} }

View File

@ -106,7 +106,7 @@ private func failMessages(postbox: Postbox, ids: [MessageId]) -> Signal<Void, No
transaction.updateMessage(id, update: { currentMessage in transaction.updateMessage(id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: [.Failed], tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media)) return .update(StoreMessage(id: id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: [.Failed], tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media))
}) })
@ -513,7 +513,7 @@ public final class PendingMessageManager {
transaction.updateMessage(id, update: { currentMessage in transaction.updateMessage(id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: [.Failed], tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media)) return .update(StoreMessage(id: id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: [.Failed], tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media))
}) })
@ -837,7 +837,7 @@ public final class PendingMessageManager {
} }
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: flags, tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media)) return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: flags, tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media))
}) })
@ -853,7 +853,7 @@ public final class PendingMessageManager {
} }
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: flags, tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media)) return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: flags, tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media))
}) })
@ -862,7 +862,7 @@ public final class PendingMessageManager {
transaction.updateMessage(message.id, update: { currentMessage in transaction.updateMessage(message.id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: message.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: [.Failed], tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media)) return .update(StoreMessage(id: message.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: [.Failed], tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media))
}) })
@ -989,7 +989,7 @@ public final class PendingMessageManager {
transaction.updateMessage(message.id, update: { currentMessage in transaction.updateMessage(message.id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: message.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: [.Failed], tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media)) return .update(StoreMessage(id: message.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: [.Failed], tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media))
}) })
@ -1003,7 +1003,7 @@ public final class PendingMessageManager {
transaction.updateMessage(message.id, update: { currentMessage in transaction.updateMessage(message.id, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: message.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: [.Failed], tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media)) return .update(StoreMessage(id: message.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: [.Failed], tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media))
}) })
@ -1031,7 +1031,7 @@ public final class PendingMessageManager {
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: attributes, media: currentMessage.media)) return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: attributes, media: currentMessage.media))
}) })

View File

@ -283,7 +283,7 @@ private func uploadedMediaImageContent(network: Network, postbox: Postbox, trans
transaction.updateMessage(messageId, update: { currentMessage in transaction.updateMessage(messageId, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: nil) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: nil)
} }
var updatedAttributes = currentMessage.attributes var updatedAttributes = currentMessage.attributes
if let index = updatedAttributes.index(where: { $0 is OutgoingMessageInfoAttribute }){ if let index = updatedAttributes.index(where: { $0 is OutgoingMessageInfoAttribute }){
@ -544,7 +544,7 @@ private func uploadedMediaFileContent(network: Network, postbox: Postbox, auxili
transaction.updateMessage(messageId, update: { currentMessage in transaction.updateMessage(messageId, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: nil) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: nil)
} }
var updatedAttributes = currentMessage.attributes var updatedAttributes = currentMessage.attributes
if let index = updatedAttributes.index(where: { $0 is OutgoingMessageInfoAttribute }){ if let index = updatedAttributes.index(where: { $0 is OutgoingMessageInfoAttribute }){

View File

@ -61,14 +61,18 @@ public struct AccountPrivacySettings: Equatable {
public let groupInvitations: SelectivePrivacySettings public let groupInvitations: SelectivePrivacySettings
public let voiceCalls: SelectivePrivacySettings public let voiceCalls: SelectivePrivacySettings
public let voiceCallsP2P: SelectivePrivacySettings public let voiceCallsP2P: SelectivePrivacySettings
public let profilePhoto: SelectivePrivacySettings
public let forwards: SelectivePrivacySettings
public let accountRemovalTimeout: Int32 public let accountRemovalTimeout: Int32
public init(presence: SelectivePrivacySettings, groupInvitations: SelectivePrivacySettings, voiceCalls: SelectivePrivacySettings, voiceCallsP2P: SelectivePrivacySettings, accountRemovalTimeout: Int32) { public init(presence: SelectivePrivacySettings, groupInvitations: SelectivePrivacySettings, voiceCalls: SelectivePrivacySettings, voiceCallsP2P: SelectivePrivacySettings, profilePhoto: SelectivePrivacySettings, forwards: SelectivePrivacySettings, accountRemovalTimeout: Int32) {
self.presence = presence self.presence = presence
self.groupInvitations = groupInvitations self.groupInvitations = groupInvitations
self.voiceCalls = voiceCalls self.voiceCalls = voiceCalls
self.voiceCallsP2P = voiceCallsP2P self.voiceCallsP2P = voiceCallsP2P
self.profilePhoto = profilePhoto
self.forwards = forwards
self.accountRemovalTimeout = accountRemovalTimeout self.accountRemovalTimeout = accountRemovalTimeout
} }
@ -85,7 +89,12 @@ public struct AccountPrivacySettings: Equatable {
if lhs.voiceCallsP2P != rhs.voiceCallsP2P { if lhs.voiceCallsP2P != rhs.voiceCallsP2P {
return false return false
} }
if lhs.profilePhoto != rhs.profilePhoto {
return false
}
if lhs.forwards != rhs.forwards {
return false
}
if lhs.accountRemovalTimeout != rhs.accountRemovalTimeout { if lhs.accountRemovalTimeout != rhs.accountRemovalTimeout {
return false return false
} }

View File

@ -231,7 +231,7 @@ public func requestEditLiveLocation(postbox: Postbox, network: Network, stateMan
transaction.updateMessage(messageId, update: { currentMessage in transaction.updateMessage(messageId, update: { currentMessage in
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
var updatedLocalTags = currentMessage.localTags var updatedLocalTags = currentMessage.localTags
updatedLocalTags.remove(.OutgoingLiveLocation) updatedLocalTags.remove(.OutgoingLiveLocation)

View File

@ -202,7 +202,7 @@ public class BoxedMessage: NSObject {
public class Serialization: NSObject, MTSerialization { public class Serialization: NSObject, MTSerialization {
public func currentLayer() -> UInt { public func currentLayer() -> UInt {
return 96 return 97
} }
public func parseMessage(_ data: Data!) -> Any! { public func parseMessage(_ data: Data!) -> Any! {

View File

@ -41,15 +41,17 @@ public final class StickerPackCollectionInfo: ItemCollectionInfo, Equatable {
public let accessHash: Int64 public let accessHash: Int64
public let title: String public let title: String
public let shortName: String public let shortName: String
public let thumbnail: TelegramMediaImageRepresentation?
public let hash: Int32 public let hash: Int32
public let count: Int32 public let count: Int32
public init(id: ItemCollectionId, flags: StickerPackCollectionInfoFlags, accessHash: Int64, title: String, shortName: String, hash: Int32, count: Int32) { public init(id: ItemCollectionId, flags: StickerPackCollectionInfoFlags, accessHash: Int64, title: String, shortName: String, thumbnail: TelegramMediaImageRepresentation?, hash: Int32, count: Int32) {
self.id = id self.id = id
self.flags = flags self.flags = flags
self.accessHash = accessHash self.accessHash = accessHash
self.title = title self.title = title
self.shortName = shortName self.shortName = shortName
self.thumbnail = thumbnail
self.hash = hash self.hash = hash
self.count = count self.count = count
} }
@ -59,6 +61,7 @@ public final class StickerPackCollectionInfo: ItemCollectionInfo, Equatable {
self.accessHash = decoder.decodeInt64ForKey("a", orElse: 0) self.accessHash = decoder.decodeInt64ForKey("a", orElse: 0)
self.title = decoder.decodeStringForKey("t", orElse: "") self.title = decoder.decodeStringForKey("t", orElse: "")
self.shortName = decoder.decodeStringForKey("s", orElse: "") self.shortName = decoder.decodeStringForKey("s", orElse: "")
self.thumbnail = decoder.decodeObjectForKey("th", decoder: { TelegramMediaImageRepresentation(decoder: $0) }) as? TelegramMediaImageRepresentation
self.hash = decoder.decodeInt32ForKey("h", orElse: 0) self.hash = decoder.decodeInt32ForKey("h", orElse: 0)
self.flags = StickerPackCollectionInfoFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0)) self.flags = StickerPackCollectionInfoFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0))
self.count = decoder.decodeInt32ForKey("n", orElse: 0) self.count = decoder.decodeInt32ForKey("n", orElse: 0)
@ -70,6 +73,11 @@ public final class StickerPackCollectionInfo: ItemCollectionInfo, Equatable {
encoder.encodeInt64(self.accessHash, forKey: "a") encoder.encodeInt64(self.accessHash, forKey: "a")
encoder.encodeString(self.title, forKey: "t") encoder.encodeString(self.title, forKey: "t")
encoder.encodeString(self.shortName, forKey: "s") encoder.encodeString(self.shortName, forKey: "s")
if let thumbnail = self.thumbnail {
encoder.encodeObject(thumbnail, forKey: "th")
} else {
encoder.encodeNil(forKey: "th")
}
encoder.encodeInt32(self.hash, forKey: "h") encoder.encodeInt32(self.hash, forKey: "h")
encoder.encodeInt32(self.flags.rawValue, forKey: "f") encoder.encodeInt32(self.flags.rawValue, forKey: "f")
encoder.encodeInt32(self.count, forKey: "n") encoder.encodeInt32(self.count, forKey: "n")
@ -148,7 +156,7 @@ public final class StickerPackItem: ItemCollectionItem, Equatable {
extension StickerPackCollectionInfo { extension StickerPackCollectionInfo {
convenience init(apiSet: Api.StickerSet, namespace: ItemCollectionId.Namespace) { convenience init(apiSet: Api.StickerSet, namespace: ItemCollectionId.Namespace) {
switch apiSet { switch apiSet {
case let .stickerSet(flags, _, id, accessHash, title, shortName, count, nHash): case let .stickerSet(flags, _, id, accessHash, title, shortName, thumb, count, nHash):
var setFlags: StickerPackCollectionInfoFlags = StickerPackCollectionInfoFlags() var setFlags: StickerPackCollectionInfoFlags = StickerPackCollectionInfoFlags()
if (flags & (1 << 2)) != 0 { if (flags & (1 << 2)) != 0 {
setFlags.insert(.official) setFlags.insert(.official)
@ -156,7 +164,9 @@ extension StickerPackCollectionInfo {
if (flags & (1 << 3)) != 0 { if (flags & (1 << 3)) != 0 {
setFlags.insert(.masks) setFlags.insert(.masks)
} }
self.init(id: ItemCollectionId(namespace: namespace, id: id), flags: setFlags, accessHash: accessHash, title: title, shortName: shortName, hash: nHash, count: count) self.init(id: ItemCollectionId(namespace: namespace, id: id), flags: setFlags, accessHash: accessHash, title: title, shortName: shortName, thumbnail: thumb.flatMap({ thumb in
return telegramMediaImageRepresentationsFromApiSizes([thumb]).representations.first
}), hash: nHash, count: count)
} }
} }
} }

View File

@ -150,14 +150,14 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
if let fwdHeader = fwdHeader { if let fwdHeader = fwdHeader {
switch fwdHeader { switch fwdHeader {
case let .messageFwdHeader(_, fromId, _, channelId, _, _, savedFromPeer, _): case let .messageFwdHeader(messageFwdHeader):
if let channelId = channelId { if let channelId = messageFwdHeader.channelId {
result.append(PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)) result.append(PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId))
} }
if let fromId = fromId { if let fromId = messageFwdHeader.fromId {
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: fromId)) result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: fromId))
} }
if let savedFromPeer = savedFromPeer { if let savedFromPeer = messageFwdHeader.savedFromPeer {
result.append(savedFromPeer.peerId) result.append(savedFromPeer.peerId)
} }
} }
@ -403,7 +403,7 @@ extension StoreMessage {
var forwardInfo: StoreMessageForwardInfo? var forwardInfo: StoreMessageForwardInfo?
if let fwdFrom = fwdFrom { if let fwdFrom = fwdFrom {
switch fwdFrom { switch fwdFrom {
case let .messageFwdHeader(_, fromId, date, channelId, channelPost, postAuthor, savedFromPeer, savedFromMsgId): case let .messageFwdHeader(_, fromId, fromName, date, channelId, channelPost, postAuthor, savedFromPeer, savedFromMsgId):
var authorId: PeerId? var authorId: PeerId?
var sourceId: PeerId? var sourceId: PeerId?
var sourceMessageId: MessageId? var sourceMessageId: MessageId?
@ -423,12 +423,12 @@ extension StoreMessage {
if let savedFromPeer = savedFromPeer, let savedFromMsgId = savedFromMsgId { if let savedFromPeer = savedFromPeer, let savedFromMsgId = savedFromMsgId {
let peerId: PeerId let peerId: PeerId
switch savedFromPeer { switch savedFromPeer {
case let .peerChannel(channelId): case let .peerChannel(channelId):
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId) peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
case let .peerChat(chatId): case let .peerChat(chatId):
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId) peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
case let .peerUser(userId): case let .peerUser(userId):
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId) peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
} }
let messageId: MessageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: savedFromMsgId) let messageId: MessageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: savedFromMsgId)
attributes.append(SourceReferenceMessageAttribute(messageId: messageId)) attributes.append(SourceReferenceMessageAttribute(messageId: messageId))
@ -438,6 +438,8 @@ extension StoreMessage {
forwardInfo = StoreMessageForwardInfo(authorId: authorId, sourceId: sourceId, sourceMessageId: sourceMessageId, date: date, authorSignature: postAuthor) forwardInfo = StoreMessageForwardInfo(authorId: authorId, sourceId: sourceId, sourceMessageId: sourceMessageId, date: date, authorSignature: postAuthor)
} else if let sourceId = sourceId { } else if let sourceId = sourceId {
forwardInfo = StoreMessageForwardInfo(authorId: sourceId, sourceId: sourceId, sourceMessageId: sourceMessageId, date: date, authorSignature: postAuthor) forwardInfo = StoreMessageForwardInfo(authorId: sourceId, sourceId: sourceId, sourceMessageId: sourceMessageId, date: date, authorSignature: postAuthor)
} else if let postAuthor = postAuthor ?? fromName {
forwardInfo = StoreMessageForwardInfo(authorId: nil, sourceId: nil, sourceMessageId: sourceMessageId, date: date, authorSignature: postAuthor)
} }
} }
} }

View File

@ -1,26 +1,26 @@
public func dataSizeString(_ size: Int, forceDecimal: Bool = false) -> String { public func dataSizeString(_ size: Int, forceDecimal: Bool = false, decimalSeparator: String = ".") -> String {
return dataSizeString(Int64(size), forceDecimal: forceDecimal) return dataSizeString(Int64(size), forceDecimal: forceDecimal, decimalSeparator: decimalSeparator)
} }
public func dataSizeString(_ size: Int64, forceDecimal: Bool = false) -> String { public func dataSizeString(_ size: Int64, forceDecimal: Bool = false, decimalSeparator: String = ".") -> String {
if size >= 1024 * 1024 * 1024 { if size >= 1024 * 1024 * 1024 {
let remainder = (size % (1024 * 1024 * 1024)) / (1024 * 1024 * 102) let remainder = Int64((Double(size % (1024 * 1024 * 1024)) / (1024 * 1024 * 102.4)).rounded(.down))
if remainder != 0 || forceDecimal { if remainder != 0 || forceDecimal {
return "\(size / (1024 * 1024 * 1024)),\(remainder) GB" return "\(size / (1024 * 1024 * 1024))\(decimalSeparator)\(remainder) GB"
} else { } else {
return "\(size / (1024 * 1024 * 1024)) GB" return "\(size / (1024 * 1024 * 1024)) GB"
} }
} else if size >= 1024 * 1024 { } else if size >= 1024 * 1024 {
let remainder = (size % (1024 * 1024)) / (1024 * 102) let remainder = Int64((Double(size % (1024 * 1024)) / (1024.0 * 102.4)).rounded(.down))
if remainder != 0 || forceDecimal { if remainder != 0 || forceDecimal {
return "\(size / (1024 * 1024)),\(remainder) MB" return "\(size / (1024 * 1024))\(decimalSeparator)\(remainder) MB"
} else { } else {
return "\(size / (1024 * 1024)) MB" return "\(size / (1024 * 1024)) MB"
} }
} else if size >= 1024 { } else if size >= 1024 {
let remainder = (size % (1024)) / (102) let remainder = (size % (1024)) / (102)
if remainder != 0 || forceDecimal { if remainder != 0 || forceDecimal {
return "\(size / 1024),\(remainder) KB" return "\(size / 1024)\(decimalSeparator)\(remainder) KB"
} else { } else {
return "\(size / 1024) KB" return "\(size / 1024) KB"
} }

View File

@ -168,7 +168,7 @@ public final class TelegramChannel: Peer {
public let associatedPeerId: PeerId? = nil public let associatedPeerId: PeerId? = nil
public let notificationSettingsPeerId: PeerId? = nil public let notificationSettingsPeerId: PeerId? = nil
public init(id: PeerId, accessHash: Int64?, title: String, username: String?, photo: [TelegramMediaImageRepresentation], creationDate: Int32, version: Int32, participationStatus: TelegramChannelParticipationStatus, info: TelegramChannelInfo, flags: TelegramChannelFlags, restrictionInfo: PeerAccessRestrictionInfo?, adminRights: TelegramChatAdminRights?, bannedRights: TelegramChatBannedRights?, defaultBannedRights: TelegramChatBannedRights?, peerGroupId: PeerGroupId?) { public init(id: PeerId, accessHash: Int64?, title: String, username: String?, photo: [TelegramMediaImageRepresentation], creationDate: Int32, version: Int32, participationStatus: TelegramChannelParticipationStatus, info: TelegramChannelInfo, flags: TelegramChannelFlags, restrictionInfo: PeerAccessRestrictionInfo?, adminRights: TelegramChatAdminRights?, bannedRights: TelegramChatBannedRights?, defaultBannedRights: TelegramChatBannedRights?, peerGroupId: PeerGroupId? = nil) {
self.id = id self.id = id
self.accessHash = accessHash self.accessHash = accessHash
self.title = title self.title = title

View File

@ -324,7 +324,7 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
let stickerPack: StickerPackCollectionInfo? = stickerSet.flatMap { apiSet -> StickerPackCollectionInfo in let stickerPack: StickerPackCollectionInfo? = stickerSet.flatMap { apiSet -> StickerPackCollectionInfo in
let namespace: ItemCollectionId.Namespace let namespace: ItemCollectionId.Namespace
switch apiSet { switch apiSet {
case let .stickerSet(flags, _, _, _, _, _, _, _): case let .stickerSet(flags, _, _, _, _, _, _, _, _):
if (flags & (1 << 3)) != 0 { if (flags & (1 << 3)) != 0 {
namespace = Namespaces.ItemCollection.CloudMaskPacks namespace = Namespaces.ItemCollection.CloudMaskPacks
} else { } else {

View File

@ -23,7 +23,7 @@ func updateMessageMedia(transaction: Transaction, id: MediaId, media: Media?) {
var storeForwardInfo: StoreMessageForwardInfo? var storeForwardInfo: StoreMessageForwardInfo?
if let forwardInfo = currentMessage.forwardInfo { if let forwardInfo = currentMessage.forwardInfo {
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature) storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature)
} }
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media)) return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: currentMessage.media))
}) })

View File

@ -12,10 +12,12 @@ public func requestAccountPrivacySettings(account: Account) -> Signal<AccountPri
let groupPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyChatInvite)) let groupPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyChatInvite))
let voiceCallPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyPhoneCall)) let voiceCallPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyPhoneCall))
let voiceCallP2P = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyPhoneP2P)) let voiceCallP2P = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyPhoneP2P))
let profilePhotoPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyProfilePhoto))
let forwardPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyForwards))
let autoremoveTimeout = account.network.request(Api.functions.account.getAccountTTL()) let autoremoveTimeout = account.network.request(Api.functions.account.getAccountTTL())
return combineLatest(lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, autoremoveTimeout) return combineLatest(lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, autoremoveTimeout)
|> retryRequest |> retryRequest
|> mapToSignal { lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, autoremoveTimeout -> Signal<AccountPrivacySettings, NoError> in |> mapToSignal { lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, autoremoveTimeout -> Signal<AccountPrivacySettings, NoError> in
let accountTimeoutSeconds: Int32 let accountTimeoutSeconds: Int32
switch autoremoveTimeout { switch autoremoveTimeout {
case let .accountDaysTTL(days): case let .accountDaysTTL(days):
@ -27,6 +29,8 @@ public func requestAccountPrivacySettings(account: Account) -> Signal<AccountPri
let groupRules: [Api.PrivacyRule] let groupRules: [Api.PrivacyRule]
let voiceRules: [Api.PrivacyRule] let voiceRules: [Api.PrivacyRule]
let voiceP2PRules: [Api.PrivacyRule] let voiceP2PRules: [Api.PrivacyRule]
let profilePhotoRules: [Api.PrivacyRule]
let forwardRules: [Api.PrivacyRule]
var apiUsers: [Api.User] = [] var apiUsers: [Api.User] = []
switch lastSeenPrivacy { switch lastSeenPrivacy {
@ -53,6 +57,18 @@ public func requestAccountPrivacySettings(account: Account) -> Signal<AccountPri
voiceP2PRules = rules voiceP2PRules = rules
} }
switch profilePhotoPrivacy {
case let .privacyRules(rules, users):
apiUsers.append(contentsOf: users)
profilePhotoRules = rules
}
switch forwardPrivacy {
case let .privacyRules(rules, users):
apiUsers.append(contentsOf: users)
forwardRules = rules
}
let peers = apiUsers.map { TelegramUser(user: $0) } let peers = apiUsers.map { TelegramUser(user: $0) }
return account.postbox.transaction { transaction -> AccountPrivacySettings in return account.postbox.transaction { transaction -> AccountPrivacySettings in
@ -60,7 +76,7 @@ public func requestAccountPrivacySettings(account: Account) -> Signal<AccountPri
return updated return updated
}) })
return AccountPrivacySettings(presence: SelectivePrivacySettings(apiRules: lastSeenRules), groupInvitations: SelectivePrivacySettings(apiRules: groupRules), voiceCalls: SelectivePrivacySettings(apiRules: voiceRules), voiceCallsP2P: SelectivePrivacySettings(apiRules: voiceP2PRules), accountRemovalTimeout: accountTimeoutSeconds) return AccountPrivacySettings(presence: SelectivePrivacySettings(apiRules: lastSeenRules), groupInvitations: SelectivePrivacySettings(apiRules: groupRules), voiceCalls: SelectivePrivacySettings(apiRules: voiceRules), voiceCallsP2P: SelectivePrivacySettings(apiRules: voiceP2PRules), profilePhoto: SelectivePrivacySettings(apiRules: profilePhotoRules), forwards: SelectivePrivacySettings(apiRules: forwardRules), accountRemovalTimeout: accountTimeoutSeconds)
} }
} }
} }
@ -78,6 +94,8 @@ public enum UpdateSelectiveAccountPrivacySettingsType {
case groupInvitations case groupInvitations
case voiceCalls case voiceCalls
case voiceCallsP2P case voiceCallsP2P
case profilePhoto
case forwards
var apiKey: Api.InputPrivacyKey { var apiKey: Api.InputPrivacyKey {
switch self { switch self {
@ -89,6 +107,10 @@ public enum UpdateSelectiveAccountPrivacySettingsType {
return .inputPrivacyKeyPhoneCall return .inputPrivacyKeyPhoneCall
case .voiceCallsP2P: case .voiceCallsP2P:
return .inputPrivacyKeyPhoneP2P return .inputPrivacyKeyPhoneP2P
case .profilePhoto:
return .inputPrivacyKeyProfilePhoto
case .forwards:
return .inputPrivacyKeyForwards
} }
} }
} }