Merge pull request #232 from emrysal/change-email-sending-moments
commit
6e76cc386c
|
@ -135,7 +135,10 @@ const MicrosoftOffice365Calendar = (credential): CalendarApiAdapter => {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify(translateEvent(event))
|
body: JSON.stringify(translateEvent(event))
|
||||||
}).then(handleErrors))
|
}).then(handleErrors).then( (responseBody) => ({
|
||||||
|
...responseBody,
|
||||||
|
disableConfirmationEmail: true,
|
||||||
|
})))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -228,14 +231,17 @@ const getBusyTimes = (withCredentials, dateFrom, dateTo) => Promise.all(
|
||||||
(results) => results.reduce( (acc, availability) => acc.concat(availability), [])
|
(results) => results.reduce( (acc, availability) => acc.concat(availability), [])
|
||||||
);
|
);
|
||||||
|
|
||||||
const createEvent = (credential, calEvent: CalendarEvent) => {
|
const createEvent = (credential, calEvent: CalendarEvent): Promise<any> => {
|
||||||
if (credential) {
|
|
||||||
return calendars([credential])[0].createEvent(calEvent);
|
|
||||||
}
|
|
||||||
// send email if no Calendar integration is found for now.
|
|
||||||
createNewEventEmail(
|
createNewEventEmail(
|
||||||
calEvent,
|
calEvent,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (credential) {
|
||||||
|
return calendars([credential])[0].createEvent(calEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve({});
|
||||||
};
|
};
|
||||||
|
|
||||||
export { getBusyTimes, createEvent, CalendarEvent };
|
export { getBusyTimes, createEvent, CalendarEvent };
|
||||||
|
|
|
@ -31,12 +31,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: for now, first integration created; primary = obvious todo; ability to change primary.
|
|
||||||
const result = await createEvent(currentUser.credentials[0], evt);
|
const result = await createEvent(currentUser.credentials[0], evt);
|
||||||
|
|
||||||
createConfirmBookedEmail(
|
if (!result.disableConfirmationEmail) {
|
||||||
evt
|
createConfirmBookedEmail(
|
||||||
);
|
evt
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
res.status(200).json(result);
|
res.status(200).json(result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue