diff --git a/src/appstore.js b/src/appstore.js index f63a9551e..33d12ec1f 100644 --- a/src/appstore.js +++ b/src/appstore.js @@ -30,7 +30,6 @@ var apps = require('./apps.js'), async = require('async'), BoxError = require('./boxerror.js'), constants = require('./constants.js'), - custom = require('./custom.js'), debug = require('debug')('box:appstore'), domains = require('./domains.js'), eventlog = require('./eventlog.js'), @@ -471,7 +470,7 @@ function createTicket(info, auditSource, callback) { let url = settings.apiServerOrigin() + '/api/v1/ticket'; - info.supportEmail = custom.spec().support.email; // destination address for tickets + info.supportEmail = constants.SUPPORT_EMAIL; // destination address for tickets superagent.post(url).query({ accessToken: token }).send(info).timeout(10 * 1000).end(function (error, result) { if (error && !error.response) return callback(new BoxError(BoxError.NETWORK_ERROR, error.message)); diff --git a/src/constants.js b/src/constants.js index b46be2d40..958612e45 100644 --- a/src/constants.js +++ b/src/constants.js @@ -47,6 +47,8 @@ exports = module.exports = { CLOUDRON: CLOUDRON, TEST: TEST, + SUPPORT_EMAIL: 'support@cloudron.io', + VERSION: process.env.BOX_ENV === 'cloudron' ? fs.readFileSync(path.join(__dirname, '../VERSION'), 'utf8').trim() : '4.2.0-test' }; diff --git a/src/custom.js b/src/custom.js index 8bb39ac96..5babaf0ac 100644 --- a/src/custom.js +++ b/src/custom.js @@ -12,16 +12,6 @@ exports = module.exports = { }; const DEFAULT_SPEC = { - support: { - email: 'support@cloudron.io', - remoteSupport: true, - ticketFormBody: - 'Use this form to open support tickets. You can also write directly to [support@cloudron.io](mailto:support@cloudron.io).\n\n' - + '* [Knowledge Base & App Docs](https://cloudron.io/documentation/apps/?support_view)\n' - + '* [Custom App Packaging & API](https://cloudron.io/developer/packaging/?support_view)\n' - + '* [Forum](https://forum.cloudron.io/)\n\n', - submitTickets: true - }, alerts: { email: '', notifyCloudronAdmins: true diff --git a/src/mailer.js b/src/mailer.js index d61205b71..90b1547c0 100644 --- a/src/mailer.js +++ b/src/mailer.js @@ -26,7 +26,7 @@ exports = module.exports = { var assert = require('assert'), BoxError = require('./boxerror.js'), - custom = require('./custom.js'), + constants = require('./constants.js'), debug = require('debug')('box:mailer'), ejs = require('ejs'), mail = require('./mail.js'), @@ -279,7 +279,7 @@ function appDied(mailTo, app) { from: mailConfig.notificationFrom, to: mailTo, subject: util.format('[%s] App %s is down', mailConfig.cloudronName, app.fqdn), - text: render('app_down.ejs', { title: app.manifest.title, appFqdn: app.fqdn, supportEmail: custom.spec().support.email, format: 'text' }) + text: render('app_down.ejs', { title: app.manifest.title, appFqdn: app.fqdn, supportEmail: constants.SUPPORT_EMAIL, format: 'text' }) }; sendMail(mailOptions); diff --git a/src/routes/support.js b/src/routes/support.js index ecf86ceb1..f4c03f127 100644 --- a/src/routes/support.js +++ b/src/routes/support.js @@ -10,7 +10,7 @@ exports = module.exports = { var appstore = require('../appstore.js'), assert = require('assert'), auditSource = require('../auditsource.js'), - custom = require('../custom.js'), + constants = require('../constants.js'), HttpError = require('connect-lastmile').HttpError, HttpSuccess = require('connect-lastmile').HttpSuccess, support = require('../support.js'), @@ -19,8 +19,6 @@ var appstore = require('../appstore.js'), function createTicket(req, res, next) { assert.strictEqual(typeof req.user, 'object'); - if (!custom.spec().support.submitTickets) return next(new HttpError(405, 'feature disabled by admin')); - const VALID_TYPES = [ 'feedback', 'ticket', 'app_missing', 'app_error', 'upgrade_request', 'email_error' ]; if (typeof req.body.type !== 'string' || !req.body.type) return next(new HttpError(400, 'type must be string')); @@ -31,17 +29,15 @@ function createTicket(req, res, next) { if (req.body.altEmail && typeof req.body.altEmail !== 'string') return next(new HttpError(400, 'altEmail must be string')); appstore.createTicket(_.extend({ }, req.body, { email: req.user.email, displayName: req.user.displayName }), auditSource.fromRequest(req), function (error) { - if (error) return next(new HttpError(503, `Error contacting cloudron.io: ${error.message}. Please email ${custom.spec().support.email}`)); + if (error) return next(new HttpError(503, `Error contacting cloudron.io: ${error.message}. Please email ${constants.SUPPORT_EMAIL}`)); - next(new HttpSuccess(201, { message: `An email for sent to ${custom.spec().support.email}. We will get back shortly!` })); + next(new HttpSuccess(201, { message: `An email for sent to ${constants.SUPPORT_EMAIL}. We will get back shortly!` })); }); } function enableRemoteSupport(req, res, next) { assert.strictEqual(typeof req.body, 'object'); - if (!custom.spec().support.remoteSupport) return next(new HttpError(405, 'feature disabled by admin')); - if (typeof req.body.enable !== 'boolean') return next(new HttpError(400, 'enabled is required')); support.enableRemoteSupport(req.body.enable, auditSource.fromRequest(req), function (error) {