Synchronizing calendars for gmail and some events.

This commit is contained in:
Burak Kaan Köse
2024-12-27 00:18:46 +01:00
parent 1668dfcce6
commit fbc3ca4517
44 changed files with 1030 additions and 320 deletions

View File

@@ -7,10 +7,12 @@ namespace Wino.Core.Domain.Entities.Calendar
{
[PrimaryKey]
public Guid Id { get; set; }
public string RemoteCalendarId { get; set; }
public string SynchronizationDeltaToken { get; set; }
public Guid AccountId { get; set; }
public string Name { get; set; }
public string ColorHex { get; set; }
public string TimeZoneId { get; set; }
public string TimeZone { get; set; }
public bool IsPrimary { get; set; }
}
}

View File

@@ -1,16 +0,0 @@
using System;
using SQLite;
using Wino.Core.Domain.Enums;
namespace Wino.Core.Domain.Entities.Calendar
{
public class Attendee
{
[PrimaryKey]
public Guid Id { get; set; }
public Guid EventId { get; set; }
public Guid ContactId { get; set; }
public AttendeeStatus Status { get; set; }
public bool IsOrganizer { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using System;
using SQLite;
using Wino.Core.Domain.Enums;
namespace Wino.Core.Domain.Entities.Calendar
{
// TODO: Connect to Contact store with Wino People.
public class CalendarEventAttendee
{
[PrimaryKey]
public Guid Id { get; set; }
public Guid CalendarItemId { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public AttendeeStatus AttendenceStatus { get; set; }
public bool IsOrganizer { get; set; }
public bool IsOptionalAttendee { get; set; }
public string Comment { get; set; }
}
}

View File

@@ -14,9 +14,8 @@ namespace Wino.Core.Domain.Entities.Calendar
public string Description { get; set; }
public string Location { get; set; }
public DateTimeOffset StartTime { get; set; }
public DateTimeOffset EndTime { get; set; }
public bool IsAllDay { get; set; }
public Guid? RecurrenceRuleId { get; set; }
public int DurationInMinutes { get; set; }
public string Recurrence { get; set; }
public CalendarItemStatus Status { get; set; }
public CalendarItemVisibility Visibility { get; set; }
public DateTimeOffset CreatedAt { get; set; }
@@ -24,6 +23,6 @@ namespace Wino.Core.Domain.Entities.Calendar
public Guid CalendarId { get; set; }
[Ignore]
public TimeRange Period => new TimeRange(StartTime.Date, EndTime.Date);
public TimeRange Period => new TimeRange(StartTime.Date, StartTime.Date.AddMinutes(DurationInMinutes));
}
}

View File

@@ -1,20 +0,0 @@
using System;
using SQLite;
using Wino.Core.Domain.Enums;
namespace Wino.Core.Domain.Entities.Calendar
{
public class RecurrenceRule
{
[PrimaryKey]
public Guid Id { get; set; }
public Guid CalendarItemId { get; set; }
public CalendarItemRecurrenceFrequency Frequency { get; set; }
public int Interval { get; set; }
public string DaysOfWeek { get; set; }
public DateTimeOffset StartDate { get; set; }
public DateTimeOffset EndDate { get; set; }
public int Occurrences { get; set; }
}
}

View File

@@ -34,7 +34,7 @@ namespace Wino.Core.Domain.Entities.Shared
public MailProviderType ProviderType { get; set; }
/// <summary>
/// For tracking change delta.
/// For tracking mail change delta.
/// Gmail : historyId
/// Outlook: deltaToken
/// </summary>

View File

@@ -2,6 +2,7 @@
{
public enum AttendeeStatus
{
NeedsAction,
Accepted,
Tentative,
Declined

View File

@@ -2,7 +2,9 @@
{
public enum CalendarItemVisibility
{
Default,
Public,
Private
Private,
Confidential
}
}

View File

@@ -2,8 +2,10 @@
{
public enum CalendarSynchronizationType
{
AllCalendars, // Sync all calendars.
SingleCalendar, // Sync only one calendar.
ExecuteRequests, // Execute all requests in the queue.
CalendarMetadata, // Sync calendar metadata.
CalendarEvents, // Sync all events for all calendars.
SingleCalendar, // Sync events for only specified calendars.
UpdateProfile // Update profile information only.
}
}

View File

@@ -8,7 +8,7 @@ namespace Wino.Core.Domain.Interfaces
string Title { get; }
Guid Id { get; }
DateTimeOffset StartTime { get; }
DateTimeOffset EndTime { get; }
int DurationInMinutes { get; }
TimeRange Period { get; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Wino.Core.Domain.Entities.Calendar;
namespace Wino.Core.Domain.Interfaces
{
public interface ICalendarService
{
Task<List<AccountCalendar>> GetAccountCalendarsAsync(Guid accountId);
Task DeleteCalendarItemAsync(Guid calendarItemId);
Task DeleteAccountCalendarAsync(AccountCalendar accountCalendar);
Task InsertAccountCalendarAsync(AccountCalendar accountCalendar);
Task UpdateAccountCalendarAsync(AccountCalendar accountCalendar);
Task CreateNewCalendarItemAsync(CalendarItem calendarItem, List<CalendarEventAttendee> attendees);
}
}

View File

@@ -10,5 +10,6 @@ namespace Wino.Core.Domain.Interfaces
Task<List<AccountContact>> GetAddressInformationAsync(string queryText);
Task<AccountContact> GetAddressInformationByAddressAsync(string address);
Task SaveAddressInformationAsync(MimeMessage message);
Task<AccountContact> CreateNewContactAsync(string address, string displayName);
}
}

View File

@@ -19,6 +19,8 @@ namespace Wino.Core.Domain.Interfaces
/// <returns>Result summary of synchronization.</returns>
Task<MailSynchronizationResult> SynchronizeMailsAsync(MailSynchronizationOptions options, CancellationToken cancellationToken = default);
Task<CalendarSynchronizationResult> SynchronizeCalendarEventsAsync(CalendarSynchronizationOptions options, CancellationToken cancellationToken = default);
/// <summary>
/// Downloads a single MIME message from the server and saves it to disk.
/// </summary>

View File

@@ -1,24 +0,0 @@
using System;
using Itenso.TimePeriod;
using Wino.Core.Domain.Interfaces;
namespace Wino.Core.Domain.Models.Calendar
{
public class CalendarItem : ICalendarItem
{
public string Title { get; set; }
public CalendarItem(DateTime startTime, DateTime endTime)
{
StartTime = startTime;
EndTime = endTime;
Period = new TimeRange(startTime, endTime);
}
public DateTimeOffset StartTime { get; }
public DateTimeOffset EndTime { get; }
public Guid Id { get; } = Guid.NewGuid();
public TimeRange Period { get; }
}
}