Add Ping backend
.NET 10 solution for Ping, a Discord style chat app: Domain, Application and Infrastructure projects plus the Api host. SignalR for chat and presence, LiveKit for call tokens, EF Core on Postgres, S3 compatible storage for attachments, and OIDC auth shared with the Musify Zitadel instance. Includes the Compose stack for local development.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ping.Application.Contracts;
|
||||
using Ping.Application.Servers.Responses;
|
||||
|
||||
namespace Ping.Application.Servers
|
||||
{
|
||||
public record GetUserServersQuery(long UserId) : IQuery<IReadOnlyList<ServerResponse>>;
|
||||
|
||||
public class GetUserServersQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetUserServersQuery, IReadOnlyList<ServerResponse>>
|
||||
{
|
||||
public async ValueTask<IReadOnlyList<ServerResponse>> Handle(GetUserServersQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var servers = await database.ServerMembers.AsNoTracking()
|
||||
.Where(m => m.UserId == request.UserId)
|
||||
.Select(m => m.Server!)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return servers.Select(ServerResponse.FromEntity).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user