Event details page navigation, handling of attendees in Outlook synchronizer, navigation changes for calendar.
This commit is contained in:
@@ -247,6 +247,38 @@ namespace Wino.Core.Extensions
|
||||
}
|
||||
}
|
||||
|
||||
private static AttendeeStatus GetAttendeeStatus(ResponseType? responseType)
|
||||
{
|
||||
return responseType switch
|
||||
{
|
||||
ResponseType.None => AttendeeStatus.NeedsAction,
|
||||
ResponseType.NotResponded => AttendeeStatus.NeedsAction,
|
||||
ResponseType.Organizer => AttendeeStatus.Accepted,
|
||||
ResponseType.TentativelyAccepted => AttendeeStatus.Tentative,
|
||||
ResponseType.Accepted => AttendeeStatus.Accepted,
|
||||
ResponseType.Declined => AttendeeStatus.Declined,
|
||||
_ => AttendeeStatus.NeedsAction
|
||||
};
|
||||
}
|
||||
|
||||
public static CalendarEventAttendee CreateAttendee(this Attendee attendee, Guid calendarItemId)
|
||||
{
|
||||
bool isOrganizer = attendee?.Status?.Response == ResponseType.Organizer;
|
||||
|
||||
var eventAttendee = new CalendarEventAttendee()
|
||||
{
|
||||
CalendarItemId = calendarItemId,
|
||||
Id = Guid.NewGuid(),
|
||||
Email = attendee.EmailAddress?.Address,
|
||||
Name = attendee.EmailAddress?.Name,
|
||||
AttendenceStatus = GetAttendeeStatus(attendee.Status.Response),
|
||||
IsOrganizer = isOrganizer,
|
||||
IsOptionalAttendee = attendee.Type == AttendeeType.Optional,
|
||||
};
|
||||
|
||||
return eventAttendee;
|
||||
}
|
||||
|
||||
#region Mime to Outlook Message Helpers
|
||||
|
||||
private static IEnumerable<Recipient> GetRecipients(this InternetAddressList internetAddresses)
|
||||
|
||||
@@ -163,59 +163,59 @@ namespace Wino.Core.Integration.Processors
|
||||
// Attendees
|
||||
var attendees = new List<CalendarEventAttendee>();
|
||||
|
||||
//if (calendarEvent.Attendees == null)
|
||||
//{
|
||||
// // Self-only event.
|
||||
if (calendarEvent.Attendees == null)
|
||||
{
|
||||
// Self-only event.
|
||||
|
||||
// attendees.Add(new CalendarEventAttendee()
|
||||
// {
|
||||
// CalendarItemId = calendarItem.Id,
|
||||
// IsOrganizer = true,
|
||||
// Email = organizerAccount.Address,
|
||||
// Name = organizerAccount.SenderName,
|
||||
// AttendenceStatus = AttendeeStatus.Accepted,
|
||||
// Id = Guid.NewGuid(),
|
||||
// IsOptionalAttendee = false,
|
||||
// });
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// foreach (var attendee in calendarEvent.Attendees)
|
||||
// {
|
||||
// if (attendee.Self == true)
|
||||
// {
|
||||
// // TODO:
|
||||
// }
|
||||
// else if (!string.IsNullOrEmpty(attendee.Email))
|
||||
// {
|
||||
// AttendeeStatus GetAttendenceStatus(string responseStatus)
|
||||
// {
|
||||
// return responseStatus switch
|
||||
// {
|
||||
// "accepted" => AttendeeStatus.Accepted,
|
||||
// "declined" => AttendeeStatus.Declined,
|
||||
// "tentative" => AttendeeStatus.Tentative,
|
||||
// "needsAction" => AttendeeStatus.NeedsAction,
|
||||
// _ => AttendeeStatus.NeedsAction
|
||||
// };
|
||||
// }
|
||||
attendees.Add(new CalendarEventAttendee()
|
||||
{
|
||||
CalendarItemId = calendarItem.Id,
|
||||
IsOrganizer = true,
|
||||
Email = organizerAccount.Address,
|
||||
Name = organizerAccount.SenderName,
|
||||
AttendenceStatus = AttendeeStatus.Accepted,
|
||||
Id = Guid.NewGuid(),
|
||||
IsOptionalAttendee = false,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var attendee in calendarEvent.Attendees)
|
||||
{
|
||||
if (attendee.Self == true)
|
||||
{
|
||||
// TODO:
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(attendee.Email))
|
||||
{
|
||||
AttendeeStatus GetAttendenceStatus(string responseStatus)
|
||||
{
|
||||
return responseStatus switch
|
||||
{
|
||||
"accepted" => AttendeeStatus.Accepted,
|
||||
"declined" => AttendeeStatus.Declined,
|
||||
"tentative" => AttendeeStatus.Tentative,
|
||||
"needsAction" => AttendeeStatus.NeedsAction,
|
||||
_ => AttendeeStatus.NeedsAction
|
||||
};
|
||||
}
|
||||
|
||||
// var eventAttendee = new CalendarEventAttendee()
|
||||
// {
|
||||
// CalendarItemId = calendarItem.Id,
|
||||
// IsOrganizer = attendee.Organizer ?? false,
|
||||
// Comment = attendee.Comment,
|
||||
// Email = attendee.Email,
|
||||
// Name = attendee.DisplayName,
|
||||
// AttendenceStatus = GetAttendenceStatus(attendee.ResponseStatus),
|
||||
// Id = Guid.NewGuid(),
|
||||
// IsOptionalAttendee = attendee.Optional ?? false,
|
||||
// };
|
||||
var eventAttendee = new CalendarEventAttendee()
|
||||
{
|
||||
CalendarItemId = calendarItem.Id,
|
||||
IsOrganizer = attendee.Organizer ?? false,
|
||||
Comment = attendee.Comment,
|
||||
Email = attendee.Email,
|
||||
Name = attendee.DisplayName,
|
||||
AttendenceStatus = GetAttendenceStatus(attendee.ResponseStatus),
|
||||
Id = Guid.NewGuid(),
|
||||
IsOptionalAttendee = attendee.Optional ?? false,
|
||||
};
|
||||
|
||||
// attendees.Add(eventAttendee);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
attendees.Add(eventAttendee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await CalendarService.CreateNewCalendarItemAsync(calendarItem, attendees);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Graph.Models;
|
||||
using Serilog;
|
||||
@@ -44,9 +45,6 @@ namespace Wino.Core.Integration.Processors
|
||||
|
||||
public async Task ManageCalendarEventAsync(Event calendarEvent, AccountCalendar assignedCalendar, MailAccount organizerAccount)
|
||||
{
|
||||
// TODO: Make sure to call this method ordered by type:SeriesMaster first.
|
||||
// otherwise we might lose exceptions.s
|
||||
|
||||
// We parse the occurrences based on the parent event.
|
||||
// There is literally no point to store them because
|
||||
// type=Exception events are the exceptional childs of recurrency parent event.
|
||||
@@ -140,6 +138,14 @@ namespace Wino.Core.Integration.Processors
|
||||
|
||||
// Upsert the event.
|
||||
await Connection.InsertOrReplaceAsync(savingItem);
|
||||
|
||||
// Manage attendees.
|
||||
if (calendarEvent.Attendees != null)
|
||||
{
|
||||
// Clear all attendees for this event.
|
||||
var attendees = calendarEvent.Attendees.Select(a => a.CreateAttendee(savingItemId)).ToList();
|
||||
await CalendarService.ManageEventAttendeesAsync(savingItemId, attendees).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -964,7 +964,7 @@ namespace Wino.Core.Synchronizers.Mail
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// await SynchronizeCalendarsAsync(cancellationToken).ConfigureAwait(false);
|
||||
await SynchronizeCalendarsAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var localCalendars = await _outlookChangeProcessor.GetAccountCalendarsAsync(Account.Id).ConfigureAwait(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user