Merged v4.33.1 into main

v4.33.1
This commit is contained in:
Daniel Lockyer 2022-01-24 16:03:16 +00:00
commit a2c44efa6a
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD
6 changed files with 83 additions and 65 deletions

@ -1 +1 @@
Subproject commit eb5bd600b753dfe14acda6053a307e0f76757d97
Subproject commit 03a3578fb402c1ab780e2c3347f901eb745f8445

View File

@ -148,7 +148,11 @@ module.exports = {
}
})();
await stripeService.migrations.execute();
try {
await stripeService.migrations.execute();
} catch (err) {
logging.error(err);
}
},
contentGating: require('./content-gating'),

View File

@ -1,53 +1 @@
const _ = require('lodash');
const StripeService = require('@tryghost/members-stripe-service');
const membersService = require('../members');
const config = require('../../../shared/config');
const settings = require('../../../shared/settings-cache');
const urlUtils = require('../../../shared/url-utils');
const events = require('../../lib/common/events');
const models = require('../../models');
const {getConfig} = require('./config');
function configureApi() {
const cfg = getConfig(settings, config, urlUtils);
if (cfg) {
module.exports.configure(cfg);
return true;
}
return false;
}
const debouncedConfigureApi = _.debounce(() => {
configureApi();
}, 600);
module.exports = new StripeService({
membersService,
models: _.pick(models, ['Product', 'StripePrice', 'StripeCustomerSubscription', 'StripeProduct', 'MemberStripeCustomer', 'Offer', 'Settings']),
StripeWebhook: {
async get() {
return {
webhook_id: settings.get('members_stripe_webhook_id'),
secret: settings.get('members_stripe_webhook_secret')
};
},
async save(data) {
await models.Settings.edit([{
key: 'members_stripe_webhook_id',
value: data.webhook_id
}, {
key: 'members_stripe_webhook_secret',
value: data.secret
}]);
}
}
});
module.exports.init = async function init() {
configureApi();
events.on('settings.edited', function (model) {
if (['stripe_publishable_key', 'stripe_secret_key', 'stripe_connect_publishable_key', 'stripe_connect_secret_key'].includes(model.get('key'))) {
debouncedConfigureApi();
}
});
};
module.exports = require('./service');

View File

@ -0,0 +1,58 @@
const _ = require('lodash');
const StripeService = require('@tryghost/members-stripe-service');
const logging = require('@tryghost/logging');
const membersService = require('../members');
const config = require('../../../shared/config');
const settings = require('../../../shared/settings-cache');
const urlUtils = require('../../../shared/url-utils');
const events = require('../../lib/common/events');
const models = require('../../models');
const {getConfig} = require('./config');
async function configureApi() {
const cfg = getConfig(settings, config, urlUtils);
if (cfg) {
await module.exports.configure(cfg);
return true;
}
return false;
}
const debouncedConfigureApi = _.debounce(() => {
configureApi();
}, 600);
module.exports = new StripeService({
membersService,
models: _.pick(models, ['Product', 'StripePrice', 'StripeCustomerSubscription', 'StripeProduct', 'MemberStripeCustomer', 'Offer', 'Settings']),
StripeWebhook: {
async get() {
return {
webhook_id: settings.get('members_stripe_webhook_id'),
secret: settings.get('members_stripe_webhook_secret')
};
},
async save(data) {
await models.Settings.edit([{
key: 'members_stripe_webhook_id',
value: data.webhook_id
}, {
key: 'members_stripe_webhook_secret',
value: data.secret
}]);
}
}
});
module.exports.init = async function init() {
try {
await configureApi();
} catch (err) {
logging.error(err);
}
events.on('settings.edited', function (model) {
if (['stripe_publishable_key', 'stripe_secret_key', 'stripe_connect_publishable_key', 'stripe_connect_secret_key'].includes(model.get('key'))) {
debouncedConfigureApi();
}
});
};

View File

@ -1,6 +1,6 @@
{
"name": "ghost",
"version": "4.33.0",
"version": "4.33.1",
"description": "The professional publishing platform",
"author": "Ghost Foundation",
"homepage": "https://ghost.org",
@ -79,13 +79,11 @@
"@tryghost/kg-mobiledoc-html-renderer": "5.3.2",
"@tryghost/limit-service": "1.0.9",
"@tryghost/logging": "2.0.1",
"@tryghost/magic-link": "1.0.15",
"@tryghost/magic-link": "1.0.17",
"@tryghost/members-api": "4.7.0",
"@tryghost/members-csv": "1.2.3",
"@tryghost/members-importer": "0.4.1",
"@tryghost/members-offers": "0.10.6",
"@tryghost/members-ssr": "1.0.19",
"@tryghost/members-stripe-service": "0.6.3",
"@tryghost/members-stripe-service": "0.6.4",
"@tryghost/metrics": "1.0.2",
"@tryghost/minifier": "0.1.10",
"@tryghost/mw-error-handler": "0.1.2",

View File

@ -1480,10 +1480,10 @@
json-stringify-safe "^5.0.1"
lodash "^4.17.21"
"@tryghost/magic-link@1.0.15":
version "1.0.15"
resolved "https://registry.yarnpkg.com/@tryghost/magic-link/-/magic-link-1.0.15.tgz#61aac2990f65decd6bc18aa4699181cb12388fce"
integrity sha512-df0owOkpR2SAx48NTVJLmfDMY9fnSpZ0c8nRaU/JIiAm++pKLveyl4Djas2l8up6PA1dkS1ND8VktIf7Ug4SVA==
"@tryghost/magic-link@1.0.17":
version "1.0.17"
resolved "https://registry.yarnpkg.com/@tryghost/magic-link/-/magic-link-1.0.17.tgz#149fc93ba63a0ea89b22b90b01a3bcc28a71e636"
integrity sha512-stsUKEyTygacONVW5f9uqjIUVYLiJi9AbTmLb9sgNj4sVKgcFw7wMokoKQe2ezsQdwjQx8cvpTZhyKL5Qo3BaQ==
dependencies:
bluebird "^3.5.5"
jsonwebtoken "^8.5.1"
@ -1600,7 +1600,17 @@
jsonwebtoken "^8.5.1"
lodash "^4.17.11"
"@tryghost/members-stripe-service@0.6.3", "@tryghost/members-stripe-service@^0.6.3":
"@tryghost/members-stripe-service@0.6.4":
version "0.6.4"
resolved "https://registry.yarnpkg.com/@tryghost/members-stripe-service/-/members-stripe-service-0.6.4.tgz#8946e1eb8becaccb0c1dc3a7d26a6931802d2023"
integrity sha512-twxt5r/yqSGFO48cV6RtMyTngd+HvBBr97/Psbjy5TnyYZo6D1AXetocHscOMqbWkpu3CSTBZgJx0VqywKLYKQ==
dependencies:
"@tryghost/debug" "^0.1.4"
"@tryghost/errors" "1.2.0"
leaky-bucket "^2.2.0"
stripe "^8.174.0"
"@tryghost/members-stripe-service@^0.6.3":
version "0.6.3"
resolved "https://registry.yarnpkg.com/@tryghost/members-stripe-service/-/members-stripe-service-0.6.3.tgz#c6c54a8d38036ce76334d3297fcc85d72baca5f9"
integrity sha512-4a8d+x8HmMVE45hhbQ6NNcMFJXUfIM+uhUrGLN1lg6K02hr7CVl2y25cqbG7dN9ZOHuiUEJy/P0hqrdZJz12lA==