Update dependencies and add support for google calendar html event description

This commit is contained in:
2022-11-07 18:00:29 +01:00
parent 87c3dd21c6
commit dac3f31a37
3 changed files with 34 additions and 22 deletions

View File

@@ -59,8 +59,14 @@ public class TippligaGoogleEventManager {
public static Event findEvent(List<Event> allEvents, Integer season, Integer league, Integer matchday, Integer deliveryDateNumber) {
String description = getDescription(season, league, matchday, deliveryDateNumber);
String descriptionHtml = getDescriptionHTML(season, league, matchday, deliveryDateNumber);
for (Event event : allEvents) {
if (event.getDescription().replaceAll("\\s+","").equals(description.replaceAll("\\s+",""))) return event;
if (
(event.getDescription().replaceAll("\\s+","").equals(description.replaceAll("\\s+","")))
|| event.getDescription().equals(descriptionHtml)
) {
return event;
}
}
return null;
}
@@ -151,11 +157,7 @@ public class TippligaGoogleEventManager {
// Set reminder to 12 hours before
Event.Reminders reminders = new Event.Reminders();
reminders.setUseDefault(false);
EventReminder[] reminderOverrides = new EventReminder[] {
new EventReminder().setMethod("popup").setMinutes(12 * 60),
};
reminders.setOverrides(Arrays.asList(reminderOverrides));
reminders.setUseDefault(true);
return new Event()
.setSummary(summary)
@@ -171,6 +173,12 @@ public class TippligaGoogleEventManager {
return "Saison: " + season + "\n" + "Liga: " + league + "\n" + "Spieltag: " + matchday + "\n" + "Abgabeschluss: " + deliverDateNumber;
}
private static String getDescriptionHTML(Integer season, Integer league, Integer matchday, Integer deliverDateNumber) {
league = league == 2 ? 1 : league;
return "<html-blob>Saison: " + season + "<br>" + "Liga: " + league + "<br>" + "Spieltag: " + matchday + "<br>" + "Abgabeschluss: " + deliverDateNumber + "</html-blob>";
}
public static void updateAllMatchdays(ArrayList<TLWMatchday> matchdays) {
matchdays.forEach(tlwMatchday -> {
createOrUpdateEvent(tlwMatchday, tlwMatchday.getDeliveryDate(), 1);