diff --git a/src/users/users.service.ts b/src/users/users.service.ts index c558775ac..9e8cb79fc 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -1,5 +1,6 @@ import { Injectable, Logger } from '@nestjs/common'; import { UserInfoDto } from './user-info.dto'; +import { User } from './user.entity'; @Injectable() export class UsersService { @@ -15,4 +16,26 @@ export class UsersService { photo: '', }; } + + getPhotoUrl(user: User) { + if (user.photo) { + return user.photo; + } else { + // TODO: Create new photo, see old code + return ''; + } + } + + toUserDto(user: User): UserInfoDto { + if (user === undefined) { + this.logger.warn('toUserDto recieved undefined argument!'); + return null; + } + return { + userName: user.userName, + displayName: user.displayName, + photo: this.getPhotoUrl(user), + email: user.email, + }; + } }