mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-13 08:43:27 +01:00
Revises appPermissions format in source JSON
Before, appPermissions was one array containing all permissions of different types. Now, we split entitlement and privacy permissions into separate “entitlements” and “privacy” child arrays.
This commit is contained in:
@@ -41,9 +41,7 @@ public class AppPermission: NSManagedObject, Decodable, Fetchable
|
||||
|
||||
private enum CodingKeys: String, CodingKey
|
||||
{
|
||||
case entitlement
|
||||
case privacyType = "privacy"
|
||||
|
||||
case name
|
||||
case usageDescription
|
||||
}
|
||||
|
||||
@@ -57,27 +55,11 @@ public class AppPermission: NSManagedObject, Decodable, Fetchable
|
||||
{
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
self._permission = try container.decode(String.self, forKey: .name)
|
||||
self.usageDescription = try container.decodeIfPresent(String.self, forKey: .usageDescription)
|
||||
|
||||
if let entitlement = try container.decodeIfPresent(String.self, forKey: .entitlement)
|
||||
{
|
||||
self._permission = entitlement
|
||||
self.type = .entitlement
|
||||
}
|
||||
else if let privacyType = try container.decodeIfPresent(String.self, forKey: .privacyType)
|
||||
{
|
||||
self._permission = privacyType
|
||||
self.type = .privacy
|
||||
}
|
||||
else
|
||||
{
|
||||
self._permission = ""
|
||||
self.type = .unknown
|
||||
|
||||
// We don't want to save any unknown permissions, but can't throw error
|
||||
// without making the entire decoding fail, so just delete self instead.
|
||||
context.delete(self)
|
||||
}
|
||||
// Will be updated from StoreApp.
|
||||
self.type = .unknown
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user