2018-05-31 14:29:00 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Email.js controller
|
|
|
|
*
|
|
|
|
* @description: A set of functions called "actions" of the `email` plugin.
|
|
|
|
*/
|
|
|
|
module.exports = {
|
2019-08-21 12:10:23 +02:00
|
|
|
send: async ctx => {
|
2018-05-31 14:29:00 -05:00
|
|
|
// Verify if the file email is enable.
|
2020-05-14 11:26:19 +02:00
|
|
|
if (strapi.plugins.email.enabled === false) {
|
2018-05-31 14:29:00 -05:00
|
|
|
strapi.log.error('Email is disabled');
|
2019-08-21 12:10:23 +02:00
|
|
|
return ctx.badRequest(null, [
|
|
|
|
{
|
2020-04-06 17:39:48 +02:00
|
|
|
messages: [{ id: 'Email.status.disabled', message: 'Emails disabled' }],
|
2019-08-21 12:10:23 +02:00
|
|
|
},
|
|
|
|
]);
|
2018-05-31 14:29:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Something is wrong
|
|
|
|
if (ctx.status === 400) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-18 13:20:55 +02:00
|
|
|
let options = ctx.request.body;
|
2018-05-31 14:29:00 -05:00
|
|
|
|
2020-05-14 11:26:19 +02:00
|
|
|
await strapi.plugins.email.services.email.send(options);
|
2018-05-31 14:29:00 -05:00
|
|
|
|
|
|
|
// Send 200 `ok`
|
|
|
|
ctx.send({});
|
|
|
|
},
|
|
|
|
};
|