Skip to content

Commit

Permalink
add option for -custom-sofa-feed-url
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Jul 22, 2024
1 parent 73656af commit efb9ecc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Nudge/3rd Party Assets/sofa.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ extension MacOSDataFeed {

class SOFA: NSObject, URLSessionDelegate {
func URLSync(url: URL, maxRetries: Int = 3) -> (data: Data?, response: URLResponse?, error: Error?, responseCode: Int?, eTag: String?) {
if url.scheme == "file" {
do {
let data = try Data(contentsOf: url)
return (data, nil, nil, 200, nil)
} catch {
return (nil, nil, error, nil, nil)
}
}

let semaphore = DispatchSemaphore(value: 0)
let lastEtag = Globals.nudgeDefaults.string(forKey: "LastEtag") ?? ""
var request = URLRequest(url: url)
Expand Down
1 change: 1 addition & 0 deletions Nudge/Preferences/DefaultPreferencesNudge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ struct OptionalFeatureVariables {
}

static var customSOFAFeedURL: String {
CommandLineUtilities().customSOFAFeedURLOption() ??
optionalFeaturesProfile?["customSOFAFeedURL"] as? String ??
optionalFeaturesJSON?.customSOFAFeedURL ??
"https://sofafeed.macadmins.io/v1/macos_data_feed.json"
Expand Down
4 changes: 4 additions & 0 deletions Nudge/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ struct CommandLineUtilities {
return checkAndLogArgument("-bundle-mode-profile", logStateKey: &nudgeLogState.hasLoggedBundleMode)
}

func customSOFAFeedURLOption() -> String? {
return valueForArgument("-custom-sofa-feed-url")
}

func debugUIModeEnabled() -> Bool {
return checkAndLogArgument("-debug-ui-mode", logStateKey: &nudgeLogState.afterFirstRun)
}
Expand Down

0 comments on commit efb9ecc

Please sign in to comment.