diff --git a/config/default.json b/config/default.json index 7dd1802a037..bd8d6b19c5d 100644 --- a/config/default.json +++ b/config/default.json @@ -2,13 +2,7 @@ "$schema": "./default.schema.json", "host": "localhost", "port": 3030, - "public": "../public/", - "services": { - "calendar": "http://localhost:3000", - "content": "https://content.schul-cloud.org", - "hydra": "http://localhost:9001", - "web": "http://localhost:3100" - }, + "public": "./public/", "I18N": { "AVAILABLE_LANGUAGES": "de,en,es,uk", "DEFAULT_LANGUAGE": "de", diff --git a/config/production.json b/config/production.json index 77110333930..a2c3c3302c9 100644 --- a/config/production.json +++ b/config/production.json @@ -3,11 +3,5 @@ "host": "localhost", "port": "PORT", "mongodb": "MONGO_URI", - "public": "../public/", - "services": { - "calendar": "CALENDAR_URI", - "content": "CONTENT_URI", - "hydra": "HYDRA_URI", - "web": "HOST" - } + "public": "./public/" } diff --git a/config/test.json b/config/test.json index c8b82b383ba..3ffe08b648b 100644 --- a/config/test.json +++ b/config/test.json @@ -5,11 +5,7 @@ "SC_DOMAIN": "localhost", "PUBLIC_BACKEND_URL": "http://localhost:3030/api", "DB_URL": "mongodb://127.0.0.1:27017/schulcloud-test", - "public": "../public/", - "services": { - "calendar": "https://schul.tech:3000", - "content": "https://content.schul-cloud.org" - }, + "public": "./public/", "FORCE_SEND_EMAIL": true, "LDAP_PASSWORD_ENCRYPTION_KEY": "1234567890123456", "AES_KEY": "6543210987654321", diff --git a/src/services/calendar/courseCalendar.js b/src/services/calendar/courseCalendar.js index be7f2338c48..938be072301 100644 --- a/src/services/calendar/courseCalendar.js +++ b/src/services/calendar/courseCalendar.js @@ -3,17 +3,16 @@ const request = require('request-promise-native'); const { Configuration } = require('@hpi-schul-cloud/commons'); const hooks = require('./hooks'); +const calendarUri = Configuration.get('CALENDAR_URI'); class CourseCalendarService { constructor(app) { this.app = app; } remove(id, params) { - const serviceUrls = this.app.get('services') || {}; - const userId = (params.query || {}).userId || (params.account || {}).userId || params.payload.userId; const options = { - uri: `${serviceUrls.calendar}/scopes/${id}`, + uri: `${calendarUri}/scopes/${id}`, headers: { Authorization: userId, }, diff --git a/src/services/calendar/index.js b/src/services/calendar/index.js index b52640196ed..babbc21974c 100644 --- a/src/services/calendar/index.js +++ b/src/services/calendar/index.js @@ -8,6 +8,8 @@ const courseCalendarSetup = require('./courseCalendar'); const hooks = require('./hooks'); +const calendarUri = Configuration.get('CALENDAR_URI'); + /** * converts a jsonApi-event to a plain event * @param event {object} @@ -34,34 +36,36 @@ const convertJsonApiToEvent = (event) => { * @param body * @returns {object} - valid json-api body for calendar-service */ -const convertEventToJsonApi = (body) => ({ - data: [ - { - type: 'event', - attributes: { - summary: body.summary, - location: body.location, - description: body.description, - dtstart: body.startDate, - dtend: body.endDate || new Date(new Date(body.startDate).getTime() + body.duration).toISOString(), - dtstamp: new Date(), - transp: 'OPAQUE', - sequence: 0, - repeat_freq: body.frequency, - repeat_wkst: body.weekday, - repeat_until: body.repeat_until, - 'x-sc-courseId': body.courseId, - 'x-sc-teamId': body.teamId, - 'x-sc-featureVideoConference': body.featureVideoConference === 'on', - 'x-sc-courseTimeId': body.courseTimeId, - }, - relationships: { - 'scope-ids': [body.scopeId], - 'separate-users': false, +const convertEventToJsonApi = (body) => { + return { + data: [ + { + type: 'event', + attributes: { + summary: body.summary, + location: body.location, + description: body.description, + dtstart: body.startDate, + dtend: body.endDate || new Date(new Date(body.startDate).getTime() + body.duration).toISOString(), + dtstamp: new Date(), + transp: 'OPAQUE', + sequence: 0, + repeat_freq: body.frequency, + repeat_wkst: body.weekday, + repeat_until: body.repeat_until, + 'x-sc-courseId': body.courseId, + 'x-sc-teamId': body.teamId, + 'x-sc-featureVideoConference': body.featureVideoConference === 'on', + 'x-sc-courseTimeId': body.courseTimeId, + }, + relationships: { + 'scope-ids': [body.scopeId], + 'separate-users': false, + }, }, - }, - ], -}); + ], + }; +}; class Service { constructor(options) { @@ -172,11 +176,9 @@ class Service { } create(data, params) { - const serviceUrls = this.app.get('services') || {}; - const userId = (params.query || {}).userId || (params.account || {}).userId || params.payload.userId; const options = { - uri: `${serviceUrls.calendar}/events/`, + uri: `${calendarUri}/events/`, method: 'POST', headers: { Authorization: userId, @@ -201,10 +203,9 @@ class Service { } find(params) { - const serviceUrls = this.app.get('services') || {}; const userId = (params.query || {}).userId || (params.account || {}).userId || params.payload.userId; const options = { - uri: `${serviceUrls.calendar}/events?${queryString.stringify(params.query)}`, + uri: `${calendarUri}/events?${queryString.stringify(params.query)}`, headers: { Authorization: userId, }, @@ -229,11 +230,9 @@ class Service { } remove(id, params) { - const serviceUrls = this.app.get('services') || {}; - const userId = (params.query || {}).userId || (params.account || {}).userId || params.payload.userId; const options = { - uri: `${serviceUrls.calendar}/events/${id}`, + uri: `${calendarUri}/events/${id}`, headers: { Authorization: userId, }, @@ -251,11 +250,9 @@ class Service { } update(id, data, params) { - const serviceUrls = this.app.get('services') || {}; - const userId = (params.query || {}).userId || (params.account || {}).userId || params.payload.userId; const options = { - uri: `${serviceUrls.calendar}/events/${id}`, + uri: `${calendarUri}/events/${id}`, method: 'PUT', headers: { Authorization: userId,