Skip to content

Commit

Permalink
make calendar update route similar to the rest
Browse files Browse the repository at this point in the history
  • Loading branch information
pzmarzly committed Jun 8, 2020
1 parent 1247e1f commit c1d93f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions backend/app/controllers/calendar/updateCalendar.js
Expand Up @@ -4,14 +4,11 @@ const FindOrCreateUserService = require( '../../services/FindOrCreateUserService
const RoomToCalendarService = require( '../../services/RoomToCalendarService' );
const UserPolicy = require( '../../policies/UserPolicy' );

const paramsSchema = yup.object().shape( {
const bodySchema = yup.object().shape( {
calendar: yup
.string()
.required()
.matches( /[a-zA-Z0-9]{10,64}/ ),
} );

const bodySchema = yup.object().shape( {
summary: yup
.string()
.matches( /(ROOM_.*)/ )
Expand All @@ -31,7 +28,6 @@ const bodySchema = yup.object().shape( {

module.exports = async ( req, res ) => {
try {
const params = await paramsSchema.validate( req.params );
const body = await bodySchema.validate( req.body );

const user = await new FindOrCreateUserService().fromRequest( req );
Expand All @@ -44,7 +40,7 @@ module.exports = async ( req, res ) => {
};

const client = new CalendarClient();
const calendar = await client.updateCalendar( params.calendar, calendarData );
const calendar = await client.updateCalendar( body.calendar, calendarData );

res.send( calendar );
}
Expand Down
2 changes: 1 addition & 1 deletion backend/routes/api.js
Expand Up @@ -11,7 +11,7 @@ const deleteCalendar = require( '../app/controllers/calendar/deleteCalendar' );
router.get( '/calendars', listCalendars );
router.post( '/calendars/free', getFreeCalendars );
router.post( '/calendars', addCalendar );
router.post( '/calendars/update/:calendar', updateCalendar );
router.post( '/calendars/update', updateCalendar );
router.post( '/calendars/delete', deleteCalendar );

const fetchCalendar = require( '../app/controllers/event/fetchCalendar' );
Expand Down

0 comments on commit c1d93f0

Please sign in to comment.