Removed old webhook cleanup code (#207)

no-issue

This is no longer necessary anymore, it would delete all webhooks which
matched the current webhook handler URL, which is undesirable
This commit is contained in:
Fabien 'egg' O'Carroll 2020-10-05 09:21:20 +01:00 committed by GitHub
parent 4a15ee6852
commit 8efc4c7016

View File

@ -1,6 +1,6 @@
const debug = require('ghost-ignition').debug('stripe');
const _ = require('lodash');
const {retrieve, list, create, update, del} = require('./api/stripeRequests');
const {retrieve, create, update, del} = require('./api/stripeRequests');
const api = require('./api');
const STRIPE_API_VERSION = '2019-09-09';
@ -75,24 +75,6 @@ module.exports = class StripePaymentProcessor {
]
};
// @TODO Delete this next time you're here
// This is a fix for the previous release of Ghost (3.25.0)
try {
const webhooks = await list(this._stripe, 'webhookEndpoints', {
limit: 100
});
const webhooksToCleanup = webhooks.data.filter((webhook) => {
return webhook.url === config.webhookHandlerUrl.slice(0, -1) || webhook.url === config.webhookHandlerUrl;
});
for (const webhookToCleanup of webhooksToCleanup) {
await del(this._stripe, 'webhookEndpoints', webhookToCleanup.id);
}
} catch (err) {
this.logging.warn(`There was an error cleaning up the old webhooks`);
}
const setupWebhook = async (id, secret, opts = {}) => {
if (!id || !secret || opts.forceCreate) {
if (id && !opts.skipDelete) {