diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs index 9e92d061c7..a843de7f7d 100644 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -212,6 +212,7 @@ namespace MaaWpfGui.Constants public const string ExternalNotificationTelegramBotToken = "ExternalNotification.Telegram.BotToken"; public const string ExternalNotificationTelegramChatId = "ExternalNotification.Telegram.ChatId"; public const string ExternalNotificationBarkSendKey = "ExternalNotification.Bark.SendKey"; + public const string ExternalNotificationBarkServer = "ExternalNotification.Bark.Server"; // The following should not be modified manually public const string VersionName = "VersionUpdate.name"; diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index e6d47a77a4..5108190ab5 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -34,6 +34,7 @@ This is MAA external notification test information. If you see this content, the notification was sent successfully! Server Chan Send Key Bark Send Key + Bark Server Recipient SMTP Server Port diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index 187cede3c4..2674664b01 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -34,6 +34,7 @@ これは MAA 外部通知テスト情報です。 このコンテンツが表示された場合、通知は正常に送信されました! ServerChan Send Key Bark Send Key + Bark サーバ SMTP サーバ ポート SSL を使用します diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index 0f84a5443c..ef85a91809 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -34,6 +34,7 @@ MAA 외부 알림 테스트 정보입니다. 이 콘텐츠가 표시되면 알림이 성공적으로 전송된 것입니다! Server Chan 전송 키 Bark 전송 키 + Bark 서버 SMTP 서버 포트 는 SSL을 사용합니다. diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index eda17daee3..924f04cdd7 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -34,6 +34,7 @@ 这是 MAA 外部通知测试信息。如果你看到了这段内容,就说明通知发送成功了! Server Chan 发送密钥 Bark 发送密钥 + Bark 服务器 SMTP 服务器 端口 使用 SSL diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 5948edda8a..c2dec3f904 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -34,6 +34,7 @@ 這是 MAA 外部通知測試資訊。 如果你看到了這段內容,就說明通知發送成功了! Server Chan 發送金鑰 Bark 發送金鑰 + Bark 伺服器 SMTP 伺服器 使用 SSL diff --git a/src/MaaWpfGui/Services/Notification/BarkNotificationProvider.cs b/src/MaaWpfGui/Services/Notification/BarkNotificationProvider.cs index 2028058cbc..0f81ed9500 100644 --- a/src/MaaWpfGui/Services/Notification/BarkNotificationProvider.cs +++ b/src/MaaWpfGui/Services/Notification/BarkNotificationProvider.cs @@ -19,8 +19,6 @@ namespace MaaWpfGui.Services.Notification private readonly ILogger _logger = Log.ForContext(); - private readonly string _apiBase = "https://api.day.app"; - public BarkNotificationProvider(IHttpService httpService) { _httpService = httpService; @@ -34,8 +32,14 @@ namespace MaaWpfGui.Services.Notification _logger.Warning("Failed to send Bark notification, Bark send key is empty"); return false; } + var apiBase = ConfigurationHelper.GetValue(ConfigurationKeys.ExternalNotificationBarkServer, string.Empty); + if (string.IsNullOrWhiteSpace(apiBase)) + { + _logger.Warning("Failed to send Bark notification, Bark server address is empty"); + return false; + } var response = await _httpService.PostAsJsonAsync( - new Uri($"{_apiBase}/push"), + new Uri(new Uri(apiBase), "/push"), new BarkPostContent { Title = title, Content = content, SendKey = sendKey }); var data = JsonSerializer.Deserialize(response); if (data.Code != 200) diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index 5b1a0b29cf..c6305b4c23 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -406,6 +406,18 @@ namespace MaaWpfGui.ViewModels.UI private string _barkSendKey = ConfigurationHelper.GetValue(ConfigurationKeys.ExternalNotificationBarkSendKey, string.Empty); + public string BarkServer + { + get => _barkServer; + set + { + SetAndNotify(ref _barkServer, value); + ConfigurationHelper.SetValue(ConfigurationKeys.ExternalNotificationBarkServer, value); + } + } + + private string _barkServer = ConfigurationHelper.GetValue(ConfigurationKeys.ExternalNotificationBarkServer, "https://api.day.app"); + private string _smtpServer = ConfigurationHelper.GetValue(ConfigurationKeys.ExternalNotificationSmtpServer, string.Empty); public string SmtpServer diff --git a/src/MaaWpfGui/Views/UserControl/ExternalNotificationSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/ExternalNotificationSettingsUserControl.xaml index d6eeacde3d..d77deef69e 100644 --- a/src/MaaWpfGui/Views/UserControl/ExternalNotificationSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/ExternalNotificationSettingsUserControl.xaml @@ -359,27 +359,46 @@ Visibility="{c:Binding 'EnabledExternalNotificationProvider == "Bark"'}" Orientation="Horizontal"> + + + + + + Text="{c:Binding BarkServer}" /> +