Skip to content

Commit

Permalink
merge: pull request #23 from bddvlpr/feature/maintenance
Browse files Browse the repository at this point in the history
Maintenance message option
  • Loading branch information
bddvlpr committed Nov 7, 2023
2 parents 5218bb9 + 55ebd05 commit 635d8e5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=
27 changes: 26 additions & 1 deletion src/lessons/lessons.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export class LessonsService {
endInputType: 'local',
endOutputType: 'utc',
} as EventAttributes),
),
)
.concat([this.createMaintenanceEvent()]),
);

if (error) {
Expand All @@ -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;
}
}

0 comments on commit 635d8e5

Please sign in to comment.