Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Do this clientside instead
Browse files Browse the repository at this point in the history
  • Loading branch information
hhvrc committed Jul 5, 2023
1 parent fb1e7f5 commit 81c9c06
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions Common/Services/UserRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,31 +77,19 @@ public Task<UserEntity> CreateSystemUserAsync(SystemUserCreationDto newUser, Can
.Include(u => u.RelationsIncoming)
.Include(u => u.SSOConnections);

private async Task<UserEntity?> SetOnlineStatus(Task<UserEntity?> userTask)
{
var user = await userTask;

if (user is not null)
{
user.Status = Websocket.WebSocketHub.IsUserOnline(user.Id) ? user.Status : UserStatus.Offline;
}

return user;
}

public Task<UserEntity?> GetUserByIdAsync(Guid userId, CancellationToken cancellationToken = default)
{
return SetOnlineStatus(QueryBase.FirstOrDefaultAsync(u => u.Id == userId, cancellationToken));
return QueryBase.FirstOrDefaultAsync(u => u.Id == userId, cancellationToken);
}

public Task<UserEntity?> GetUserByUserNameAsync(string userName, CancellationToken cancellationToken = default)
{
return SetOnlineStatus(QueryBase.FirstOrDefaultAsync(u => u.Name == userName, cancellationToken));
return QueryBase.FirstOrDefaultAsync(u => u.Name == userName, cancellationToken);
}

public Task<UserEntity?> GetUserByEmailAsync(string email, CancellationToken cancellationToken = default)
{
return SetOnlineStatus(QueryBase.FirstOrDefaultAsync(u => u.Email == email, cancellationToken));
return QueryBase.FirstOrDefaultAsync(u => u.Email == email, cancellationToken);
}

public async Task<bool> DeleteUserById(Guid userId, CancellationToken cancellationToken = default)
Expand Down

0 comments on commit 81c9c06

Please sign in to comment.