🐛 Fixed create and update user methods to account for created_at and subscribed fields

refs https://github.com/TryGhost/Ghost/issues/12156

- During the refactor - 117309b4e8 (diff-3daeef67d07a2a0f94c89a86cafcede9R44), `subscribed` and `created_at` fields have been overlooked. All fields accepted by Ghost's `POST /members` and `PUT /members/:id` should be supported
This commit is contained in:
Nazar Gargol 2020-08-24 18:29:03 +12:00
parent 56b9f4d350
commit 30f758e297

View File

@ -33,6 +33,7 @@ module.exports = function ({
'email',
'name',
'note',
'subscribed',
'labels',
'geolocation'
]), options);
@ -42,7 +43,9 @@ module.exports = function ({
return Member.findPage(options);
}
async function create({email, name, note, labels, geolocation}, options) {
async function create(data, options) {
const {email, labels} = data;
debug(`create email:${email}`);
/** Member.add model method expects label object array*/
@ -54,13 +57,17 @@ module.exports = function ({
});
}
return Member.add({
email,
name,
note,
labels,
geolocation
}, options);
return Member.add(Object.assign(
{},
{labels},
_.pick(data, [
'email',
'name',
'note',
'subscribed',
'geolocation',
'created_at'
])), options);
}
function safeStripe(methodName) {