25 lines
510 B
JavaScript
Raw Normal View History

'use strict';
/**
* Email.js controller
*
* @description: A set of functions called "actions" of the `email` plugin.
*/
module.exports = {
send: async ctx => {
2018-09-18 13:20:55 +02:00
let options = ctx.request.body;
try {
await strapi.plugins.email.services.email.send(options);
} catch (e) {
if (e.statusCode === 400) {
return ctx.badRequest(e.message);
} else {
throw new Error(`Couldn't send email: ${e.message}.`);
}
}
// Send 200 `ok`
ctx.send({});
},
};