Event creation.
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
|
||||
namespace Wino.Core.Domain.Extensions;
|
||||
|
||||
public static class CalendarRemoteEventIdExtensions
|
||||
{
|
||||
private const string ClientTrackingSeparator = "::";
|
||||
private const string CalDavClientTrackingPrefix = "caldav-";
|
||||
private const string LocalClientTrackingPrefix = "local-";
|
||||
|
||||
public static string GetProviderRemoteEventId(this string remoteEventId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(remoteEventId))
|
||||
return string.Empty;
|
||||
|
||||
var separatorIndex = remoteEventId.IndexOf(ClientTrackingSeparator, StringComparison.Ordinal);
|
||||
return separatorIndex >= 0 ? remoteEventId[..separatorIndex] : remoteEventId;
|
||||
}
|
||||
|
||||
public static Guid? GetClientTrackingId(this string remoteEventId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(remoteEventId))
|
||||
return null;
|
||||
|
||||
if (remoteEventId.Contains(ClientTrackingSeparator, StringComparison.Ordinal))
|
||||
{
|
||||
var trackedPart = remoteEventId[(remoteEventId.LastIndexOf(ClientTrackingSeparator, StringComparison.Ordinal) + ClientTrackingSeparator.Length)..];
|
||||
if (TryParseGuid(trackedPart, out var trackedId))
|
||||
return trackedId;
|
||||
}
|
||||
|
||||
if (TryParseGuid(remoteEventId, out var directId))
|
||||
return directId;
|
||||
|
||||
if (remoteEventId.StartsWith(CalDavClientTrackingPrefix, StringComparison.OrdinalIgnoreCase) &&
|
||||
TryParseGuid(remoteEventId[CalDavClientTrackingPrefix.Length..], out var calDavId))
|
||||
{
|
||||
return calDavId;
|
||||
}
|
||||
|
||||
if (remoteEventId.StartsWith(LocalClientTrackingPrefix, StringComparison.OrdinalIgnoreCase) &&
|
||||
TryParseGuid(remoteEventId[LocalClientTrackingPrefix.Length..], out var localId))
|
||||
{
|
||||
return localId;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string WithClientTrackingId(this string providerRemoteEventId, Guid? clientTrackingId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(providerRemoteEventId) || !clientTrackingId.HasValue)
|
||||
return providerRemoteEventId ?? string.Empty;
|
||||
|
||||
return $"{providerRemoteEventId}{ClientTrackingSeparator}{clientTrackingId.Value:N}";
|
||||
}
|
||||
|
||||
private static bool TryParseGuid(string value, out Guid parsedGuid)
|
||||
{
|
||||
parsedGuid = Guid.Empty;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return false;
|
||||
|
||||
return Guid.TryParseExact(value, "N", out parsedGuid) || Guid.TryParse(value, out parsedGuid);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Wino.Core.Domain.Entities.Calendar;
|
||||
using System;
|
||||
using Wino.Core.Domain.Entities.Calendar;
|
||||
using Wino.Core.Domain.Entities.Mail;
|
||||
using Wino.Core.Domain.Enums;
|
||||
|
||||
@@ -68,5 +69,6 @@ public interface IFolderActionRequest : IRequestBase
|
||||
public interface ICalendarActionRequest : IRequestBase
|
||||
{
|
||||
CalendarItem Item { get; }
|
||||
Guid? LocalCalendarItemId { get; }
|
||||
CalendarSynchronizerOperation Operation { get; }
|
||||
}
|
||||
|
||||
@@ -15,8 +15,9 @@ namespace Wino.Core.Domain.Models.Calendar;
|
||||
/// <param name="OriginalAttendees">Original attendees list before update (for revert capability).</param>
|
||||
public record CalendarOperationPreparationRequest(
|
||||
CalendarSynchronizerOperation Operation,
|
||||
CalendarItem CalendarItem,
|
||||
List<CalendarEventAttendee> Attendees,
|
||||
CalendarItem CalendarItem = null,
|
||||
List<CalendarEventAttendee> Attendees = null,
|
||||
string ResponseMessage = null,
|
||||
CalendarItem OriginalItem = null,
|
||||
List<CalendarEventAttendee> OriginalAttendees = null);
|
||||
List<CalendarEventAttendee> OriginalAttendees = null,
|
||||
CalendarEventComposeResult ComposeResult = null);
|
||||
|
||||
@@ -32,6 +32,7 @@ public abstract record FolderRequestBase(MailItemFolder Folder, FolderSynchroniz
|
||||
|
||||
public abstract record CalendarRequestBase(CalendarItem Item) : RequestBase<CalendarSynchronizerOperation>, ICalendarActionRequest
|
||||
{
|
||||
public virtual Guid? LocalCalendarItemId => Item?.Id;
|
||||
}
|
||||
|
||||
public class BatchCollection<TRequestType> : List<TRequestType>, IUIChangeRequest where TRequestType : IUIChangeRequest
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
"SyncAction_Archiving": "Archiving {0} mail(s)",
|
||||
"SyncAction_ClearingFlag": "Unflagging {0} mail(s)",
|
||||
"SyncAction_CreatingDraft": "Creating draft",
|
||||
"SyncAction_CreatingEvent": "Creating event",
|
||||
"SyncAction_Deleting": "Deleting {0} mail(s)",
|
||||
"SyncAction_EmptyingFolder": "Emptying folder",
|
||||
"SyncAction_MarkingAsRead": "Marking {0} mail(s) as read",
|
||||
@@ -148,6 +149,7 @@
|
||||
"CalendarEventCompose_PickCalendarTitle": "Pick a calendar",
|
||||
"CalendarEventCompose_Recurring": "Recurring",
|
||||
"CalendarEventCompose_RecurringSummary": "Occurs every {0} {1}{2} {3} effective {4}{5}",
|
||||
"CalendarEventCompose_RecurringSummarySmart": "Occurs {0}{1} {2} starting {3}{4}",
|
||||
"CalendarEventCompose_RepeatEvery": "Repeat every",
|
||||
"CalendarEventCompose_SelectCalendar": "Select calendar",
|
||||
"CalendarEventCompose_SingleOccurrenceSummary": "Occurs on {0} {1}",
|
||||
|
||||
Reference in New Issue
Block a user