Support exporting calendar events
Also update Deno and libraries
This commit is contained in:
@@ -118,7 +118,7 @@ export const handler: Handler<Data, FreshContextState> = async (request, context
|
||||
const calendarEvents = await getCalendarEvents(context.state.user.id, [calendar.id]);
|
||||
|
||||
if (request.method === 'GET') {
|
||||
const response = new Response(formatCalendarEventsToVCalendar(calendarEvents, calendar), {
|
||||
const response = new Response(formatCalendarEventsToVCalendar(calendarEvents, [calendar]), {
|
||||
status: 200,
|
||||
});
|
||||
|
||||
@@ -172,7 +172,7 @@ export const handler: Handler<Data, FreshContextState> = async (request, context
|
||||
|
||||
if (includeVCalendar) {
|
||||
parsedCalendarEvent['d:propstat'][0]['d:prop']['cal:calendar-data'] = escapeXml(
|
||||
formatCalendarEventsToVCalendar([calendarEvent], calendar!),
|
||||
formatCalendarEventsToVCalendar([calendarEvent], [calendar!]),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
formatCalendarEventsToVCalendar,
|
||||
parseVCalendarFromTextContents,
|
||||
} from '/lib/utils.ts';
|
||||
import { getCalendar, getCalendarEvent, getCalendarEvents } from '/lib/data/calendar.ts';
|
||||
import { getCalendar, getCalendarEvent, getCalendarEvents, updateCalendarEvent } from '/lib/data/calendar.ts';
|
||||
import { createSessionCookie } from '/lib/auth.ts';
|
||||
|
||||
interface Data {}
|
||||
@@ -157,7 +157,15 @@ export const handler: Handler<Data, FreshContextState> = async (request, context
|
||||
// }
|
||||
|
||||
if (request.method === 'GET') {
|
||||
const response = new Response(formatCalendarEventsToVCalendar([calendarEvent], calendar), {
|
||||
// Set a UID if there isn't one
|
||||
if (!calendarEvent.extra.uid) {
|
||||
calendarEvent.extra.uid = crypto.randomUUID();
|
||||
await updateCalendarEvent(calendarEvent);
|
||||
|
||||
calendarEvent = await getCalendarEvent(calendarEventId, context.state.user.id);
|
||||
}
|
||||
|
||||
const response = new Response(formatCalendarEventsToVCalendar([calendarEvent], [calendar]), {
|
||||
status: 200,
|
||||
});
|
||||
|
||||
@@ -195,7 +203,7 @@ export const handler: Handler<Data, FreshContextState> = async (request, context
|
||||
|
||||
if (includeVCalendar) {
|
||||
parsedCalendarEvent['d:propstat'][0]['d:prop']['cal:calendar-data'] = escapeXml(
|
||||
formatCalendarEventsToVCalendar([calendarEvent], calendar!),
|
||||
formatCalendarEventsToVCalendar([calendarEvent], [calendar!]),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user