mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			86 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			86 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			Swift
		
	
| 
											2 years ago
										 | // Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. | ||
| 
											2 years ago
										 | // | ||
|  | // stringlint:disable | ||
| 
											2 years ago
										 | 
 | ||
|  | import Foundation | ||
| 
											8 months ago
										 | import SessionSnodeKit | ||
| 
											2 years ago
										 | import SessionMessagingKit | ||
| 
											8 months ago
										 | import SessionUtilitiesKit | ||
| 
											2 years ago
										 | 
 | ||
| 
											8 months ago
										 | enum NotificationResolution: CustomStringConvertible { | ||
|  |     case success(PushNotificationAPI.NotificationMetadata) | ||
|  |     case successCall | ||
|  |      | ||
|  |     case ignoreDueToMainAppRunning | ||
|  |     case ignoreDueToNoContentFromApple | ||
|  |     case ignoreDueToNonLegacyGroupLegacyNotification | ||
|  |     case ignoreDueToOutdatedMessage | ||
|  |     case ignoreDueToRequiresNoNotification | ||
|  |     case ignoreDueToDuplicateMessage | ||
|  |     case ignoreDueToContentSize(PushNotificationAPI.NotificationMetadata) | ||
|  |      | ||
|  |     case errorTimeout | ||
|  |     case errorNotReadyForExtensions | ||
|  |     case errorNoContentLegacy | ||
|  |     case errorDatabaseInvalid | ||
|  |     case errorDatabaseMigrations(Error) | ||
|  |     case errorTransactionFailure | ||
|  |     case errorLegacyGroupKeysMissing | ||
|  |     case errorCallFailure | ||
|  |     case errorNoContent(PushNotificationAPI.NotificationMetadata) | ||
|  |     case errorProcessing(PushNotificationAPI.ProcessResult) | ||
|  |     case errorMessageHandling(MessageReceiverError) | ||
|  |     case errorOther(Error) | ||
| 
											2 years ago
										 |      | ||
| 
											2 years ago
										 |     public var description: String { | ||
| 
											2 years ago
										 |         switch self { | ||
| 
											8 months ago
										 |             case .success(let metadata): return "Completed: Handled notification from namespace: \(metadata.namespace)" | ||
|  |             case .successCall: return "Completed: Notified main app of call message" | ||
|  |              | ||
|  |             case .ignoreDueToMainAppRunning: return "Ignored: Main app running" | ||
|  |             case .ignoreDueToNoContentFromApple: return "Ignored: No content" | ||
|  |             case .ignoreDueToNonLegacyGroupLegacyNotification: return "Ignored: Non-group legacy notification" | ||
|  |             case .ignoreDueToOutdatedMessage: return "Ignored: Alteady seen message" | ||
|  |             case .ignoreDueToRequiresNoNotification: return "Ignored: Message requires no notification" | ||
|  |              | ||
|  |             case .ignoreDueToDuplicateMessage: | ||
|  |                 return "Ignored: Duplicate message (probably received it just before going to the background)" | ||
|  |              | ||
|  |             case .ignoreDueToContentSize(let metadata): | ||
|  |                 return "Ignored: Notification content from namespace: \(metadata.namespace) was too long: \(metadata.dataLength)" | ||
|  |              | ||
|  |             case .errorTimeout: return "Failed: Execution time expired" | ||
|  |             case .errorNotReadyForExtensions: return "Failed: App not ready for extensions" | ||
|  |             case .errorNoContentLegacy: return "Failed: Legacy notification contained invalid payload" | ||
|  |             case .errorDatabaseInvalid: return "Failed: Database in invalid state" | ||
|  |             case .errorDatabaseMigrations(let error): return "Failed: Database migration error: \(error)" | ||
|  |             case .errorTransactionFailure: return "Failed: Unexpected database transaction rollback" | ||
|  |             case .errorLegacyGroupKeysMissing: return "Failed: No legacy group decryption keys" | ||
|  |             case .errorCallFailure: return "Failed: Failed to handle call message" | ||
|  |              | ||
|  |             case .errorNoContent(let metadata): | ||
|  |                 return "Failed: Notification from namespace: \(metadata.namespace) contained no content, expected dataLength: \(metadata.dataLength)" | ||
|  |                  | ||
|  |             case .errorProcessing(let result): return "Failed: Unable to process notification (\(result))" | ||
|  |             case .errorMessageHandling(let error): return "Failed: Handling the message (\(error))" | ||
|  |             case .errorOther(let error): return "Error: Unhandled error occurred (\(error))" | ||
|  |         } | ||
|  |     } | ||
|  |      | ||
|  |     public var logLevel: Log.Level { | ||
|  |         switch self { | ||
|  |             case .success, .successCall, .ignoreDueToMainAppRunning, .ignoreDueToNoContentFromApple, | ||
|  |                 .ignoreDueToNonLegacyGroupLegacyNotification, .ignoreDueToOutdatedMessage, | ||
|  |                 .ignoreDueToRequiresNoNotification, .ignoreDueToDuplicateMessage, .ignoreDueToContentSize: | ||
|  |                 return .info | ||
|  |                  | ||
|  |             case .errorNotReadyForExtensions, .errorNoContentLegacy, .errorNoContent, .errorCallFailure: | ||
|  |                 return .warn | ||
|  |                  | ||
|  |             case .errorTimeout, .errorDatabaseInvalid, .errorDatabaseMigrations, .errorTransactionFailure, | ||
|  |                     .errorLegacyGroupKeysMissing, .errorProcessing, .errorMessageHandling, .errorOther: | ||
|  |                 return .error | ||
| 
											2 years ago
										 |         } | ||
|  |     } | ||
|  | } |