* Updates the user's avatar * @param userId User ID * @param file File upload * @returns Updated user object
(userId: string, file: Promise<FileUpload>)
| 49 | // the caller there is no such user. |
| 50 | if (!user) { |
| 51 | const bare = await this.userRepository.findOne({ |
| 52 | where: { id: userId, isDeleted: false }, |
| 53 | }); |
| 54 | if (bare) bare.chats = Promise.resolve([]) as any; |
| 55 | return bare; |
| 56 | } |
| 57 | |
| 58 | return user; |
| 59 | } |
| 60 | |
| 61 | async getUser(id: string): Promise<User> | null { |
| 62 | return await this.userRepository.findOneBy({ |
| 63 | id, |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | async getUserByEmail(email: string): Promise<User | null> { |
| 68 | return await this.userRepository.findOne({ |
| 69 | where: { email }, |
| 70 | }); |
| 71 | } |
no test coverage detected