diff --git a/manifest.webapp b/manifest.webapp index cfeb858b1a0d0b9d53b5a696d1e23af3e6497d14..319d3ed43d06b492c87fc9e0a31708f91931da1d 100644 --- a/manifest.webapp +++ b/manifest.webapp @@ -21,7 +21,7 @@ "public": false } }, - "service": { + "services": { "monthlySummary": { "type": "node", "file": "monthlySummary.js", diff --git a/src/targets/services/monthlySummary.js b/src/targets/services/monthlySummary.js index a4d8dd6e556019dd18b804dd5e6e740b9d6f2d3f..10000734b1d83f2ccba2eb48c3f9a3f5cb5471cc 100644 --- a/src/targets/services/monthlySummary.js +++ b/src/targets/services/monthlySummary.js @@ -50,6 +50,25 @@ const monthlySummaryStats = async () => { const consumptions = await fetchConsumptionsForPeriod(period) const meanConsumptions = getMeanOnPeriod(consumptions, period) + const FEEDBACK_EMAIL = 'ecolyo@grandlyon.com' + + const mailContent = 'TEST' + + const mailData = { + mode: 'from', + to: [{ name: 'Support', email: FEEDBACK_EMAIL }], + subject: '[Ecolyo] - Votre bilan mensuel', + parts: [{ type: 'text/plain', body: mailContent }], + } + try { + const jobCollection = client.collection('io.cozy.jobs') + await jobCollection.create('sendmail', mailData) + } catch (e) { + // eslint-disable-next-line no-console + console.error(e) + setError(t('feedback.error_sending')) + } + log( 'info', `${consumptions.length} consumptions between ${period.start} and ${period.end}`