mirror of
https://github.com/JasonHHouse/gaps.git
synced 2026-02-16 07:49:37 -06:00
Minor cleanup to notifications
This commit is contained in:
@@ -13,5 +13,5 @@ package com.jasonhhouse.gaps.notifications;
|
||||
public interface NotificationAgent {
|
||||
boolean isEnabled();
|
||||
|
||||
void sendMessage(String level, String message);
|
||||
void sendMessage(String level, String title, String message);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TelegramNotificationAgent implements NotificationAgent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String level, String message) {
|
||||
public void sendMessage(String level, String title, String message) {
|
||||
|
||||
HttpUrl url = new HttpUrl.Builder()
|
||||
.scheme("https")
|
||||
@@ -50,7 +50,7 @@ public class TelegramNotificationAgent implements NotificationAgent {
|
||||
.addPathSegment("sendMessage")
|
||||
.build();
|
||||
|
||||
String telegramMessage = String.format("{\"chat_id\":\"%s\", \"text\":\"%s\", \"parse_mode\":\"HTML\"}", chatId, message);
|
||||
String telegramMessage = String.format("{\"chat_id\":\"%s\", \"text\":\"%s\", \"parse_mode\":\"HTML\"}", chatId, String.format("<strong>%s</strong>\n%s", title, message));
|
||||
LOGGER.info("telegramMessage {}", telegramMessage);
|
||||
RequestBody body = RequestBody.create(telegramMessage, MediaType.get("application/json"));
|
||||
|
||||
|
||||
@@ -22,4 +22,6 @@ public interface Notification {
|
||||
void recommendedMoviesSearchFailed(PlexServer plexServer, PlexLibrary plexLibrary, String error);
|
||||
|
||||
void recommendedMoviesSearchFinished(PlexServer plexServer, PlexLibrary plexLibrary);
|
||||
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,10 @@ public class NotificationService implements Notification {
|
||||
|
||||
@Override
|
||||
public void plexServerConnectSuccessful(PlexServer plexServer) {
|
||||
notificationAgents.forEach(notificationAgent -> notificationAgent.sendMessage("INFO", String.format("<strong>Automatic Search</strong>\nConnection to Plex Server %s Successful", plexServer.getFriendlyName())));
|
||||
notificationAgents
|
||||
.stream()
|
||||
.filter(NotificationAgent::isEnabled)
|
||||
.forEach(notificationAgent -> notificationAgent.sendMessage("INFO", "Automatic Search", String.format("Connection to Plex Server %s Successful", plexServer.getFriendlyName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,4 +62,12 @@ public class NotificationService implements Notification {
|
||||
public void recommendedMoviesSearchFinished(PlexServer plexServer, PlexLibrary plexLibrary) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test() {
|
||||
notificationAgents
|
||||
.stream()
|
||||
.filter(NotificationAgent::isEnabled)
|
||||
.forEach(notificationAgent -> notificationAgent.sendMessage("DEBUG", "Gaps Test", "Test Successful"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user