1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-04-01 09:10:08 +02:00

♻️ WIP: Integrations are off by default

This commit is contained in:
2026-02-06 15:39:59 +01:00
parent 17339c0aa5
commit d6d1d3ec0c
4 changed files with 42 additions and 5 deletions

View File

@@ -8,22 +8,30 @@
import Cocoa
import Foundation
import NVAlert
extension AppDelegate {
/**
This is an entry point for future development for integrating with the PHP Monitor
application URL. You can use the `phpmon://` protocol to communicate with the app.
At this time you can trigger the site list using Alfred (or some other application)
by opening the following URL: `phpmon://list`.
Please note that PHP Monitor needs to be running in the background for this to work.
*/
@MainActor func application(_ application: NSApplication, open urls: [URL]) {
if !Preferences.isEnabled(.allowProtocolForIntegrations) {
Log.info("Acting on commands via phpmon:// has been disabled.")
return
if UserDefaults.standard.bool(forKey: PersistentAppState.didPromptForIntegrations.rawValue) {
Log.info("Acting on commands via phpmon:// has been disabled.")
return
}
Log.info("Acting on commands via phpmon:// has been disabled. Prompting user...")
if !promptToEnableIntegrations() {
return
}
}
guard let url = urls.first else { return }
@@ -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]) {
commands.forEach { action in
if command.starts(with: action.command) {

View File

@@ -111,6 +111,7 @@ enum PersistentAppState: String {
case lastAutomaticUpdateCheck = "last_automatic_update_check"
case userFavorites = "user_favorites"
case updateCheckFailureCount = "update_check_failure_count"
case didPromptForIntegrations = "did_prompt_for_integrations"
}
/**

View File

@@ -62,7 +62,7 @@ class Preferences {
/// Preferences: General
PreferenceName.autoServiceRestartAfterExtensionToggle.rawValue: true,
PreferenceName.autoComposerGlobalUpdateAfterSwitch.rawValue: false,
PreferenceName.allowProtocolForIntegrations.rawValue: true,
PreferenceName.allowProtocolForIntegrations.rawValue: false,
PreferenceName.automaticBackgroundUpdateCheck.rawValue: true,
PreferenceName.showPhpDoctorSuggestions.rawValue: true,
PreferenceName.languageOverride.rawValue: "",

View File

@@ -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.";
"crash_reporter.send_report" = "Send Report";
"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";