mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
4179c14463
@ -64,7 +64,7 @@ private func rootPathForBasePath(_ appGroupPath: String) -> String {
|
||||
|
||||
let rootPath = rootPathForBasePath(appGroupUrl.path)
|
||||
|
||||
let logsPath = rootPath + "/broadcast-logs"
|
||||
let logsPath = rootPath + "/logs/broadcast-logs"
|
||||
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
|
||||
|
||||
let screencastBufferClientContext = IpcGroupCallBufferBroadcastContext(basePath: rootPath + "/broadcast-coordination")
|
||||
|
@ -639,7 +639,7 @@ private final class NotificationServiceHandler {
|
||||
|
||||
TempBox.initializeShared(basePath: rootPath, processType: "notification", launchSpecificId: Int64.random(in: Int64.min ... Int64.max))
|
||||
|
||||
let logsPath = rootPath + "/notification-logs"
|
||||
let logsPath = rootPath + "/logs/notification-logs"
|
||||
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
|
||||
|
||||
setupSharedLogger(rootPath: rootPath, path: logsPath)
|
||||
@ -673,7 +673,7 @@ private final class NotificationServiceHandler {
|
||||
incomingCallMessage = "is calling you"
|
||||
}
|
||||
|
||||
Logger.shared.log("NotificationService \(episode)", "Begin processing payload \(payload)")
|
||||
Logger.shared.log("NotificationService \(episode)", "Begin processing payload")
|
||||
|
||||
guard var encryptedPayload = payload["p"] as? String else {
|
||||
Logger.shared.log("NotificationService \(episode)", "Invalid payload 1")
|
||||
@ -691,13 +691,16 @@ private final class NotificationServiceHandler {
|
||||
|
||||
let _ = (combineLatest(queue: self.queue,
|
||||
self.accountManager.accountRecords(),
|
||||
self.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.inAppNotificationSettings, ApplicationSpecificSharedDataKeys.voiceCallSettings])
|
||||
self.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.inAppNotificationSettings, ApplicationSpecificSharedDataKeys.voiceCallSettings, SharedDataKeys.loggingSettings])
|
||||
)
|
||||
|> take(1)
|
||||
|> deliverOn(self.queue)).start(next: { [weak self] records, sharedData in
|
||||
var recordId: AccountRecordId?
|
||||
var isCurrentAccount: Bool = false
|
||||
var customSoundPath: String?
|
||||
|
||||
let loggingSettings = sharedData.entries[SharedDataKeys.loggingSettings]?.get(LoggingSettings.self) ?? LoggingSettings.defaultSettings
|
||||
Logger.shared.logToFile = loggingSettings.logToFile
|
||||
Logger.shared.logToConsole = loggingSettings.logToConsole
|
||||
|
||||
if let keyId = notificationPayloadKeyId(data: payloadData) {
|
||||
outer: for listRecord in records.records {
|
||||
@ -717,8 +720,6 @@ private final class NotificationServiceHandler {
|
||||
|
||||
let inAppNotificationSettings = sharedData.entries[ApplicationSpecificSharedDataKeys.inAppNotificationSettings]?.get(InAppNotificationSettings.self) ?? InAppNotificationSettings.defaultSettings
|
||||
|
||||
customSoundPath = inAppNotificationSettings.customSound
|
||||
|
||||
let voiceCallSettings: VoiceCallSettings
|
||||
if let value = sharedData.entries[ApplicationSpecificSharedDataKeys.voiceCallSettings]?.get(VoiceCallSettings.self) {
|
||||
voiceCallSettings = value
|
||||
|
@ -113,7 +113,7 @@ class DefaultIntentHandler: INExtension, INSendMessageIntentHandling, INSearchFo
|
||||
|
||||
TempBox.initializeShared(basePath: rootPath, processType: "siri", launchSpecificId: Int64.random(in: Int64.min ... Int64.max))
|
||||
|
||||
let logsPath = rootPath + "/siri-logs"
|
||||
let logsPath = rootPath + "/logs/siri-logs"
|
||||
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
|
||||
|
||||
setupSharedLogger(rootPath: rootPath, path: logsPath)
|
||||
@ -880,7 +880,7 @@ private final class WidgetIntentHandler {
|
||||
|
||||
TempBox.initializeShared(basePath: rootPath, processType: "siri", launchSpecificId: Int64.random(in: Int64.min ... Int64.max))
|
||||
|
||||
let logsPath = rootPath + "/siri-logs"
|
||||
let logsPath = rootPath + "/logs/siri-logs"
|
||||
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
|
||||
|
||||
setupSharedLogger(rootPath: rootPath, path: logsPath)
|
||||
|
@ -91,7 +91,7 @@ private func getCommonTimeline(friends: [Friend]?, in context: TimelineProviderC
|
||||
|
||||
TempBox.initializeShared(basePath: rootPath, processType: "widget", launchSpecificId: Int64.random(in: Int64.min ... Int64.max))
|
||||
|
||||
let logsPath = rootPath + "/widget-logs"
|
||||
let logsPath = rootPath + "/logs/widget-logs"
|
||||
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
|
||||
|
||||
setupSharedLogger(rootPath: rootPath, path: logsPath)
|
||||
|
@ -61,6 +61,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
case sendGroupCallLogs
|
||||
case sendNotificationLogs(PresentationTheme)
|
||||
case sendCriticalLogs(PresentationTheme)
|
||||
case sendAllLogs
|
||||
case accounts(PresentationTheme)
|
||||
case logToFile(PresentationTheme, Bool)
|
||||
case logToConsole(PresentationTheme, Bool)
|
||||
@ -102,7 +103,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
switch self {
|
||||
case .testStickerImport:
|
||||
return DebugControllerSection.sticker.rawValue
|
||||
case .sendLogs, .sendOneLog, .sendShareLogs, .sendGroupCallLogs, .sendNotificationLogs, .sendCriticalLogs:
|
||||
case .sendLogs, .sendOneLog, .sendShareLogs, .sendGroupCallLogs, .sendNotificationLogs, .sendCriticalLogs, .sendAllLogs:
|
||||
return DebugControllerSection.logs.rawValue
|
||||
case .accounts:
|
||||
return DebugControllerSection.logs.rawValue
|
||||
@ -137,70 +138,72 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
return 5
|
||||
case .sendCriticalLogs:
|
||||
return 6
|
||||
case .accounts:
|
||||
case .sendAllLogs:
|
||||
return 7
|
||||
case .logToFile:
|
||||
case .accounts:
|
||||
return 8
|
||||
case .logToConsole:
|
||||
case .logToFile:
|
||||
return 9
|
||||
case .redactSensitiveData:
|
||||
case .logToConsole:
|
||||
return 10
|
||||
case .enableRaiseToSpeak:
|
||||
case .redactSensitiveData:
|
||||
return 11
|
||||
case .keepChatNavigationStack:
|
||||
case .enableRaiseToSpeak:
|
||||
return 12
|
||||
case .skipReadHistory:
|
||||
case .keepChatNavigationStack:
|
||||
return 13
|
||||
case .crashOnSlowQueries:
|
||||
case .skipReadHistory:
|
||||
return 14
|
||||
case .clearTips:
|
||||
case .crashOnSlowQueries:
|
||||
return 15
|
||||
case .crash:
|
||||
case .clearTips:
|
||||
return 16
|
||||
case .resetData:
|
||||
case .crash:
|
||||
return 17
|
||||
case .resetDatabase:
|
||||
case .resetData:
|
||||
return 18
|
||||
case .resetDatabaseAndCache:
|
||||
case .resetDatabase:
|
||||
return 19
|
||||
case .resetHoles:
|
||||
case .resetDatabaseAndCache:
|
||||
return 20
|
||||
case .reindexUnread:
|
||||
case .resetHoles:
|
||||
return 21
|
||||
case .resetBiometricsData:
|
||||
case .reindexUnread:
|
||||
return 22
|
||||
case .resetWebViewCache:
|
||||
case .resetBiometricsData:
|
||||
return 23
|
||||
case .optimizeDatabase:
|
||||
case .resetWebViewCache:
|
||||
return 24
|
||||
case .photoPreview:
|
||||
case .optimizeDatabase:
|
||||
return 25
|
||||
case .knockoutWallpaper:
|
||||
case .photoPreview:
|
||||
return 26
|
||||
case .experimentalCompatibility:
|
||||
case .knockoutWallpaper:
|
||||
return 27
|
||||
case .enableDebugDataDisplay:
|
||||
case .experimentalCompatibility:
|
||||
return 28
|
||||
case .acceleratedStickers:
|
||||
case .enableDebugDataDisplay:
|
||||
return 29
|
||||
case .experimentalBackground:
|
||||
case .acceleratedStickers:
|
||||
return 30
|
||||
case .inlineStickers:
|
||||
case .experimentalBackground:
|
||||
return 31
|
||||
case .localTranscription:
|
||||
case .inlineStickers:
|
||||
return 32
|
||||
case .enableReactionOverrides:
|
||||
case .localTranscription:
|
||||
return 33
|
||||
case .restorePurchases:
|
||||
case .enableReactionOverrides:
|
||||
return 34
|
||||
case .playerEmbedding:
|
||||
case .restorePurchases:
|
||||
return 35
|
||||
case .playlistPlayback:
|
||||
case .playerEmbedding:
|
||||
return 36
|
||||
case .voiceConference:
|
||||
case .playlistPlayback:
|
||||
return 37
|
||||
case .voiceConference:
|
||||
return 38
|
||||
case let .preferredVideoCodec(index, _, _, _):
|
||||
return 38 + index
|
||||
return 39 + index
|
||||
case .disableVideoAspectScaling:
|
||||
return 100
|
||||
case .enableVoipTcp:
|
||||
@ -402,7 +405,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
})
|
||||
case .sendShareLogs:
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: "Send Share Logs (Up to 40 MB)", label: "", sectionId: self.section, style: .blocks, action: {
|
||||
let _ = (Logger.shared.collectLogs(prefix: "/share-logs")
|
||||
let _ = (Logger.shared.collectLogs(prefix: "/logs/share-logs")
|
||||
|> deliverOnMainQueue).start(next: { logs in
|
||||
let presentationData = arguments.sharedContext.currentPresentationData.with { $0 }
|
||||
let actionSheet = ActionSheetController(presentationData: presentationData)
|
||||
@ -570,7 +573,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
})
|
||||
case .sendNotificationLogs:
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: "Send Notification Logs (Up to 40 MB)", label: "", sectionId: self.section, style: .blocks, action: {
|
||||
let _ = (Logger(rootPath: arguments.sharedContext.basePath, basePath: arguments.sharedContext.basePath + "/notification-logs").collectLogs()
|
||||
let _ = (Logger(rootPath: arguments.sharedContext.basePath, basePath: arguments.sharedContext.basePath + "/logs/notification-logs").collectLogs()
|
||||
|> deliverOnMainQueue).start(next: { logs in
|
||||
let presentationData = arguments.sharedContext.currentPresentationData.with { $0 }
|
||||
let actionSheet = ActionSheetController(presentationData: presentationData)
|
||||
@ -705,6 +708,101 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
arguments.presentController(actionSheet, nil)
|
||||
})
|
||||
})
|
||||
case .sendAllLogs:
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: "Send All Logs", label: "", sectionId: self.section, style: .blocks, action: {
|
||||
let logTypes: [String] = [
|
||||
"app-logs",
|
||||
"broadcast-logs",
|
||||
"siri-logs",
|
||||
"widget-logs",
|
||||
"notificationcontent-logs",
|
||||
"notification-logs"
|
||||
]
|
||||
|
||||
var logByType: [Signal<(type: String, logs: [(String, String)]), NoError>] = []
|
||||
for type in logTypes {
|
||||
logByType.append(Logger(rootPath: arguments.sharedContext.basePath, basePath: arguments.sharedContext.basePath + "/logs/\(type)").collectLogs()
|
||||
|> map { result -> (type: String, logs: [(String, String)]) in
|
||||
return (type, result)
|
||||
})
|
||||
}
|
||||
|
||||
let allLogs = combineLatest(logByType)
|
||||
|
||||
let _ = (allLogs
|
||||
|> deliverOnMainQueue).start(next: { allLogs in
|
||||
let presentationData = arguments.sharedContext.currentPresentationData.with { $0 }
|
||||
let actionSheet = ActionSheetController(presentationData: presentationData)
|
||||
|
||||
var items: [ActionSheetButtonItem] = []
|
||||
|
||||
if let context = arguments.context, context.sharedContext.applicationBindings.isMainApp {
|
||||
items.append(ActionSheetButtonItem(title: "Via Telegram", color: .accent, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
|
||||
let controller = context.sharedContext.makePeerSelectionController(PeerSelectionControllerParams(context: context, filter: [.onlyWriteable, .excludeDisabled]))
|
||||
controller.peerSelected = { [weak controller] peer in
|
||||
let peerId = peer.id
|
||||
|
||||
if let strongController = controller {
|
||||
strongController.dismiss()
|
||||
|
||||
let lineFeed = "\n".data(using: .utf8)!
|
||||
|
||||
var tempSources: [TempBoxFile] = []
|
||||
for (type, logItems) in allLogs {
|
||||
let tempSource = TempBox.shared.tempFile(fileName: "Log-\(type).txt")
|
||||
|
||||
var rawLogData: Data = Data()
|
||||
for (name, path) in logItems {
|
||||
if !rawLogData.isEmpty {
|
||||
rawLogData.append(lineFeed)
|
||||
rawLogData.append(lineFeed)
|
||||
}
|
||||
|
||||
rawLogData.append("------ File: \(name) ------\n".data(using: .utf8)!)
|
||||
|
||||
if let data = try? Data(contentsOf: URL(fileURLWithPath: path)) {
|
||||
rawLogData.append(data)
|
||||
}
|
||||
}
|
||||
|
||||
let _ = try? rawLogData.write(to: URL(fileURLWithPath: tempSource.path))
|
||||
tempSources.append(tempSource)
|
||||
}
|
||||
|
||||
let tempZip = TempBox.shared.tempFile(fileName: "destination.zip")
|
||||
SSZipArchive.createZipFile(atPath: tempZip.path, withFilesAtPaths: tempSources.map(\.path))
|
||||
|
||||
guard let gzippedData = try? Data(contentsOf: URL(fileURLWithPath: tempZip.path)) else {
|
||||
return
|
||||
}
|
||||
|
||||
tempSources.forEach(TempBox.shared.dispose)
|
||||
TempBox.shared.dispose(tempZip)
|
||||
|
||||
let id = Int64.random(in: Int64.min ... Int64.max)
|
||||
let fileResource = LocalFileMediaResource(fileId: id, size: Int64(gzippedData.count), isSecretRelated: false)
|
||||
context.account.postbox.mediaBox.storeResourceData(fileResource.id, data: gzippedData)
|
||||
|
||||
let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/zip", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-All.txt.zip")])
|
||||
let message: EnqueueMessage = .message(text: "", attributes: [], mediaReference: .standalone(media: file), replyToMessageId: nil, localGroupingKey: nil, correlationId: nil)
|
||||
|
||||
let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start()
|
||||
}
|
||||
}
|
||||
arguments.pushController(controller)
|
||||
}))
|
||||
}
|
||||
|
||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
})
|
||||
])])
|
||||
arguments.presentController(actionSheet, nil)
|
||||
})
|
||||
})
|
||||
case .accounts:
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: "Accounts", label: "", sectionId: self.section, style: .blocks, action: {
|
||||
guard let context = arguments.context else {
|
||||
@ -1083,6 +1181,7 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
|
||||
entries.append(.sendGroupCallLogs)
|
||||
entries.append(.sendNotificationLogs(presentationData.theme))
|
||||
entries.append(.sendCriticalLogs(presentationData.theme))
|
||||
entries.append(.sendAllLogs)
|
||||
if isMainApp {
|
||||
entries.append(.accounts(presentationData.theme))
|
||||
}
|
||||
|
@ -1369,6 +1369,8 @@ public func standaloneStateManager(
|
||||
Logger.shared.log("StandaloneStateManager", "Received settings")
|
||||
|
||||
return postbox.transaction { transaction -> (PostboxCoding?, LocalizationSettings?, ProxySettings?, NetworkSettings?) in
|
||||
Logger.shared.log("StandaloneStateManager", "Getting state")
|
||||
|
||||
let state = transaction.getState()
|
||||
|
||||
return (state, localizationSettings, proxySettings, transaction.getPreferencesEntry(key: PreferencesKeys.networkSettings)?.get(NetworkSettings.self))
|
||||
|
@ -473,7 +473,19 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
|
||||
TempBox.initializeShared(basePath: rootPath, processType: "app", launchSpecificId: Int64.random(in: Int64.min ... Int64.max))
|
||||
|
||||
let logsPath = rootPath + "/logs"
|
||||
let legacyLogs: [String] = [
|
||||
"logs",
|
||||
"broadcast-logs",
|
||||
"siri-logs",
|
||||
"widget-logs",
|
||||
"notificationcontent-logs",
|
||||
"notification-logs"
|
||||
]
|
||||
for item in legacyLogs {
|
||||
let _ = try? FileManager.default.removeItem(atPath: "\(rootPath)/\(item)")
|
||||
}
|
||||
|
||||
let logsPath = rootPath + "/logs/app-logs"
|
||||
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
|
||||
Logger.setSharedLogger(Logger(rootPath: rootPath, basePath: logsPath))
|
||||
|
||||
|
@ -87,7 +87,7 @@ public final class NotificationViewControllerImpl {
|
||||
|
||||
TempBox.initializeShared(basePath: rootPath, processType: "notification-content", launchSpecificId: Int64.random(in: Int64.min ... Int64.max))
|
||||
|
||||
let logsPath = rootPath + "/notificationcontent-logs"
|
||||
let logsPath = rootPath + "/logs/notificationcontent-logs"
|
||||
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
|
||||
|
||||
setupSharedLogger(rootPath: rootPath, path: logsPath)
|
||||
|
@ -175,7 +175,7 @@ public class ShareRootControllerImpl {
|
||||
|
||||
TempBox.initializeShared(basePath: rootPath, processType: "share", launchSpecificId: Int64.random(in: Int64.min ... Int64.max))
|
||||
|
||||
let logsPath = rootPath + "/share-logs"
|
||||
let logsPath = rootPath + "/logs/share-logs"
|
||||
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
|
||||
|
||||
setupSharedLogger(rootPath: rootPath, path: logsPath)
|
||||
|
Loading…
x
Reference in New Issue
Block a user