Calendar - mail mapping.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
|
||||
namespace Wino.Core.Domain.Entities.Mail;
|
||||
|
||||
/// <summary>
|
||||
/// Maps a calendar invitation mail item to a persisted calendar event.
|
||||
/// </summary>
|
||||
public class MailInvitationCalendarMapping
|
||||
{
|
||||
[PrimaryKey]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// MailCopy.Id value of the invitation mail.
|
||||
/// </summary>
|
||||
public string MailCopyId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// iCalendar UID extracted from invitation MIME/ICS content.
|
||||
/// </summary>
|
||||
public string InvitationUid { get; set; }
|
||||
|
||||
public Guid CalendarId { get; set; }
|
||||
public Guid CalendarItemId { get; set; }
|
||||
public string CalendarRemoteEventId { get; set; }
|
||||
|
||||
public DateTime UpdatedAtUtc { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
@@ -48,9 +48,22 @@ public class HtmlPreviewVisitor : MimeVisitor
|
||||
|
||||
protected override void VisitMultipartAlternative(MultipartAlternative alternative)
|
||||
{
|
||||
// walk the multipart/alternative children backwards from greatest level of faithfulness to the least faithful
|
||||
// Prefer rich body alternatives first, and only fall back to calendar text if nothing else exists.
|
||||
for (int i = alternative.Count - 1; i >= 0 && Body == null; i--)
|
||||
{
|
||||
if (IsCalendarText(alternative[i]))
|
||||
continue;
|
||||
|
||||
alternative[i].Accept(this);
|
||||
}
|
||||
|
||||
for (int i = alternative.Count - 1; i >= 0 && Body == null; i--)
|
||||
{
|
||||
if (!IsCalendarText(alternative[i]))
|
||||
continue;
|
||||
|
||||
alternative[i].Accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void VisitMultipartRelated(MultipartRelated related)
|
||||
@@ -241,6 +254,10 @@ public class HtmlPreviewVisitor : MimeVisitor
|
||||
Body = converter.Convert(entity.Text);
|
||||
}
|
||||
|
||||
private static bool IsCalendarText(MimeEntity entity)
|
||||
=> entity is TextPart textPart &&
|
||||
textPart.ContentType?.MimeType?.Equals("text/calendar", StringComparison.OrdinalIgnoreCase) == true;
|
||||
|
||||
protected override void VisitTnefPart(TnefPart entity)
|
||||
{
|
||||
// extract any attachments in the MS-TNEF part
|
||||
|
||||
Reference in New Issue
Block a user