mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
Added email disabling flag to settings records
refs https://github.com/TryGhost/Team/issues/912 - We need a place to persist the email freeze state between instance restarts - settings table record is the best place for it
This commit is contained in:
parent
9d60936c56
commit
2fbc1af165
@ -63,7 +63,8 @@ const SETTING_KEYS_BLOCKLIST = [
|
||||
'members_stripe_webhook_id',
|
||||
'members_stripe_webhook_secret',
|
||||
'oauth_client_id',
|
||||
'oauth_client_secret'
|
||||
'oauth_client_secret',
|
||||
'email_verification_required'
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
|
@ -0,0 +1,43 @@
|
||||
const ObjectID = require('bson-objectid');
|
||||
const logging = require('@tryghost/logging');
|
||||
const {createTransactionalMigration} = require('../../utils.js');
|
||||
|
||||
const MIGRATION_USER = 1;
|
||||
|
||||
module.exports = createTransactionalMigration(
|
||||
async function up(knex) {
|
||||
const settingExists = await knex('settings')
|
||||
.where('key', '=', 'email_verification_required')
|
||||
.first();
|
||||
|
||||
if (!settingExists) {
|
||||
logging.info('Adding "email_verification_required" record to "settings" table');
|
||||
|
||||
const now = knex.raw('CURRENT_TIMESTAMP');
|
||||
|
||||
await knex('settings')
|
||||
.insert({
|
||||
id: ObjectID().toHexString(),
|
||||
key: 'email_verification_required',
|
||||
value: 'false',
|
||||
group: 'email',
|
||||
type: 'boolean',
|
||||
flags: 'RO',
|
||||
created_at: now,
|
||||
created_by: MIGRATION_USER,
|
||||
updated_at: now,
|
||||
updated_by: MIGRATION_USER
|
||||
});
|
||||
} else {
|
||||
logging.warn('Skipped adding "email_verification_required" record to "settings" table. Record already exists!');
|
||||
}
|
||||
},
|
||||
|
||||
async function down(knex) {
|
||||
logging.info('Removing "email_verification_required" record from "settings" table');
|
||||
|
||||
await knex('settings')
|
||||
.where('key', '=', 'email_verification_required')
|
||||
.del();
|
||||
}
|
||||
);
|
@ -384,6 +384,15 @@
|
||||
"isIn": [["true", "false"]]
|
||||
},
|
||||
"type": "boolean"
|
||||
},
|
||||
"email_verification_required": {
|
||||
"defaultValue": "false",
|
||||
"validations": {
|
||||
"isEmpty": false,
|
||||
"isIn": [["true", "false"]]
|
||||
},
|
||||
"type": "boolean",
|
||||
"flags": "RO"
|
||||
}
|
||||
},
|
||||
"amp": {
|
||||
|
@ -295,6 +295,11 @@ const defaultSettingsKeyTypes = [
|
||||
type: 'boolean',
|
||||
group: 'email'
|
||||
},
|
||||
{
|
||||
key: 'email_verification_required',
|
||||
type: 'boolean',
|
||||
group: 'email'
|
||||
},
|
||||
{
|
||||
key: 'amp',
|
||||
type: 'boolean',
|
||||
|
@ -86,7 +86,8 @@ const defaultSettingsKeyTypes = [
|
||||
{key: 'oauth_client_secret', type: 'oauth'},
|
||||
{key: 'editor_default_email_recipients', type: 'editor'},
|
||||
{key: 'editor_default_email_recipients_filter', type: 'editor'},
|
||||
{key: 'labs', type: 'blog'}
|
||||
{key: 'labs', type: 'blog'},
|
||||
{key: 'email_verification_required', type: 'bulk_email'}
|
||||
];
|
||||
|
||||
describe('Settings API (v2)', function () {
|
||||
|
@ -90,7 +90,8 @@ const defaultSettingsKeyTypes = [
|
||||
{key: 'oauth_client_secret', type: 'oauth'},
|
||||
{key: 'editor_default_email_recipients', type: 'editor'},
|
||||
{key: 'editor_default_email_recipients_filter', type: 'editor'},
|
||||
{key: 'labs', type: 'blog'}
|
||||
{key: 'labs', type: 'blog'},
|
||||
{key: 'email_verification_required', type: 'bulk_email'}
|
||||
];
|
||||
|
||||
describe('Settings API (v3)', function () {
|
||||
|
@ -34,7 +34,7 @@ describe('DB version integrity', function () {
|
||||
// Only these variables should need updating
|
||||
const currentSchemaHash = 'a2248eaa72a9d08c3753b90a9436dbe3';
|
||||
const currentFixturesHash = '97283c575b1f6c84c27db6e1b1be21d4';
|
||||
const currentSettingsHash = 'dd0a0a08e66b252e7704bb7e346a8c20';
|
||||
const currentSettingsHash = 'aa3fcbc8ab119b630aeda7366ead5493';
|
||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||
|
||||
// If this test is failing, then it is likely a change has been made that requires a DB version bump,
|
||||
|
Loading…
Reference in New Issue
Block a user