0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/core/server/services/members/utils.js
Simon Backx ad349bb3a5
Removed GA feature flags (#14915)
refs https://github.com/TryGhost/Team/issues/1616

- Removed all GA feature flags
- Removed `tweetGridCard` alpha flag
- Changes to `members-api` and `members-importer` packages: https://github.com/TryGhost/Members/compare/%40tryghost/members-api%408.1.1...%40tryghost/members-api%408.1.2
2022-05-26 09:54:30 +02:00

25 lines
807 B
JavaScript

function formatNewsletterResponse(newsletters) {
return newsletters.map(({id, name, description, sort_order: sortOrder}) => {
return {id, name, description, sort_order: sortOrder};
});
}
module.exports.formattedMemberResponse = function formattedMemberResponse(member) {
if (!member) {
return null;
}
const data = {
uuid: member.uuid,
email: member.email,
name: member.name,
firstname: member.name && member.name.split(' ')[0],
avatar_image: member.avatar_image,
subscribed: !!member.subscribed,
subscriptions: member.subscriptions || [],
paid: member.status !== 'free'
};
if (member.newsletters) {
data.newsletters = formatNewsletterResponse(member.newsletters);
}
return data;
};