feat(Profile): Reactify profile page (#16743)
* feat(Profile): Reactify profile page * chore(tidyup): Remove console.log * fix(timeline): Remove legacy challenges from Timeline render * fix(style): Remove underline on a:hover
This commit is contained in:
committed by
Quincy Larson
parent
24ef69cf7a
commit
3131c55782
@ -17,6 +17,11 @@ import {
|
||||
getServerFullURL,
|
||||
getEmailSender
|
||||
} from '../../server/utils/url-utils.js';
|
||||
import {
|
||||
normaliseUserFields,
|
||||
getProgress,
|
||||
publicUserProps
|
||||
} from '../../server/utils/publicUserProps';
|
||||
|
||||
const debug = debugFactory('fcc:models:user');
|
||||
const BROWNIEPOINTS_TIMEOUT = [1, 'hour'];
|
||||
@ -760,6 +765,57 @@ module.exports = function(User) {
|
||||
});
|
||||
};
|
||||
|
||||
User.getPublicProfile = function getPublicProfile(username, cb) {
|
||||
return User.findOne$({ where: { username }})
|
||||
.flatMap(user => {
|
||||
if (!user) {
|
||||
return Observable.of({});
|
||||
}
|
||||
const { challengeMap, progressTimestamps, timezone } = user;
|
||||
return Observable.of({
|
||||
entities: {
|
||||
user: {
|
||||
[user.username]: {
|
||||
..._.pick(user, publicUserProps),
|
||||
isGithub: !!user.githubURL,
|
||||
isLinkedIn: !!user.linkedIn,
|
||||
isTwitter: !!user.twitter,
|
||||
isWebsite: !!user.website,
|
||||
points: progressTimestamps.length,
|
||||
challengeMap,
|
||||
...getProgress(progressTimestamps, timezone),
|
||||
...normaliseUserFields(user)
|
||||
}
|
||||
}
|
||||
},
|
||||
result: user.username
|
||||
});
|
||||
})
|
||||
.subscribe(
|
||||
user => cb(null, user),
|
||||
cb
|
||||
);
|
||||
};
|
||||
|
||||
User.remoteMethod('getPublicProfile', {
|
||||
accepts: {
|
||||
arg: 'username',
|
||||
type: 'string',
|
||||
required: true
|
||||
},
|
||||
returns: [
|
||||
{
|
||||
arg: 'user',
|
||||
type: 'object',
|
||||
root: true
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: '/get-public-profile',
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
User.giveBrowniePoints =
|
||||
function giveBrowniePoints(receiver, giver, data = {}, dev = false, cb) {
|
||||
const findUser = observeMethod(User, 'findOne');
|
||||
|
Reference in New Issue
Block a user