mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
Added email verification limit check
refs https://github.com/TryGhost/Team/issues/912 - When the import threshold is reached we want to trigger an "email" limit. See details in the refed issue
This commit is contained in:
parent
ec8b49ea42
commit
a7dd7bb64b
@ -4,7 +4,7 @@ const db = require('../data/db');
|
||||
const LimitService = require('@tryghost/limit-service');
|
||||
let limitService = new LimitService();
|
||||
|
||||
const initFn = () => {
|
||||
const initFn = (limits) => {
|
||||
let helpLink;
|
||||
|
||||
if (config.get('hostSettings:billing:enabled') && config.get('hostSettings:billing:enabled') === true && config.get('hostSettings:billing:url')) {
|
||||
@ -23,7 +23,7 @@ const initFn = () => {
|
||||
}
|
||||
|
||||
limitService.loadLimits({
|
||||
limits: config.get('hostSettings:limits'),
|
||||
limits: Object.assign(config.get('hostSettings:limits'), limits),
|
||||
subscription,
|
||||
db,
|
||||
helpLink,
|
||||
|
@ -16,11 +16,14 @@ const ghostVersion = require('@tryghost/version');
|
||||
const _ = require('lodash');
|
||||
const {GhostMailer} = require('../mail');
|
||||
const jobsService = require('../jobs');
|
||||
const limits = require('../limits');
|
||||
|
||||
const messages = {
|
||||
noLiveKeysInDevelopment: 'Cannot use live stripe keys in development. Please restart in production mode.',
|
||||
sslRequiredForStripe: 'Cannot run Ghost without SSL when Stripe is connected. Please update your url config to use "https://".',
|
||||
remoteWebhooksInDevelopment: 'Cannot use remote webhooks in development. See https://ghost.org/docs/webhooks/#stripe-webhooks for developing with Stripe.'
|
||||
remoteWebhooksInDevelopment: 'Cannot use remote webhooks in development. See https://ghost.org/docs/webhooks/#stripe-webhooks for developing with Stripe.',
|
||||
emailVerificationNeeded: `To make sure you get great deliverability on a list of that size, we'll need to enable some extra features for your account. A member of our team will be in touch with you by email to review your account make sure everything is configured correctly so you're ready to go.`,
|
||||
emailSendingDisabled: `Sending is temporarily disabled because your account is currently in review. You should have an email about this from us already, but you can also reach us any time at support@ghost.org`
|
||||
};
|
||||
|
||||
// Bind to settings.edited to update systems based on settings changes, similar to the bridge and models/base/listeners
|
||||
@ -48,6 +51,15 @@ function reconfigureMembersAPI() {
|
||||
logging.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
const getThreshold = () => {
|
||||
if (_.get(config.get('hostSettings'), 'emailVerification.verified')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return _.get(config.get('hostSettings'), 'emailVerification.importThreshold');
|
||||
};
|
||||
|
||||
const membersImporter = new MembersCSVImporter({
|
||||
storagePath: config.getContentPath('data'),
|
||||
getTimezone: () => settingsCache.get('timezone'),
|
||||
@ -57,11 +69,26 @@ const membersImporter = new MembersCSVImporter({
|
||||
addJob: jobsService.addJob.bind(jobsService),
|
||||
knex: db.knex,
|
||||
urlFor: urlUtils.urlFor.bind(urlUtils),
|
||||
importThreshold: config.get('hostSettings.emailVerification.importThreshold')
|
||||
importThreshold: getThreshold()
|
||||
});
|
||||
|
||||
const processImport = async (options) => {
|
||||
return membersImporter.process(options);
|
||||
const result = await membersImporter.process(options);
|
||||
|
||||
if (result.meta.freeze) {
|
||||
limits.init({
|
||||
emails: {
|
||||
disabled: true,
|
||||
error: tpl(messages.emailSendingDisabled)
|
||||
}
|
||||
});
|
||||
|
||||
throw new errors.ValidationError({
|
||||
message: tpl(messages.emailVerificationNeeded)
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const debouncedReconfigureMembersAPI = _.debounce(reconfigureMembersAPI, 600);
|
||||
|
@ -73,7 +73,7 @@
|
||||
"@tryghost/magic-link": "1.0.7",
|
||||
"@tryghost/members-api": "1.23.1",
|
||||
"@tryghost/members-csv": "1.1.2",
|
||||
"@tryghost/members-importer": "0.1.0",
|
||||
"@tryghost/members-importer": "0.1.1",
|
||||
"@tryghost/members-ssr": "1.0.8",
|
||||
"@tryghost/mw-session-from-token": "0.1.22",
|
||||
"@tryghost/package-json": "1.0.2",
|
||||
|
@ -856,10 +856,10 @@
|
||||
papaparse "5.3.1"
|
||||
pump "^3.0.0"
|
||||
|
||||
"@tryghost/members-importer@0.1.0":
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@tryghost/members-importer/-/members-importer-0.1.0.tgz#d36544e2917c41e7f35c66c91deff567c83da9b5"
|
||||
integrity sha512-eiruaYreKd7S7mGtLS2RzAMwq7T48bL4Pa5497bi3soCQCS0P8GCfonojwQmYPDHaF3xPN/oY+80q6HqP43+rw==
|
||||
"@tryghost/members-importer@0.1.1":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@tryghost/members-importer/-/members-importer-0.1.1.tgz#c1b6d26b3afc41fc1ae7f73e1661318d32ae949a"
|
||||
integrity sha512-tzCimEgVT55x3HrOwwQuQDyX7Jx2vH6ec1HlJLVH4GwezRjh3ooztXRet6Qy5lp6oE3iB3Pob3KXaWnuI35Qtw==
|
||||
dependencies:
|
||||
"@tryghost/errors" "^0.2.13"
|
||||
"@tryghost/members-csv" "^1.1.2"
|
||||
|
Loading…
Reference in New Issue
Block a user