mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Removed Members CSV import validation endpoint
no-issue The new import flow does not use prevalidation of the CSV file, so we have no use for this anymore.
This commit is contained in:
parent
83c5270217
commit
73dc19e498
3 changed files with 0 additions and 80 deletions
|
@ -429,42 +429,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
validateImport: {
|
|
||||||
permissions: {
|
|
||||||
method: 'add'
|
|
||||||
},
|
|
||||||
headers: {},
|
|
||||||
async query(frame) {
|
|
||||||
const importedMembers = frame.data.members;
|
|
||||||
|
|
||||||
await Promise.map(importedMembers, (async (entry) => {
|
|
||||||
if (entry.stripe_customer_id) {
|
|
||||||
if (!membersService.config.isStripeConnected()) {
|
|
||||||
throw new errors.ValidationError({
|
|
||||||
message: i18n.t('errors.api.members.stripeNotConnected.message', {
|
|
||||||
id: entry.stripe_customer_id
|
|
||||||
}),
|
|
||||||
context: i18n.t('errors.api.members.stripeNotConnected.context'),
|
|
||||||
help: i18n.t('errors.api.members.stripeNotConnected.help')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await membersService.api.members.getStripeCustomer(entry.stripe_customer_id);
|
|
||||||
} catch (error) {
|
|
||||||
throw new errors.ValidationError({
|
|
||||||
message: `Member not imported. ${error.message}`,
|
|
||||||
context: i18n.t('errors.api.members.stripeCustomerNotFound.context'),
|
|
||||||
help: i18n.t('errors.api.members.stripeCustomerNotFound.help')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
importCSV: {
|
importCSV: {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
permissions: {
|
permissions: {
|
||||||
|
|
|
@ -93,7 +93,6 @@ module.exports = function apiRoutes() {
|
||||||
|
|
||||||
router.get('/members/stats', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.stats));
|
router.get('/members/stats', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.stats));
|
||||||
|
|
||||||
router.post('/members/upload/validate', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.validateImport));
|
|
||||||
router.get('/members/upload', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.exportCSV));
|
router.get('/members/upload', shared.middlewares.labs.members, mw.authAdminApi, http(apiCanary.members.exportCSV));
|
||||||
router.post('/members/upload',
|
router.post('/members/upload',
|
||||||
shared.middlewares.labs.members,
|
shared.middlewares.labs.members,
|
||||||
|
|
|
@ -261,49 +261,6 @@ describe('Members API', function () {
|
||||||
.expect(404);
|
.expect(404);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can validate import data', async function () {
|
|
||||||
const member = {
|
|
||||||
name: 'test',
|
|
||||||
email: 'memberTestAdd@test.com'
|
|
||||||
};
|
|
||||||
|
|
||||||
const res = await request
|
|
||||||
.post(localUtils.API.getApiQuery(`members/upload/validate`))
|
|
||||||
.send({members: [member]})
|
|
||||||
.set('Origin', config.get('url'))
|
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
||||||
.expect(200);
|
|
||||||
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
const jsonResponse = res.body;
|
|
||||||
should.exist(jsonResponse);
|
|
||||||
should.not.exist(jsonResponse.members);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Fails to validate import data when stripe_customer_id is present but Stripe is not connected', async function () {
|
|
||||||
const member = {
|
|
||||||
name: 'test',
|
|
||||||
email: 'memberTestAdd@test.com',
|
|
||||||
stripe_customer_id: 'cus_XXXXX'
|
|
||||||
};
|
|
||||||
|
|
||||||
const res = await request
|
|
||||||
.post(localUtils.API.getApiQuery(`members/upload/validate`))
|
|
||||||
.send({members: [member]})
|
|
||||||
.set('Origin', config.get('url'))
|
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
||||||
.expect(422);
|
|
||||||
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
const jsonResponse = res.body;
|
|
||||||
should.exist(jsonResponse);
|
|
||||||
should.exist(jsonResponse.errors);
|
|
||||||
jsonResponse.errors[0].message.should.match(/Missing Stripe connection/i);
|
|
||||||
jsonResponse.errors[0].context.should.match(/no Stripe account connected/i);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Can export CSV', async function () {
|
it('Can export CSV', async function () {
|
||||||
const res = await request
|
const res = await request
|
||||||
.get(localUtils.API.getApiQuery(`members/upload/`))
|
.get(localUtils.API.getApiQuery(`members/upload/`))
|
||||||
|
|
Loading…
Add table
Reference in a new issue