mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
9c0c99b65f
@ -1 +1 @@
|
|||||||
1c6f97bd3d230ccacfcdb9ff323624644fa53fc0ca4bbb6a5152826fa731a273
|
2bf91df86de591d993771f62fd05896852285001a5e720b8b04158a855350de3
|
||||||
|
@ -372,7 +372,6 @@ plist_fragment(
|
|||||||
|
|
||||||
official_apple_pay_merchants = [
|
official_apple_pay_merchants = [
|
||||||
"merchant.ph.telegra.Telegraph",
|
"merchant.ph.telegra.Telegraph",
|
||||||
"merchant.yandex.ph.telegra.Telegraph",
|
|
||||||
"merchant.sberbank.ph.telegra.Telegraph",
|
"merchant.sberbank.ph.telegra.Telegraph",
|
||||||
"merchant.sberbank.test.ph.telegra.Telegraph",
|
"merchant.sberbank.test.ph.telegra.Telegraph",
|
||||||
"merchant.privatbank.test.telergramios",
|
"merchant.privatbank.test.telergramios",
|
||||||
@ -380,6 +379,7 @@ official_apple_pay_merchants = [
|
|||||||
"merchant.paymaster.test.telegramios",
|
"merchant.paymaster.test.telegramios",
|
||||||
"merchant.smartglocal.prod.telegramios",
|
"merchant.smartglocal.prod.telegramios",
|
||||||
"merchant.smartglocal.test.telegramios",
|
"merchant.smartglocal.test.telegramios",
|
||||||
|
"merchant.yoomoney.test.telegramios",
|
||||||
]
|
]
|
||||||
|
|
||||||
official_bundle_ids = [
|
official_bundle_ids = [
|
||||||
|
@ -598,17 +598,40 @@ private final class NotificationServiceHandler {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = (self.accountManager.currentAccountRecord(allocateIfNotExists: false)
|
let _ = (self.accountManager.accountRecords()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOn(self.queue)).start(next: { [weak self] records in
|
|> deliverOn(self.queue)).start(next: { [weak self] records in
|
||||||
guard let strongSelf = self, let record = records else {
|
var recordId: AccountRecordId?
|
||||||
|
var isCurrentAccount: Bool = false
|
||||||
|
|
||||||
|
if let keyId = notificationPayloadKeyId(data: payloadData) {
|
||||||
|
outer: for listRecord in records.records {
|
||||||
|
for attribute in listRecord.attributes {
|
||||||
|
if case let .backupData(backupData) = attribute {
|
||||||
|
if let notificationEncryptionKeyId = backupData.data?.notificationEncryptionKeyId {
|
||||||
|
if keyId == notificationEncryptionKeyId {
|
||||||
|
recordId = listRecord.id
|
||||||
|
isCurrentAccount = records.currentRecord?.id == listRecord.id
|
||||||
|
break outer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let strongSelf = self, let recordId = recordId else {
|
||||||
|
let content = NotificationContent()
|
||||||
|
updateCurrentContent(content)
|
||||||
|
completed()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = (standaloneStateManager(
|
let _ = (standaloneStateManager(
|
||||||
accountManager: strongSelf.accountManager,
|
accountManager: strongSelf.accountManager,
|
||||||
networkArguments: networkArguments,
|
networkArguments: networkArguments,
|
||||||
id: record.0,
|
id: recordId,
|
||||||
encryptionParameters: strongSelf.encryptionParameters,
|
encryptionParameters: strongSelf.encryptionParameters,
|
||||||
rootPath: rootPath,
|
rootPath: rootPath,
|
||||||
auxiliaryMethods: accountAuxiliaryMethods
|
auxiliaryMethods: accountAuxiliaryMethods
|
||||||
@ -618,6 +641,8 @@ private final class NotificationServiceHandler {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let stateManager = stateManager else {
|
guard let stateManager = stateManager else {
|
||||||
|
let content = NotificationContent()
|
||||||
|
updateCurrentContent(content)
|
||||||
completed()
|
completed()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -626,18 +651,31 @@ private final class NotificationServiceHandler {
|
|||||||
strongSelf.notificationKeyDisposable.set((existingMasterNotificationsKey(postbox: stateManager.postbox)
|
strongSelf.notificationKeyDisposable.set((existingMasterNotificationsKey(postbox: stateManager.postbox)
|
||||||
|> deliverOn(strongSelf.queue)).start(next: { notificationsKey in
|
|> deliverOn(strongSelf.queue)).start(next: { notificationsKey in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
|
let content = NotificationContent()
|
||||||
|
updateCurrentContent(content)
|
||||||
|
completed()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let notificationsKey = notificationsKey else {
|
guard let notificationsKey = notificationsKey else {
|
||||||
|
let content = NotificationContent()
|
||||||
|
updateCurrentContent(content)
|
||||||
completed()
|
completed()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let decryptedPayload = decryptedNotificationPayload(key: notificationsKey, data: payloadData) else {
|
guard let decryptedPayload = decryptedNotificationPayload(key: notificationsKey, data: payloadData) else {
|
||||||
|
let content = NotificationContent()
|
||||||
|
updateCurrentContent(content)
|
||||||
completed()
|
completed()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let payloadJson = try? JSONSerialization.jsonObject(with: decryptedPayload, options: []) as? [String: Any] else {
|
guard let payloadJson = try? JSONSerialization.jsonObject(with: decryptedPayload, options: []) as? [String: Any] else {
|
||||||
|
let content = NotificationContent()
|
||||||
|
updateCurrentContent(content)
|
||||||
completed()
|
completed()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,6 +701,10 @@ private final class NotificationServiceHandler {
|
|||||||
if let channelIdValue = Int64(channelIdString) {
|
if let channelIdValue = Int64(channelIdString) {
|
||||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelIdValue))
|
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelIdValue))
|
||||||
}
|
}
|
||||||
|
} else if let encryptionIdString = payloadJson["encryption_id"] as? String {
|
||||||
|
if let encryptionIdValue = Int64(encryptionIdString) {
|
||||||
|
peerId = PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(encryptionIdValue))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Action {
|
enum Action {
|
||||||
@ -735,7 +777,7 @@ private final class NotificationServiceHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
content.userInfo["peerId"] = "\(peerId.toInt64())"
|
content.userInfo["peerId"] = "\(peerId.toInt64())"
|
||||||
content.userInfo["accountId"] = "\(record.0.int64)"
|
content.userInfo["accountId"] = "\(recordId.int64)"
|
||||||
|
|
||||||
if let silentString = payloadJson["silent"] as? String {
|
if let silentString = payloadJson["silent"] as? String {
|
||||||
if let silentValue = Int(silentString), silentValue != 0 {
|
if let silentValue = Int(silentString), silentValue != 0 {
|
||||||
@ -888,7 +930,9 @@ private final class NotificationServiceHandler {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isCurrentAccount {
|
||||||
content.badge = Int(value.0)
|
content.badge = Int(value.0)
|
||||||
|
}
|
||||||
|
|
||||||
if let image = mediaAttachment as? TelegramMediaImage, let resource = largestImageRepresentation(image.representations)?.resource {
|
if let image = mediaAttachment as? TelegramMediaImage, let resource = largestImageRepresentation(image.representations)?.resource {
|
||||||
if let mediaData = mediaData {
|
if let mediaData = mediaData {
|
||||||
@ -1037,7 +1081,9 @@ private final class NotificationServiceHandler {
|
|||||||
)
|
)
|
||||||
|> deliverOn(strongSelf.queue)).start(next: { value in
|
|> deliverOn(strongSelf.queue)).start(next: { value in
|
||||||
var content = NotificationContent()
|
var content = NotificationContent()
|
||||||
|
if isCurrentAccount {
|
||||||
content.badge = Int(value.0)
|
content.badge = Int(value.0)
|
||||||
|
}
|
||||||
|
|
||||||
updateCurrentContent(content)
|
updateCurrentContent(content)
|
||||||
|
|
||||||
@ -1080,7 +1126,9 @@ private final class NotificationServiceHandler {
|
|||||||
)
|
)
|
||||||
|> deliverOn(strongSelf.queue)).start(next: { value in
|
|> deliverOn(strongSelf.queue)).start(next: { value in
|
||||||
var content = NotificationContent()
|
var content = NotificationContent()
|
||||||
|
if isCurrentAccount {
|
||||||
content.badge = Int(value.0)
|
content.badge = Int(value.0)
|
||||||
|
}
|
||||||
|
|
||||||
updateCurrentContent(content)
|
updateCurrentContent(content)
|
||||||
|
|
||||||
|
@ -802,7 +802,7 @@ public final class SparseItemGridScrollingArea: ASDisplayNode {
|
|||||||
let indicatorSize = self.dateIndicator.update(
|
let indicatorSize = self.dateIndicator.update(
|
||||||
transition: .immediate,
|
transition: .immediate,
|
||||||
component: AnyComponent(SparseItemGridScrollingIndicatorComponent(
|
component: AnyComponent(SparseItemGridScrollingIndicatorComponent(
|
||||||
backgroundColor: theme.list.itemHighlightedBackgroundColor,
|
backgroundColor: theme.list.itemBlocksBackgroundColor,
|
||||||
shadowColor: .black,
|
shadowColor: .black,
|
||||||
foregroundColor: theme.list.itemPrimaryTextColor,
|
foregroundColor: theme.list.itemPrimaryTextColor,
|
||||||
dateString: dateString
|
dateString: dateString
|
||||||
|
@ -695,11 +695,17 @@ private func masterNotificationsKey(masterNotificationKeyValue: Atomic<MasterNot
|
|||||||
}
|
}
|
||||||
|
|
||||||
return postbox.transaction(ignoreDisabled: ignoreDisabled, { transaction -> MasterNotificationKey? in
|
return postbox.transaction(ignoreDisabled: ignoreDisabled, { transaction -> MasterNotificationKey? in
|
||||||
|
let result = masterNotificationsKey(transaction: transaction, createIfNotExists: createIfNotExists)
|
||||||
|
let _ = masterNotificationKeyValue.swap(result)
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func masterNotificationsKey(transaction: Transaction, createIfNotExists: Bool) -> MasterNotificationKey? {
|
||||||
if let value = transaction.keychainEntryForKey("master-notification-secret"), !value.isEmpty {
|
if let value = transaction.keychainEntryForKey("master-notification-secret"), !value.isEmpty {
|
||||||
let authKeyHash = sha1Digest(value)
|
let authKeyHash = sha1Digest(value)
|
||||||
let authKeyId = authKeyHash.subdata(in: authKeyHash.count - 8 ..< authKeyHash.count)
|
let authKeyId = authKeyHash.subdata(in: authKeyHash.count - 8 ..< authKeyHash.count)
|
||||||
let keyData = MasterNotificationKey(id: authKeyId, data: value)
|
let keyData = MasterNotificationKey(id: authKeyId, data: value)
|
||||||
let _ = masterNotificationKeyValue.swap(keyData)
|
|
||||||
return keyData
|
return keyData
|
||||||
} else if createIfNotExists {
|
} else if createIfNotExists {
|
||||||
var secretData = Data(count: 256)
|
var secretData = Data(count: 256)
|
||||||
@ -716,12 +722,18 @@ private func masterNotificationsKey(masterNotificationKeyValue: Atomic<MasterNot
|
|||||||
let authKeyHash = sha1Digest(secretData)
|
let authKeyHash = sha1Digest(secretData)
|
||||||
let authKeyId = authKeyHash.subdata(in: authKeyHash.count - 8 ..< authKeyHash.count)
|
let authKeyId = authKeyHash.subdata(in: authKeyHash.count - 8 ..< authKeyHash.count)
|
||||||
let keyData = MasterNotificationKey(id: authKeyId, data: secretData)
|
let keyData = MasterNotificationKey(id: authKeyId, data: secretData)
|
||||||
let _ = masterNotificationKeyValue.swap(keyData)
|
|
||||||
return keyData
|
return keyData
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
public func notificationPayloadKeyId(data: Data) -> Data? {
|
||||||
|
if data.count < 8 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.subdata(in: 0 ..< 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func decryptedNotificationPayload(key: MasterNotificationKey, data: Data) -> Data? {
|
public func decryptedNotificationPayload(key: MasterNotificationKey, data: Data) -> Data? {
|
||||||
@ -792,7 +804,14 @@ public func accountBackupData(postbox: Postbox) -> Signal<AccountBackupData?, No
|
|||||||
guard let authKey = datacenterAuthInfo.authKey else {
|
guard let authKey = datacenterAuthInfo.authKey else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return AccountBackupData(masterDatacenterId: state.masterDatacenterId, peerId: state.peerId.toInt64(), masterDatacenterKey: authKey, masterDatacenterKeyId: datacenterAuthInfo.authKeyId)
|
let notificationsKey = masterNotificationsKey(transaction: transaction, createIfNotExists: true)
|
||||||
|
return AccountBackupData(
|
||||||
|
masterDatacenterId: state.masterDatacenterId,
|
||||||
|
peerId: state.peerId.toInt64(),
|
||||||
|
masterDatacenterKey: authKey,
|
||||||
|
masterDatacenterKeyId: datacenterAuthInfo.authKeyId,
|
||||||
|
notificationEncryptionKeyId: notificationsKey?.id
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,12 +6,20 @@ public struct AccountBackupData: Codable, Equatable {
|
|||||||
public var peerId: Int64
|
public var peerId: Int64
|
||||||
public var masterDatacenterKey: Data
|
public var masterDatacenterKey: Data
|
||||||
public var masterDatacenterKeyId: Int64
|
public var masterDatacenterKeyId: Int64
|
||||||
|
public var notificationEncryptionKeyId: Data?
|
||||||
|
|
||||||
public init(masterDatacenterId: Int32, peerId: Int64, masterDatacenterKey: Data, masterDatacenterKeyId: Int64) {
|
public init(
|
||||||
|
masterDatacenterId: Int32,
|
||||||
|
peerId: Int64,
|
||||||
|
masterDatacenterKey: Data,
|
||||||
|
masterDatacenterKeyId: Int64,
|
||||||
|
notificationEncryptionKeyId: Data?
|
||||||
|
) {
|
||||||
self.masterDatacenterId = masterDatacenterId
|
self.masterDatacenterId = masterDatacenterId
|
||||||
self.peerId = peerId
|
self.peerId = peerId
|
||||||
self.masterDatacenterKey = masterDatacenterKey
|
self.masterDatacenterKey = masterDatacenterKey
|
||||||
self.masterDatacenterKeyId = masterDatacenterKeyId
|
self.masterDatacenterKeyId = masterDatacenterKeyId
|
||||||
|
self.notificationEncryptionKeyId = notificationEncryptionKeyId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,8 +209,8 @@ public final class SparseMessageList {
|
|||||||
var removeIndices: [Int] = []
|
var removeIndices: [Int] = []
|
||||||
for i in 0 ..< sparseItems.items.count {
|
for i in 0 ..< sparseItems.items.count {
|
||||||
switch sparseItems.items[i] {
|
switch sparseItems.items[i] {
|
||||||
case let .anchor(id, _, message):
|
case let .anchor(id, _, _):
|
||||||
if message != nil, idsSet.contains(id) {
|
if idsSet.contains(id) {
|
||||||
removeIndices.append(i)
|
removeIndices.append(i)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -389,7 +389,7 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
|
|||||||
controlColor: UIColor(rgb: 0x98989e)
|
controlColor: UIColor(rgb: 0x98989e)
|
||||||
),
|
),
|
||||||
mediaPlaceholderColor: UIColor(rgb: 0xffffff).mixedWith(UIColor(rgb: 0x1c1c1d), alpha: 0.9),
|
mediaPlaceholderColor: UIColor(rgb: 0xffffff).mixedWith(UIColor(rgb: 0x1c1c1d), alpha: 0.9),
|
||||||
scrollIndicatorColor: UIColor(rgb: 0xffffff, alpha: 0.3),
|
scrollIndicatorColor: UIColor(rgb: 0xffffff, alpha: 0.5),
|
||||||
pageIndicatorInactiveColor: UIColor(white: 1.0, alpha: 0.3),
|
pageIndicatorInactiveColor: UIColor(white: 1.0, alpha: 0.3),
|
||||||
inputClearButtonColor: UIColor(rgb: 0x8b9197),
|
inputClearButtonColor: UIColor(rgb: 0x8b9197),
|
||||||
itemBarChart: PresentationThemeItemBarChart(color1: UIColor(rgb: 0xffffff), color2: UIColor(rgb: 0x929196), color3: UIColor(rgb: 0x333333)),
|
itemBarChart: PresentationThemeItemBarChart(color1: UIColor(rgb: 0xffffff), color2: UIColor(rgb: 0x929196), color3: UIColor(rgb: 0x333333)),
|
||||||
|
@ -644,7 +644,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
|
|||||||
controlColor: mainSecondaryTextColor.withAlphaComponent(0.5)
|
controlColor: mainSecondaryTextColor.withAlphaComponent(0.5)
|
||||||
),
|
),
|
||||||
mediaPlaceholderColor: UIColor(rgb: 0xffffff).mixedWith(mainBackgroundColor, alpha: 0.9),
|
mediaPlaceholderColor: UIColor(rgb: 0xffffff).mixedWith(mainBackgroundColor, alpha: 0.9),
|
||||||
scrollIndicatorColor: UIColor(white: 1.0, alpha: 0.3),
|
scrollIndicatorColor: UIColor(white: 1.0, alpha: 0.5),
|
||||||
pageIndicatorInactiveColor: mainSecondaryTextColor.withAlphaComponent(0.4),
|
pageIndicatorInactiveColor: mainSecondaryTextColor.withAlphaComponent(0.4),
|
||||||
inputClearButtonColor: mainSecondaryColor,
|
inputClearButtonColor: mainSecondaryColor,
|
||||||
itemBarChart: PresentationThemeItemBarChart(color1: accentColor, color2: mainSecondaryTextColor.withAlphaComponent(0.5), color3: accentColor.withMultiplied(hue: 1.038, saturation: 0.329, brightness: 0.33)),
|
itemBarChart: PresentationThemeItemBarChart(color1: accentColor, color2: mainSecondaryTextColor.withAlphaComponent(0.5), color3: accentColor.withMultiplied(hue: 1.038, saturation: 0.329, brightness: 0.33)),
|
||||||
|
@ -2277,6 +2277,8 @@ private func notificationPayloadKey(data: Data) -> Data? {
|
|||||||
private func accountIdFromNotification(_ notification: UNNotification, sharedContext: Signal<SharedApplicationContext, NoError>) -> Signal<AccountRecordId?, NoError> {
|
private func accountIdFromNotification(_ notification: UNNotification, sharedContext: Signal<SharedApplicationContext, NoError>) -> Signal<AccountRecordId?, NoError> {
|
||||||
if let id = notification.request.content.userInfo["accountId"] as? Int64 {
|
if let id = notification.request.content.userInfo["accountId"] as? Int64 {
|
||||||
return .single(AccountRecordId(rawValue: id))
|
return .single(AccountRecordId(rawValue: id))
|
||||||
|
} else if let idString = notification.request.content.userInfo["accountId"] as? String, let id = Int64(idString) {
|
||||||
|
return .single(AccountRecordId(rawValue: id))
|
||||||
} else {
|
} else {
|
||||||
var encryptedData: Data?
|
var encryptedData: Data?
|
||||||
if var encryptedPayload = notification.request.content.userInfo["p"] as? String {
|
if var encryptedPayload = notification.request.content.userInfo["p"] as? String {
|
||||||
@ -2336,6 +2338,8 @@ private func accountIdFromNotification(_ notification: UNNotification, sharedCon
|
|||||||
private func peerIdFromNotification(_ notification: UNNotification) -> PeerId? {
|
private func peerIdFromNotification(_ notification: UNNotification) -> PeerId? {
|
||||||
if let peerId = notification.request.content.userInfo["peerId"] as? Int64 {
|
if let peerId = notification.request.content.userInfo["peerId"] as? Int64 {
|
||||||
return PeerId(peerId)
|
return PeerId(peerId)
|
||||||
|
} else if let peerIdString = notification.request.content.userInfo["peerId"] as? String, let peerId = Int64(peerIdString) {
|
||||||
|
return PeerId(peerId)
|
||||||
} else {
|
} else {
|
||||||
let payload = notification.request.content.userInfo
|
let payload = notification.request.content.userInfo
|
||||||
var peerId: PeerId?
|
var peerId: PeerId?
|
||||||
|
@ -101,6 +101,8 @@ private final class FetchManagerStatusContext {
|
|||||||
return .Fetching(isActive: false, progress: 0.0)
|
return .Fetching(isActive: false, progress: 0.0)
|
||||||
} else if self.hasEntry {
|
} else if self.hasEntry {
|
||||||
return originalStatus
|
return originalStatus
|
||||||
|
} else if case .Local = originalStatus {
|
||||||
|
return originalStatus
|
||||||
} else {
|
} else {
|
||||||
return .Remote
|
return .Remote
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"app": "8.1.2",
|
"app": "8.2",
|
||||||
"bazel": "4.0.0",
|
"bazel": "4.0.0",
|
||||||
"xcode": "13.0"
|
"xcode": "13.0"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user