Рабочий чат
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using Knot.Shared.Kernel;
|
||||
using Knot.Contracts.Auth.Application.Abstractions;
|
||||
using Knot.Contracts.Auth.Domain;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Knot.Modules.Auth.Application.Users;
|
||||
|
||||
internal sealed class GetUsersExistenceQueryHandler : IQueryHandler<GetUsersExistenceQuery, List<Guid>>
|
||||
{
|
||||
private readonly IAuthDbContext _context;
|
||||
|
||||
public GetUsersExistenceQueryHandler(IAuthDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<Result<List<Guid>>> Handle(GetUsersExistenceQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var existingIds = await _context.Set<Knot.Modules.Auth.Domain.User>()
|
||||
.Where(u => request.UserIds.Contains(u.Id))
|
||||
.Select(u => u.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return Result.Success(existingIds);
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,14 @@ public sealed class User : AggregateRoot<Guid>
|
||||
public string? RefreshToken { get; private set; }
|
||||
public DateTime? BannedUntil { get; private set; }
|
||||
|
||||
public void Ban() => IsBanned = true;
|
||||
public void Unban() => IsBanned = false;
|
||||
public void Ban() {
|
||||
IsBanned = true;
|
||||
RaiseDomainEvent(new UserBannedDomainEvent(Id, true));
|
||||
}
|
||||
public void Unban() {
|
||||
IsBanned = false;
|
||||
RaiseDomainEvent(new UserBannedDomainEvent(Id, false));
|
||||
}
|
||||
|
||||
public void SetOnline(bool isOnline, DateTime? lastSeen = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user