diff --git a/src/digest.js b/src/digest.js deleted file mode 100644 index 509eb9c1a..000000000 --- a/src/digest.js +++ /dev/null @@ -1,65 +0,0 @@ -'use strict'; - -var assert = require('assert'), - async = require('async'), - debug = require('debug')('box:digest'), - eventlog = require('./eventlog.js'), - mailer = require('./mailer.js'), - settings = require('./settings.js'), - updatechecker = require('./updatechecker.js'), - users = require('./users.js'); - -exports = module.exports = { - send: send -}; - -function send(callback) { - assert.strictEqual(typeof callback, 'function'); - - settings.getEmailDigest(function (error, enabled) { - if (error) return callback(error); - - if (!enabled) { - debug('send: email digest is disabled'); - return callback(); - } - - var updateInfo = updatechecker.getUpdateInfo(); - var pendingAppUpdates = updateInfo.apps || {}; - pendingAppUpdates = Object.keys(pendingAppUpdates).map(function (key) { return pendingAppUpdates[key]; }); - - eventlog.getByCreationTime(new Date(new Date() - 7*86400000), function (error, events) { - if (error) return callback(error); - - var appUpdates = events.filter(function (e) { return e.action === eventlog.ACTION_APP_UPDATE; }).map(function (e) { return e.data; }); - var boxUpdates = events.filter(function (e) { return e.action === eventlog.ACTION_UPDATE && e.data.boxUpdateInfo; }).map(function (e) { return e.data.boxUpdateInfo; }); - var certRenewals = events.filter(function (e) { return e.action === eventlog.ACTION_CERTIFICATE_RENEWAL; }).map(function (e) { return e.data; }); - var usersAdded = events.filter(function (e) { return e.action === eventlog.ACTION_USER_ADD; }).map(function (e) { return e.data; }); - var usersRemoved = events.filter(function (e) { return e.action === eventlog.ACTION_USER_REMOVE; }).map(function (e) { return e.data; }); - var finishedBackups = events.filter(function (e) { return e.action === eventlog.ACTION_BACKUP_FINISH && !e.errorMessage; }).map(function (e) { return e.data; }); - - if (error) return callback(error); - - var info = { - pendingAppUpdates: pendingAppUpdates, - pendingBoxUpdate: updateInfo.box || null, - - finishedAppUpdates: appUpdates, - finishedBoxUpdates: boxUpdates, - - certRenewals: certRenewals, - finishedBackups: finishedBackups, // only the successful backups - usersAdded: usersAdded, - usersRemoved: usersRemoved // unused because we don't have username to work with - }; - - debug('send: sending digest email', info); - - users.getAllAdmins(function (error, admins) { - if (error) return callback(error); - - async.eachSeries(admins, (admin, done) => mailer.sendDigest(admin.email, info, done), callback); - }); - }); - }); -} diff --git a/src/mail_templates/digest.ejs b/src/mail_templates/digest.ejs deleted file mode 100644 index 29f192121..000000000 --- a/src/mail_templates/digest.ejs +++ /dev/null @@ -1,174 +0,0 @@ -<% if (format === 'text') { -%> - -Dear <%= cloudronName %> Admin, - -This is a summary of the activities on your Cloudron. -<% if (info.usersAdded.length) { -%> - -The following users were added: -<% for (var i = 0; i < info.usersAdded.length; i++) { -%> - * <%- info.usersAdded[i].email %> -<% }} -%> -<% if (info.certRenewals.length) { -%> - -The certificates of the following apps was renewed: -<% for (var i = 0; i < info.certRenewals.length; i++) { -%> - * <%- info.certRenewals[i].domain %> - <%- info.certRenewals[i].errorMessage || 'Success' %> -<% }} -%> -<% if (info.pendingBoxUpdate) { -%> - -Cloudron v<%- info.pendingBoxUpdate.version %> is available: -<% for (var i = 0; i < info.pendingBoxUpdate.changelog.length; i++) { -%> - * <%- info.pendingBoxUpdate.changelog[i] %> -<% }} -%> -<% if (info.pendingAppUpdates.length) { -%> - -One or more app updates are available: -<% for (var i = 0; i < info.pendingAppUpdates.length; i++) { -%> - - <%= info.pendingAppUpdates[i].manifest.title %> package v<%= info.pendingAppUpdates[i].manifest.version %> -<% for (var j = 0; j < info.pendingAppUpdates[i].manifest.changelog.trim().split('\n').length; j++) { -%> - <%= info.pendingAppUpdates[i].manifest.changelog.trim().split('\n')[j] %> -<% }}} -%> -<% if (info.finishedBoxUpdates.length) { -%> - -Cloudron was updated with the following releases: -<% for (var i = 0; i < info.finishedBoxUpdates.length; i++) { -%> - - Version <%= info.finishedBoxUpdates[i].boxUpdateInfo.version %> -<% for (var j = 0; j < info.finishedBoxUpdates[i].boxUpdateInfo.changelog.length; j++) { -%> - * <%= info.finishedBoxUpdates[i].boxUpdateInfo.changelog[j] %> -<% }}} -%> -<% if (info.finishedAppUpdates.length) { -%> - -The following apps were updated: -<% for (var i = 0; i < info.finishedAppUpdates.length; i++) { -%> - - <%= info.finishedAppUpdates[i].toManifest.title %> package v<%= info.finishedAppUpdates[i].toManifest.version %> -<% for (var j = 0; j < info.finishedAppUpdates[i].toManifest.changelog.trim().split('\n').length; j++) { -%> - <%= info.finishedAppUpdates[i].toManifest.changelog.trim().split('\n')[j] %> -<% }}} -%> -<% if (info.finishedBackups.length) { -%> - -Last successful backup: <%- info.finishedBackups[0].backupId || info.finishedBackups[0].filename %> -<% } else { -%> - -This Cloudron did **not** backup successfully in the last week! -<%= webadminUrl %>/#/backups -<% } -%> - -Powered by https://cloudron.io - -Sent at: <%= new Date().toUTCString() %> - -<% } else { %> - -
This is a summary of the activities on your Cloudron <%= cloudronName %> last week.
- - <% if (info.usersAdded.length) { -%> -The following users were added:
-The certificates of the following apps were renewed:
-Cloudron v<%- info.pendingBoxUpdate.version %> is available:
-Available app updates:
-Your Cloudron was updated with the following releases:
-The following apps were updated:
-Last successful backup : <%= info.finishedBackups[0].backupId || info.finishedBackups[0].filename %>
- <% } else { %> -
- The Cloudron did not backup successfully in the last week!
-
-
-
-
-
-