33 lines
894 B
JavaScript
33 lines
894 B
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
|
|
function curateUser(user) {
|
|
const curatedUser = {
|
|
id: user.id,
|
|
name: user.name,
|
|
created: new Date(user.created_utc * 1000),
|
|
image: user.icon_img,
|
|
gold: user.is_gold,
|
|
verified: user.verified,
|
|
verifiedEmail: user.has_verified_email,
|
|
};
|
|
|
|
if(user.subreddit) {
|
|
Object.assign(curatedUser, {
|
|
profile: {
|
|
id: user.subreddit.display_name.name,
|
|
title: user.subreddit.display_name.title,
|
|
image: user.subreddit.display_name.icon_img,
|
|
banner: user.subreddit.display_name.banner_img,
|
|
description: user.subreddit.display_name.public_description,
|
|
over18: user.subreddit.display_name.over_18
|
|
}
|
|
});
|
|
}
|
|
|
|
return curatedUser;
|
|
};
|
|
|
|
module.exports = curateUser;
|