summaryrefslogtreecommitdiff
path: root/src/helpers.js
diff options
context:
space:
mode:
authorRaphael Kabo <raphaelkabo@hey.com>2023-10-06 12:34:36 +0100
committerRaphael Kabo <raphaelkabo@hey.com>2023-10-06 12:34:36 +0100
commitf80e509895b7b2c1d716ac276977b7165a13c192 (patch)
tree58220155d7ccdd8e47fca8ab9df087af5b80cc2b /src/helpers.js
parentbd9fb237fa5bcc076d4c6f3bf8ff748df63515e4 (diff)
Typescript migration
Diffstat (limited to 'src/helpers.js')
-rw-r--r--src/helpers.js54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/helpers.js b/src/helpers.js
deleted file mode 100644
index 305187f..0000000
--- a/src/helpers.js
+++ /dev/null
@@ -1,54 +0,0 @@
-import moment from "moment-timezone";
-import icalGenerator from "ical-generator";
-import Log from "./models/Log.js";
-import { getConfig } from "./lib/config.js";
-const config = getConfig();
-const domain = config.general.domain;
-const siteName = config.general.site_name;
-
-// LOGGING
-
-export function addToLog(process, status, message) {
- let logEntry = new Log({
- status: status,
- process: process,
- message: message,
- timestamp: moment(),
- });
- logEntry.save().catch(() => {
- console.log("Error saving log entry!");
- });
-}
-
-export function exportIcal(events, calendarName) {
- // Create a new icalGenerator... generator
- const cal = icalGenerator({
- name: calendarName || siteName,
- x: {
- "X-WR-CALNAME": calendarName || siteName,
- },
- });
- if (events instanceof Array === false) {
- events = [events];
- }
- events.forEach((event) => {
- // Add the event to the generator
- cal.createEvent({
- start: moment.tz(event.start, event.timezone),
- end: moment.tz(event.end, event.timezone),
- timezone: event.timezone,
- timestamp: moment(),
- summary: event.name,
- description: event.description,
- organizer: {
- name: event.hostName || "Anonymous",
- email: event.creatorEmail || "anonymous@anonymous.com",
- },
- location: event.location,
- url: "https://" + domain + "/" + event.id,
- });
- });
- // Stringify it!
- const string = cal.toString();
- return string;
-}