From 7b9b50da2c8e9ccf6ec6f51bba836db8797206f5 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 26 Oct 2023 12:50:30 +0200 Subject: [PATCH] Revert "Refactoring" This reverts commit eb4806ad642d22cdc681c8a81965ee456250ec25. --- .../eu/faircode/email/CalendarHelper.java | 34 ++----------------- .../java/eu/faircode/email/MessageHelper.java | 33 ++++++++++++++++-- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/CalendarHelper.java b/app/src/main/java/eu/faircode/email/CalendarHelper.java index 6e7557a83e..d9741968f4 100644 --- a/app/src/main/java/eu/faircode/email/CalendarHelper.java +++ b/app/src/main/java/eu/faircode/email/CalendarHelper.java @@ -33,18 +33,16 @@ import androidx.preference.PreferenceManager; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.TimeZone; -import javax.mail.Address; -import javax.mail.internet.InternetAddress; - import biweekly.ICalVersion; import biweekly.ICalendar; import biweekly.component.ICalComponent; +import biweekly.component.Observance; +import biweekly.component.StandardTime; import biweekly.component.VAlarm; import biweekly.component.VEvent; import biweekly.io.TimezoneAssignment; @@ -452,32 +450,4 @@ public class CalendarHelper { } } } - - static int getReplyStatus(Context context, VEvent event, EntityMessage message) { - List
recipients = new ArrayList<>(); - if (message.to != null) - recipients.addAll(Arrays.asList(message.to)); - if (message.cc != null) - recipients.addAll(Arrays.asList(message.cc)); - if (message.bcc != null) - recipients.addAll(Arrays.asList(message.bcc)); - - List attendees = event.getAttendees(); - if (attendees != null) - for (Attendee attendee : attendees) { - String email = attendee.getEmail(); - for (Address address : recipients) { - String recipient = ((InternetAddress) address).getAddress(); - if (!TextUtils.isEmpty(email) && email.equalsIgnoreCase(recipient)) { - ParticipationStatus pstatus = attendee.getParticipationStatus(); - if (ParticipationStatus.ACCEPTED.equals(pstatus)) - return CalendarContract.Events.STATUS_CONFIRMED; - else if (ParticipationStatus.DECLINED.equals(pstatus)) - return CalendarContract.Events.STATUS_CANCELED; - } - } - } - - return CalendarContract.Events.STATUS_TENTATIVE; - } } diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 0d3b94d7ac..3a11ca68c1 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -158,6 +158,8 @@ import javax.mail.internet.ParseException; import biweekly.Biweekly; import biweekly.ICalendar; import biweekly.component.VEvent; +import biweekly.parameter.ParticipationStatus; +import biweekly.property.Attendee; import biweekly.property.Method; import ezvcard.VCard; import ezvcard.VCardVersion; @@ -4452,8 +4454,35 @@ public class MessageHelper { CalendarHelper.delete(context, event, message); else if (method == null || method.isRequest() || method.isReply()) { int status = CalendarContract.Events.STATUS_TENTATIVE; - if (method != null && method.isReply()) - status = CalendarHelper.getReplyStatus(context, event, message); + if (method != null && method.isReply()) { + List
recipients = new ArrayList<>(); + if (message.to != null) + recipients.addAll(Arrays.asList(message.to)); + if (message.cc != null) + recipients.addAll(Arrays.asList(message.cc)); + if (message.bcc != null) + recipients.addAll(Arrays.asList(message.bcc)); + List attendees = event.getAttendees(); + if (attendees != null) + for (Attendee attendee : attendees) { + String email = attendee.getEmail(); + for (Address address : recipients) { + String recipient = ((InternetAddress) address).getAddress(); + if (!TextUtils.isEmpty(email) && email.equalsIgnoreCase(recipient)) { + ParticipationStatus pstatus = attendee.getParticipationStatus(); + if (ParticipationStatus.ACCEPTED.equals(pstatus)) { + status = CalendarContract.Events.STATUS_CONFIRMED; + break; + } else if (ParticipationStatus.DECLINED.equals(pstatus)) { + status = CalendarContract.Events.STATUS_CANCELED; + break; + } + } + } + if (status != CalendarContract.Events.STATUS_TENTATIVE) + break; + } + } if (status == CalendarContract.Events.STATUS_CANCELED) { CalendarHelper.delete(context, event, message);