From 9008e815c17aa3628268c3824656d37d1b993b7b Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Thu, 28 Nov 2019 17:15:37 +0700 Subject: [PATCH] Removed redundant member manipulation proxy methods no issue - These methods have benn moved ton @tryghost/members-api in favor of using the model directly (ref: https://github.com/TryGhost/Members/pull/105) --- core/server/services/members/api.js | 64 +---------------------------- 1 file changed, 1 insertion(+), 63 deletions(-) diff --git a/core/server/services/members/api.js b/core/server/services/members/api.js index 4a1b4cdbb4ec..07c40423cfe0 100644 --- a/core/server/services/members/api.js +++ b/core/server/services/members/api.js @@ -8,28 +8,6 @@ const signupEmail = require('./emails/signup'); const subscribeEmail = require('./emails/subscribe'); const config = require('./config'); -async function createMember({email, name, note}, options = {}) { - const model = await models.Member.add({ - email, - name: name || null, - note: note || null - }); - const member = model.toJSON(options); - return member; -} - -async function getMember(data, options = {}) { - if (!data.email && !data.id && !data.uuid) { - return Promise.resolve(null); - } - const model = await models.Member.findOne(data, options); - if (!model) { - return null; - } - const member = model.toJSON(options); - return member; -} - async function setMetadata(module, metadata) { if (module !== 'stripe') { return; @@ -72,42 +50,6 @@ async function getMetadata(module, member) { }; } -async function updateMember({name, note, subscribed}, options = {}) { - const attrs = { - name: name || null, - note: note || null - }; - - if (subscribed !== undefined) { - attrs.subscribed = subscribed; - } - - const model = await models.Member.edit(attrs, options); - - const member = model.toJSON(options); - return member; -} - -function deleteMember(options) { - options = options || {}; - return models.Member.destroy(options).catch(models.Member.NotFoundError, () => { - throw new common.errors.NotFoundError({ - message: common.i18n.t('errors.api.resource.resourceNotFound', { - resource: 'Member' - }) - }); - }); -} - -function listMembers(options) { - return models.Member.findPage(options).then((models) => { - return { - members: models.data.map(model => model.toJSON(options)), - meta: models.meta - }; - }); -} - const ghostMailer = new mail.GhostMailer(); module.exports = createApiInstance; @@ -225,11 +167,7 @@ function createApiInstance() { }, setMetadata, getMetadata, - createMember, - updateMember, - getMember, - deleteMember, - listMembers, + memberModel: models.Member, logger: common.logging });