Log failed whatsapp reminders
This commit is contained in:
1 parent
52766b12f2
commit
bd03483fda
2 files changed
+25
-11
No files matched your search
@@ -468,12 +468,16 @@ public class TippligaSQLConnector {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getMarkWhatsAppReminderAsSentQuery(WhatsAppReminder reminder) {
|
||||
return """
|
||||
INSERT INTO phpbb_footb_whatsapp_reminders
|
||||
(season, league, matchday, delivery_date, user_id, remaining_hours)
|
||||
VALUES
|
||||
(""" + reminder.season() + ", " + reminder.league() + ", " + reminder.matchday() + ", '" + reminder.deliveryDate() + "', " + reminder.userId() + ", " + reminder.remainingHours() + ");";
|
||||
}
|
||||
|
||||
public void markWhatsAppReminderAsSent(WhatsAppReminder reminder) {
|
||||
String query = """
|
||||
INSERT INTO phpbb_footb_whatsapp_reminders
|
||||
(season, league, matchday, delivery_date, user_id, remaining_hours)
|
||||
VALUES
|
||||
(""" + reminder.season() + ", " + reminder.league() + ", " + reminder.matchday() + ", '" + reminder.deliveryDate() + "', " + reminder.userId() + ", " + reminder.remainingHours() + ");";
|
||||
executeUpdate(query);
|
||||
executeUpdate(getMarkWhatsAppReminderAsSentQuery(reminder));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
package de.jeyp91.whatsapp;
|
||||
|
||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
@@ -12,6 +7,12 @@ import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||
|
||||
public class WhatsAppNotifier {
|
||||
private final String host = System.getenv("TLW_WHATSAPP_HOST");
|
||||
private final String port = System.getenv("TLW_WHATSAPP_PORT");
|
||||
@@ -35,6 +36,7 @@ public class WhatsAppNotifier {
|
||||
markReminderAsSent(reminder);
|
||||
logger.info("WhatsApp Erinnerung an " + reminder.username() + " gesendet.");
|
||||
} else {
|
||||
logFailedReminder(reminder);
|
||||
logger.error("WhatsApp Nachricht senden an " + reminder.username() + " fehlgeschlagen.");
|
||||
}
|
||||
});
|
||||
@@ -68,5 +70,13 @@ public class WhatsAppNotifier {
|
||||
public void markReminderAsSent(WhatsAppReminder reminder) {
|
||||
TippligaSQLConnector.getInstance().markWhatsAppReminderAsSent(reminder);
|
||||
}
|
||||
|
||||
private void logFailedReminder(WhatsAppReminder reminder) {
|
||||
String message = openAIConnector.getReminderMessage(reminder);
|
||||
String query = TippligaSQLConnector.getInstance().getMarkWhatsAppReminderAsSentQuery(reminder);
|
||||
|
||||
logger.info(message);
|
||||
logger.info(query);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user