Skip to content

Commit 0172835

Browse files
committed
allow dynamic sofa aboutUpdateURLs
1 parent 2b43ba4 commit 0172835

File tree

6 files changed

+22
-6
lines changed

6 files changed

+22
-6
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [2.0.7] - 2024-08-08
88
Requires macOS 12.0 and higher.
99

10+
### Added
11+
- If using `utilizeSOFAFeed`, you can now set the `aboutUpdateURL` to `sofa`
12+
- If a URL is found in the relevant `SecurityInfo` key for the corresponding update, this value will be used.
13+
- If no URL is found, the aboutUpdateURL button will not be shown to the user
14+
- [Feature Request 629](https://github.com/macadmins/nudge/issues/629)
15+
1016
### Changed
1117
- The `SMAppService` logic logs have been moved to debug logs
1218
- When an updated Managed Preference is sent for `com.github.macadmins.Nudge`, if the values are different, [Nudge will exit](https://github.com/macadmins/nudge/commit/f13a697dd61400f7f0d73dc38226f7769ed8e4f4)

Example Assets/com.github.macadmins.Nudge.tester.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"osVersionRequirements": [
77
{
8-
"aboutUpdateURL": "https://apple.com",
8+
"aboutUpdateURL": "sofa",
99
"requiredMinimumOSVersion": "latest",
1010
"unsupportedURL": "https://google.com"
1111
}

Nudge/UI/Common/InformationButton.swift

+11-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,19 @@ struct InformationButton: View {
2020

2121
private var informationButton: some View {
2222
guard OSVersionRequirementVariables.aboutUpdateURL != "" else { return AnyView(EmptyView()) }
23+
var selectedURL = OSVersionRequirementVariables.aboutUpdateURL
24+
if OSVersionRequirementVariables.aboutUpdateURL == "sofa" && OptionalFeatureVariables.utilizeSOFAFeed {
25+
if nudgePrimaryState.sofaAboutUpdateURL.hasPrefix("https://") {
26+
selectedURL = nudgePrimaryState.sofaAboutUpdateURL
27+
} else {
28+
return AnyView(EmptyView())
29+
}
30+
}
2331

2432
return AnyView(
25-
Button(action: UIUtilities().openMoreInfo) {
33+
Button(action: {
34+
UIUtilities().openMoreInfo(infoURL: selectedURL)
35+
}) {
2636
Text(.init(UserInterfaceVariables.informationButtonText.localized(desiredLanguage: getDesiredLanguage(locale: appState.locale))))
2737
.foregroundColor(dynamicTextColor)
2838
}

Nudge/UI/Defaults.swift

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class AppState: ObservableObject {
8383
@Published var requireDualQuitButtons = false
8484
@Published var requiredMinimumOSVersion = OSVersionRequirementVariables.requiredMinimumOSVersion
8585
@Published var shouldExit = false
86+
@Published var sofaAboutUpdateURL: String = ""
8687
@Published var timerCycle = 0
8788
@Published var userDeferrals = Globals.nudgeDefaults.object(forKey: "userDeferrals") as? Int ?? 0
8889
@Published var userQuitDeferrals = Globals.nudgeDefaults.object(forKey: "userQuitDeferrals") as? Int ?? 0

Nudge/UI/Main.swift

+1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
282282

283283
// Start setting UI fields
284284
nudgePrimaryState.requiredMinimumOSVersion = selectedOS!.productVersion
285+
nudgePrimaryState.sofaAboutUpdateURL = selectedOS!.securityInfo
285286
nudgePrimaryState.activelyExploitedCVEs = activelyExploitedCVEs
286287
releaseDate = selectedOS!.releaseDate ?? Date()
287288
if requiredInstallationDate == Date(timeIntervalSince1970: 0) {

Nudge/Utilities/Utils.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -1423,13 +1423,11 @@ struct UIUtilities {
14231423
return shellCommands.contains(where: path.hasPrefix)
14241424
}
14251425

1426-
func openMoreInfo() {
1427-
guard let url = URL(string: OSVersionRequirementVariables.aboutUpdateURL) else {
1426+
func openMoreInfo(infoURL: String) {
1427+
guard let url = URL(string: infoURL) else {
14281428
return
14291429
}
14301430
LogManager.notice("User clicked moreInfo button", logger: uiLog)
1431-
// TODO: Flesh this out once we understand what to do when there isn't a url in SOFA feed
1432-
// if OSVersionRequirementVariables.aboutUpdateURL == "sofa" { NSWorkspace.shared.open(url) }
14331431
NSWorkspace.shared.open(url)
14341432
}
14351433

0 commit comments

Comments
 (0)