forked from GitHubMirrors/silverbullet-icalendar
Add raw ICS logging
All checks were successful
Build SilverBullet Plug / build (push) Successful in 19s
All checks were successful
Build SilverBullet Plug / build (push) Successful in 19s
This commit is contained in:
@@ -78,7 +78,7 @@ async function sha256Hash(str: string): Promise<string> {
|
||||
* Recursively converts all Date objects and ISO date strings to strings
|
||||
* Handles nested objects like {date: Date, local: {date: Date, timezone: string}}
|
||||
*/
|
||||
function convertDatesToStrings<T>(obj: T): DateToString<T> {
|
||||
function convertDatesToStrings<T>(obj: T, timezones?: any): DateToString<T> {
|
||||
if (obj === null || obj === undefined) {
|
||||
return obj as DateToString<T>;
|
||||
}
|
||||
@@ -99,14 +99,14 @@ function convertDatesToStrings<T>(obj: T): DateToString<T> {
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(item => convertDatesToStrings(item)) as DateToString<T>;
|
||||
return obj.map(item => convertDatesToStrings(item, timezones)) as DateToString<T>;
|
||||
}
|
||||
|
||||
if (typeof obj === 'object') {
|
||||
const result: any = {};
|
||||
for (const key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
result[key] = convertDatesToStrings((obj as any)[key]);
|
||||
result[key] = convertDatesToStrings((obj as any)[key], timezones);
|
||||
}
|
||||
}
|
||||
return result as DateToString<T>;
|
||||
@@ -191,6 +191,7 @@ async function fetchAndParseCalendar(source: Source): Promise<CalendarEvent[]> {
|
||||
}
|
||||
|
||||
const icsData = await response.text();
|
||||
console.log(`[iCalendar] Raw ICS Snippet (first 500 chars): ${icsData.slice(0, 500).replace(/\n/g, " ")}`);
|
||||
const calendar: IcsCalendar = convertIcsCalendar(undefined, icsData);
|
||||
|
||||
if (!calendar.events || calendar.events.length === 0) {
|
||||
@@ -208,7 +209,7 @@ async function fetchAndParseCalendar(source: Source): Promise<CalendarEvent[]> {
|
||||
ref,
|
||||
tag: "ical-event" as const,
|
||||
sourceName: source.name,
|
||||
});
|
||||
}, calendar.timezones);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user