diff --git a/.env.example b/.env.example index de4e8a7..d798b03 100644 --- a/.env.example +++ b/.env.example @@ -3,5 +3,9 @@ UNTIS_USERNAME= UNTIS_PASSWORD= UNTIS_BASEURL= +#MAINTENANCE_TITLE= +#MAINTENANCE_DESCRIPTION= +#MAINTENANCE_LOCATION= + # Optionally set the cors origin to use with untis-ics-sync-ui #CORS_ORIGIN= diff --git a/src/lessons/lessons.service.ts b/src/lessons/lessons.service.ts index 2c4a688..1d2706d 100644 --- a/src/lessons/lessons.service.ts +++ b/src/lessons/lessons.service.ts @@ -84,7 +84,8 @@ export class LessonsService { endInputType: 'local', endOutputType: 'utc', } as EventAttributes), - ), + ) + .concat([this.createMaintenanceEvent()]), ); if (error) { @@ -94,4 +95,28 @@ export class LessonsService { return value; } + + createMaintenanceEvent() { + const { + MAINTENANCE_TITLE: title, + MAINTENANCE_DESCRIPTION: description, + MAINTENANCE_LOCATION: location, + } = process.env; + const today = new Date(); + return title + ? ({ + title: title ?? 'Maintenance', + description, + location, + + start: [today.getFullYear(), today.getMonth() + 1, today.getDate()], + startInputType: 'local', + startOutputType: 'utc', + + end: [today.getFullYear(), today.getMonth() + 1, today.getDate()], + endInputType: 'local', + endOutputType: 'utc', + } as EventAttributes) + : undefined; + } }