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:
Riley Testut
2023-05-30 12:57:45 -05:00
parent 48105f068b
commit 13248c05e7
2 changed files with 25 additions and 26 deletions

View File

@@ -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
{