Skip to content

Commit

Permalink
add - Expanded status support
Browse files Browse the repository at this point in the history
---

We've added more statuses for different calendar component types.

---

Type: add
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 11, 2024
1 parent ea2d75c commit f63ffaf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions VisualCard.Calendar/Parsers/VCalendarParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ public Parts.Calendar Parse()

// Handle the part type
Type calendarType = subPart is not null ? subPart.GetType() : calendar.GetType();
string[] allowedStatuses =
calendarType == typeof(CalendarEvent) && CalendarVersion.Major == 2 ? ["TENTATIVE", "CONFIRMED", "CANCELLED"] :
calendarType == typeof(CalendarEvent) && CalendarVersion.Major == 1 ? ["NEEDS ACTION", "SENT", "TENTATIVE", "CONFIRMED", "DECLINED", "DELEGATED"] :
calendarType == typeof(CalendarTodo) && CalendarVersion.Major == 2 ? ["NEEDS-ACTION", "COMPLETED", "IN-PROCESS", "CANCELLED"] :
calendarType == typeof(CalendarTodo) && CalendarVersion.Major == 1 ? ["NEEDS ACTION", "SENT", "ACCEPTED", "COMPLETED", "DECLINED", "DELEGATED"] :
calendarType == typeof(CalendarJournal) ? ["DRAFT", "FINAL", "CANCELLED"] :
[];
string values = VcardParserTools.GetValuesString(splitArgs, defaultValue, VCalendarConstants._valueArgumentSpecifier);
switch (type)
{
Expand Down Expand Up @@ -200,12 +207,12 @@ public Parts.Calendar Parse()
// Unescape the value
finalValue = Regex.Unescape(value);
if (finalValue != "AUDIO" && finalValue != "DISPLAY" && finalValue != "EMAIL")
throw new ArgumentException($"Invalid status {finalValue}");
throw new ArgumentException($"Invalid action {finalValue}");
break;
case CalendarStringsEnum.Status:
// Unescape the value
finalValue = Regex.Unescape(value);
if (finalValue != "TENTATIVE" && finalValue != "CONFIRMED" && finalValue != "CANCELLED")
if (!allowedStatuses.Contains(finalValue))
throw new ArgumentException($"Invalid status {finalValue}");
break;
case CalendarStringsEnum.Transparency:
Expand Down

0 comments on commit f63ffaf

Please sign in to comment.