da9224a069
feat: server & stream invites rework Co-authored-by: Dimitrie Stefanescu <didimitrie@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
54 lines
960 B
JavaScript
54 lines
960 B
JavaScript
const { pick } = require('lodash')
|
|
|
|
/**
|
|
* @typedef {{
|
|
* id: string,
|
|
* suuid: string,
|
|
* createdAt?: Date,
|
|
* name: string,
|
|
* bio?: string,
|
|
* company?: string,
|
|
* email: string,
|
|
* verified: boolean,
|
|
* avatar: string,
|
|
* profiles?: string,
|
|
* passwordDigest: string,
|
|
* ip?: string,
|
|
* }} UserRecord
|
|
*/
|
|
|
|
/**
|
|
* Fields from the entity that users can see about other users
|
|
*/
|
|
const LIMITED_USER_FIELDS = [
|
|
'id',
|
|
'name',
|
|
'bio',
|
|
'company',
|
|
'verified',
|
|
'avatar',
|
|
'createdAt'
|
|
]
|
|
|
|
/**
|
|
* @typedef {Pick<
|
|
* UserRecord,
|
|
* 'id' | 'name' | 'bio' | 'company' | 'verified' | 'avatar' | 'createdAt'
|
|
* >} LimitedUserRecord
|
|
*/
|
|
|
|
/**
|
|
* Remove fields from user that other users should not see/know about
|
|
* @param {UserRecord} user
|
|
* @returns {LimitedUserRecord}
|
|
*/
|
|
function removePrivateFields(user) {
|
|
if (!user) return user
|
|
return pick(user, LIMITED_USER_FIELDS)
|
|
}
|
|
|
|
module.exports = {
|
|
LIMITED_USER_FIELDS,
|
|
removePrivateFields
|
|
}
|