Revert "Insert event REPLY"

This reverts commit 4d24edc9ab.
This commit is contained in:
M66B
2023-10-26 12:49:25 +02:00
parent 4d24edc9ab
commit 29580f0eb6
2 changed files with 53 additions and 32 deletions

View File

@@ -398,6 +398,57 @@ public class CalendarHelper {
return null;
}
static void update(Context context, VEvent event, EntityMessage message) {
String uid = (event.getUid() == null ? null : event.getUid().getValue());
if (TextUtils.isEmpty(uid)) {
EntityLog.log(context, EntityLog.Type.General, message,
"Update event: no uid");
return;
}
List<Attendee> attendees = event.getAttendees();
if (attendees == null || attendees.size() == 0) {
EntityLog.log(context, EntityLog.Type.General, message,
"Update event: no attendees");
return;
}
ParticipationStatus status = attendees.get(0).getParticipationStatus();
if (!ParticipationStatus.ACCEPTED.equals(status) &&
!ParticipationStatus.DECLINED.equals(status)) {
EntityLog.log(context, EntityLog.Type.General, message,
"Update event: not accepted/declined");
return;
}
ContentResolver resolver = context.getContentResolver();
try (Cursor cursor = resolver.query(CalendarContract.Events.CONTENT_URI,
new String[]{CalendarContract.Events._ID},
CalendarContract.Events.UID_2445 + " = ?",
new String[]{uid},
null)) {
if (cursor.getCount() == 0)
EntityLog.log(context, EntityLog.Type.General, message,
"Update event: uid not found");
while (cursor.moveToNext()) {
long eventId = cursor.getLong(0);
// https://developer.android.com/guide/topics/providers/calendar-provider#modify-calendar
Uri updateUri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, eventId);
ContentValues values = new ContentValues();
if (ParticipationStatus.ACCEPTED.equals(status))
values.put(CalendarContract.Events.STATUS, CalendarContract.Events.STATUS_CONFIRMED);
else
values.put(CalendarContract.Events.STATUS, CalendarContract.Events.STATUS_CANCELED);
int rows = resolver.update(updateUri, values, null, null);
EntityLog.log(context, EntityLog.Type.General, message,
"Updated event id=" + eventId + " uid=" + uid + " rows=" + rows +
" status=" + status + " accept=" + ParticipationStatus.ACCEPTED.equals(status));
}
}
}
static void delete(Context context, VEvent event, EntityMessage message) {
String uid = (event.getUid() == null ? null : event.getUid().getValue());
if (TextUtils.isEmpty(uid))