mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-04-03 18:00:10 +02:00
♻️ WIP: Integrations are off by default
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Cocoa
|
import Cocoa
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import NVAlert
|
||||||
|
|
||||||
extension AppDelegate {
|
extension AppDelegate {
|
||||||
|
|
||||||
@@ -22,10 +23,17 @@ extension AppDelegate {
|
|||||||
*/
|
*/
|
||||||
@MainActor func application(_ application: NSApplication, open urls: [URL]) {
|
@MainActor func application(_ application: NSApplication, open urls: [URL]) {
|
||||||
if !Preferences.isEnabled(.allowProtocolForIntegrations) {
|
if !Preferences.isEnabled(.allowProtocolForIntegrations) {
|
||||||
|
if UserDefaults.standard.bool(forKey: PersistentAppState.didPromptForIntegrations.rawValue) {
|
||||||
Log.info("Acting on commands via phpmon:// has been disabled.")
|
Log.info("Acting on commands via phpmon:// has been disabled.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.info("Acting on commands via phpmon:// has been disabled. Prompting user...")
|
||||||
|
if !promptToEnableIntegrations() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
guard let url = urls.first else { return }
|
guard let url = urls.first else { return }
|
||||||
|
|
||||||
self.interpretCommand(
|
self.interpretCommand(
|
||||||
@@ -34,6 +42,26 @@ extension AppDelegate {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func promptToEnableIntegrations() -> Bool {
|
||||||
|
UserDefaults.standard.set(true, forKey: PersistentAppState.didPromptForIntegrations.rawValue)
|
||||||
|
UserDefaults.standard.synchronize()
|
||||||
|
|
||||||
|
if !NVAlert()
|
||||||
|
.withInformation(
|
||||||
|
title: "alert.enable_integrations.title".localized,
|
||||||
|
subtitle: "alert.enable_integrations.subtitle".localized,
|
||||||
|
description: "alert.enable_integrations.desc".localized
|
||||||
|
)
|
||||||
|
.withPrimary(text: "alert.enable_integrations.ok".localized)
|
||||||
|
.withSecondary(text: "alert.enable_integrations.cancel".localized)
|
||||||
|
.didSelectPrimary(urgency: .bringToFront) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
Preferences.update(.allowProtocolForIntegrations, value: true)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
private func interpretCommand(_ command: String, commands: [InterApp.Action]) {
|
private func interpretCommand(_ command: String, commands: [InterApp.Action]) {
|
||||||
commands.forEach { action in
|
commands.forEach { action in
|
||||||
if command.starts(with: action.command) {
|
if command.starts(with: action.command) {
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ enum PersistentAppState: String {
|
|||||||
case lastAutomaticUpdateCheck = "last_automatic_update_check"
|
case lastAutomaticUpdateCheck = "last_automatic_update_check"
|
||||||
case userFavorites = "user_favorites"
|
case userFavorites = "user_favorites"
|
||||||
case updateCheckFailureCount = "update_check_failure_count"
|
case updateCheckFailureCount = "update_check_failure_count"
|
||||||
|
case didPromptForIntegrations = "did_prompt_for_integrations"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class Preferences {
|
|||||||
/// Preferences: General
|
/// Preferences: General
|
||||||
PreferenceName.autoServiceRestartAfterExtensionToggle.rawValue: true,
|
PreferenceName.autoServiceRestartAfterExtensionToggle.rawValue: true,
|
||||||
PreferenceName.autoComposerGlobalUpdateAfterSwitch.rawValue: false,
|
PreferenceName.autoComposerGlobalUpdateAfterSwitch.rawValue: false,
|
||||||
PreferenceName.allowProtocolForIntegrations.rawValue: true,
|
PreferenceName.allowProtocolForIntegrations.rawValue: false,
|
||||||
PreferenceName.automaticBackgroundUpdateCheck.rawValue: true,
|
PreferenceName.automaticBackgroundUpdateCheck.rawValue: true,
|
||||||
PreferenceName.showPhpDoctorSuggestions.rawValue: true,
|
PreferenceName.showPhpDoctorSuggestions.rawValue: true,
|
||||||
PreferenceName.languageOverride.rawValue: "",
|
PreferenceName.languageOverride.rawValue: "",
|
||||||
|
|||||||
@@ -949,3 +949,11 @@ PHP Monitor will tell Valet to unsecure and re-secure all expired domains for yo
|
|||||||
➡️ If the crash keeps happening at a specific point in time, you may want to check GitHub's issue tracker to see if a fix is not in the works. If the app keeps crashing prior to initialization, you may need to update PHP Monitor manually.";
|
➡️ If the crash keeps happening at a specific point in time, you may want to check GitHub's issue tracker to see if a fix is not in the works. If the app keeps crashing prior to initialization, you may need to update PHP Monitor manually.";
|
||||||
"crash_reporter.send_report" = "Send Report";
|
"crash_reporter.send_report" = "Send Report";
|
||||||
"crash_reporter.do_not_send" = "Don't Send";
|
"crash_reporter.do_not_send" = "Don't Send";
|
||||||
|
|
||||||
|
// THIRD-PARTY INTEGRATIONS
|
||||||
|
|
||||||
|
"alert.enable_integrations.title" = "An external application is trying to communicate with PHP Monitor";
|
||||||
|
"alert.enable_integrations.subtitle" = "Do you want to allow third-party integrations (like Alfred or Raycast) to control PHP Monitor via the phpmon:// protocol?\n\nThis prompt appeared because PHP Monitor just received an external command. If you triggered this from a third-party app like Alfred or Raycast, it is safe to allow this.\n\nYou can change this setting later in Preferences.";
|
||||||
|
"alert.enable_integrations.desc" = "If you did not trigger this via Alfred or Raycast, there may be another application trying to control PHP Monitor. In that case I recommend checking what could be causing this and keeping this integration turned off for security reasons.";
|
||||||
|
"alert.enable_integrations.ok" = "Allow Integrations";
|
||||||
|
"alert.enable_integrations.cancel" = "Don't Allow";
|
||||||
|
|||||||
Reference in New Issue
Block a user