From bb223f9f4d492aa8518062da8dfb345d4d124b00 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Tue, 5 Nov 2019 18:03:19 +0700 Subject: [PATCH] Allowed editing subscribed field for members --- .../utils/validators/input/schemas/members.json | 3 +++ core/server/services/members/api.js | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/server/api/canary/utils/validators/input/schemas/members.json b/core/server/api/canary/utils/validators/input/schemas/members.json index 9a2e0a63a6..a4497f0717 100644 --- a/core/server/api/canary/utils/validators/input/schemas/members.json +++ b/core/server/api/canary/utils/validators/input/schemas/members.json @@ -25,6 +25,9 @@ "minLength": 0, "maxLength": 2000 }, + "subscribed": { + "type": "boolean" + }, "id": { "strip": true }, diff --git a/core/server/services/members/api.js b/core/server/services/members/api.js index f6d6646ddb..dbc2346981 100644 --- a/core/server/services/members/api.js +++ b/core/server/services/members/api.js @@ -75,11 +75,17 @@ async function getMetadata(module, member) { }; } -async function updateMember({name, note}, options = {}) { - const model = await models.Member.edit({ +async function updateMember({name, note, subscribed}, options = {}) { + const attrs = { name: name || null, note: note || null - }, options); + }; + + if (subscribed !== undefined) { + attrs.subscribed = subscribed; + } + + const model = await models.Member.edit(attrs, options); const member = model.toJSON(options); return member;