Only send ntfy-msg when ntfy-data is specified
This commit is contained in:
parent
f5607f8023
commit
b4a82c745d
@ -55,19 +55,22 @@ public class TaskSchedulingService {
|
||||
public void sendRunningTaskNotification(AbstractSchedule abstractSchedule) {
|
||||
HttpClient httpClient = HttpClient.newHttpClient();
|
||||
User user = abstractSchedule.getTask().getTaskgroup().getUser();
|
||||
try {
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI(user.getNtfy_host()+ "/" + user.getNtfy_topic()))
|
||||
.POST(HttpRequest.BodyPublishers.ofString("Running Task " + abstractSchedule.getTask().getTaskName()))
|
||||
.header("Tags", "heavy_check_mark")
|
||||
.header("Title", "Task Running")
|
||||
.header("Actions", "view, Open TimeScheduler, "+frontend_domain+", clear=true")
|
||||
.build();
|
||||
if(user.getNtfy_host() != null && user.getNtfy_topic() != null) {
|
||||
try {
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(new URI(user.getNtfy_host()+ "/" + user.getNtfy_topic()))
|
||||
.POST(HttpRequest.BodyPublishers.ofString("Running Task " + abstractSchedule.getTask().getTaskName()))
|
||||
.header("Tags", "heavy_check_mark")
|
||||
.header("Title", "Task Running")
|
||||
.header("Actions", "view, Open TimeScheduler, "+frontend_domain+", clear=true")
|
||||
.build();
|
||||
|
||||
httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString());
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString());
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Date calculateDelayInMillis(LocalDateTime executionTime) {
|
||||
|
Loading…
Reference in New Issue
Block a user