Calendar invitations for Mail part of the app.

This commit is contained in:
Burak Kaan Köse
2026-01-05 00:21:07 +01:00
parent 0b0f6b8d8e
commit 3d07328f47
24 changed files with 679 additions and 66 deletions
@@ -111,6 +111,7 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
Title = string.IsNullOrEmpty(calendarEvent.Summary) ? parentRecurringEvent.Title : calendarEvent.Summary,
UpdatedAt = DateTimeOffset.UtcNow,
Visibility = string.IsNullOrEmpty(calendarEvent.Visibility) ? parentRecurringEvent.Visibility : GetVisibility(calendarEvent.Visibility),
ShowAs = string.IsNullOrEmpty(calendarEvent.Transparency) ? parentRecurringEvent.ShowAs : GetShowAs(calendarEvent.Transparency),
HtmlLink = string.IsNullOrEmpty(calendarEvent.HtmlLink) ? parentRecurringEvent.HtmlLink : calendarEvent.HtmlLink,
RemoteEventId = calendarEvent.Id,
IsLocked = calendarEvent.Locked.GetValueOrDefault(),
@@ -148,6 +149,7 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
Title = calendarEvent.Summary,
UpdatedAt = DateTimeOffset.UtcNow,
Visibility = GetVisibility(calendarEvent.Visibility),
ShowAs = GetShowAs(calendarEvent.Transparency),
HtmlLink = calendarEvent.HtmlLink,
RemoteEventId = calendarEvent.Id,
IsLocked = calendarEvent.Locked.GetValueOrDefault(),
@@ -429,6 +431,20 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
};
}
private CalendarItemShowAs GetShowAs(string transparency)
{
/// Google Calendar uses "transparent" for free time (event doesn't block time)
/// and "opaque" for busy time (event blocks time on the calendar).
/// If not specified, defaults to opaque (busy).
return transparency switch
{
"transparent" => CalendarItemShowAs.Free,
"opaque" => CalendarItemShowAs.Busy,
_ => CalendarItemShowAs.Busy
};
}
public Task<bool> HasAccountAnyDraftAsync(Guid accountId)
=> MailService.HasAccountAnyDraftAsync(accountId);
@@ -135,6 +135,24 @@ public class OutlookChangeProcessor(IDatabaseService databaseService,
savingItem.Visibility = CalendarItemVisibility.Public;
}
// Set ShowAs status
if (calendarEvent.ShowAs != null)
{
savingItem.ShowAs = calendarEvent.ShowAs.Value switch
{
Microsoft.Graph.Models.FreeBusyStatus.Free => CalendarItemShowAs.Free,
Microsoft.Graph.Models.FreeBusyStatus.Tentative => CalendarItemShowAs.Tentative,
Microsoft.Graph.Models.FreeBusyStatus.Busy => CalendarItemShowAs.Busy,
Microsoft.Graph.Models.FreeBusyStatus.Oof => CalendarItemShowAs.OutOfOffice,
Microsoft.Graph.Models.FreeBusyStatus.WorkingElsewhere => CalendarItemShowAs.WorkingElsewhere,
_ => CalendarItemShowAs.Busy
};
}
else
{
savingItem.ShowAs = CalendarItemShowAs.Busy;
}
// Set IsLocked based on whether the user is the organizer
// Read-only events are those where the current user is not the organizer
savingItem.IsLocked = calendarEvent.IsOrganizer.HasValue && !calendarEvent.IsOrganizer.Value;