mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
Hardened members subscription migration against missing data (#12009)
closes #11993 We had some issues with some databases being in an unexpected state this check for each property before using it add uses defaults when it is missing.
This commit is contained in:
parent
f6f22fce7b
commit
4a5079085a
@ -42,23 +42,25 @@ module.exports = {
|
||||
.where('key', 'members_subscription_settings')
|
||||
.first();
|
||||
|
||||
if (!membersSubscriptionSettingsJSON) {
|
||||
if (!membersSubscriptionSettingsJSON || !membersSubscriptionSettingsJSON.value) {
|
||||
logging.warn(`Could not find members_subscription_settings - using default values`);
|
||||
return;
|
||||
}
|
||||
|
||||
const membersSubscriptionSettings = JSON.parse(membersSubscriptionSettingsJSON.value);
|
||||
|
||||
const membersFromAddress = membersSubscriptionSettings.fromAddress;
|
||||
const membersAllowSelfSignup = membersSubscriptionSettings.allowSelfSignup;
|
||||
const membersFromAddress = typeof membersSubscriptionSettings.fromAddress === 'string' ? membersSubscriptionSettings.fromAddress : 'noreply';
|
||||
const membersAllowSelfSignup = typeof membersSubscriptionSettings.allowSelfSignup === 'boolean' ? membersSubscriptionSettings.allowSelfSignup : true;
|
||||
|
||||
const stripe = membersSubscriptionSettings.paymentProcessors[0];
|
||||
const stripe = membersSubscriptionSettings && membersSubscriptionSettings.paymentProcessors && membersSubscriptionSettings.paymentProcessors[0];
|
||||
|
||||
const stripeDirectSecretKey = stripe.config.secret_token;
|
||||
const stripeDirectPublishableKey = stripe.config.public_token;
|
||||
const stripeProductName = stripe.config.product.name;
|
||||
const stripeConfig = stripe && stripe.config || {};
|
||||
|
||||
const stripePlans = stripe.config.plans.map((plan) => {
|
||||
const stripeDirectSecretKey = stripeConfig.secret_token || '';
|
||||
const stripeDirectPublishableKey = stripeConfig.public_token || '';
|
||||
const stripeProductName = stripeConfig.product && stripeConfig.product.name || 'Ghost Members';
|
||||
|
||||
const stripePlans = (stripeConfig.plans || []).map((plan) => {
|
||||
return Object.assign(plan, {
|
||||
amount: plan.amount || 0
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user