Skip to content

Commit

Permalink
new utilizeSOFAFeed preference - defaults to false
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Jul 18, 2024
1 parent 7308668 commit acbf33f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Example Assets/com.github.macadmins.Nudge.tester.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"com.microsoft.VSCode",
"us.zoom.xos"
],
"terminateApplicationsOnLaunch": false
"terminateApplicationsOnLaunch": false,
"utilizeSOFAFeed": true
},
"osVersionRequirements": [
{
Expand Down
6 changes: 6 additions & 0 deletions Nudge/Preferences/DefaultPreferencesNudge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ struct OptionalFeatureVariables {
optionalFeaturesJSON?.terminateApplicationsOnLaunch ??
false
}

static var utilizeSOFAFeed: Bool {
optionalFeaturesProfile?["utilizeSOFAFeedh"] as? Bool ??
optionalFeaturesJSON?.utilizeSOFAFeed ??
false
}
}

// OS Version Requirements
Expand Down
8 changes: 5 additions & 3 deletions Nudge/Preferences/PreferencesStructure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct OptionalFeatures: Codable {
var acceptableApplicationBundleIDs, acceptableAssertionApplicationNames: [String]?
var acceptableAssertionUsage, acceptableCameraUsage, acceptableScreenSharingUsage, aggressiveUserExperience, aggressiveUserFullScreenExperience, asynchronousSoftwareUpdate, attemptToBlockApplicationLaunches, attemptToFetchMajorUpgrade: Bool?
var blockedApplicationBundleIDs: [String]?
var disableSoftwareUpdateWorkflow, enforceMinorUpdates, terminateApplicationsOnLaunch: Bool?
var disableSoftwareUpdateWorkflow, enforceMinorUpdates, terminateApplicationsOnLaunch, utilizeSOFAFeed: Bool?
}

// MARK: OptionalFeatures convenience initializers and mutators
Expand Down Expand Up @@ -88,7 +88,8 @@ extension OptionalFeatures {
blockedApplicationBundleIDs: [String]? = nil,
disableSoftwareUpdateWorkflow: Bool? = nil,
enforceMinorUpdates: Bool? = nil,
terminateApplicationsOnLaunch: Bool? = nil
terminateApplicationsOnLaunch: Bool? = nil,
utilizeSOFAFeed: Bool? = nil
) -> OptionalFeatures {
return OptionalFeatures(
acceptableApplicationBundleIDs: acceptableApplicationBundleIDs ?? self.acceptableApplicationBundleIDs,
Expand All @@ -104,7 +105,8 @@ extension OptionalFeatures {
blockedApplicationBundleIDs: blockedApplicationBundleIDs ?? self.blockedApplicationBundleIDs,
disableSoftwareUpdateWorkflow: disableSoftwareUpdateWorkflow ?? self.disableSoftwareUpdateWorkflow,
enforceMinorUpdates: enforceMinorUpdates ?? self.enforceMinorUpdates,
terminateApplicationsOnLaunch: terminateApplicationsOnLaunch ?? self.terminateApplicationsOnLaunch
terminateApplicationsOnLaunch: terminateApplicationsOnLaunch ?? self.terminateApplicationsOnLaunch,
utilizeSOFAFeed: utilizeSOFAFeed ?? self.utilizeSOFAFeed
)
}
}
Expand Down
3 changes: 3 additions & 0 deletions Nudge/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,9 @@ struct NetworkFileManager {
}

func getSOFAAssets() -> MacOSDataFeed? {
if !OptionalFeatureVariables.utilizeSOFAFeed {
return nil
}
if let url = URL(string: "https://sofa.macadmins.io/v1/macos_data_feed.json") {
let sofaData = SOFA().URLSync(url: url)
if (sofaData.error == nil) {
Expand Down

0 comments on commit acbf33f

Please sign in to comment.