.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.
27 lines
1.1 KiB
C#
27 lines
1.1 KiB
C#
using Mediator;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Ping.Application.Contracts;
|
|
using Ping.Application.Friends.Responses;
|
|
using Ping.Domain.ValueObjects;
|
|
|
|
namespace Ping.Application.Friends
|
|
{
|
|
public record GetPendingFriendRequestsQuery(long UserId) : IQuery<IReadOnlyList<FriendshipResponse>>;
|
|
|
|
public class GetPendingFriendRequestsQueryHandler(IDatabase database)
|
|
: IQueryHandler<GetPendingFriendRequestsQuery, IReadOnlyList<FriendshipResponse>>
|
|
{
|
|
public async ValueTask<IReadOnlyList<FriendshipResponse>> Handle(GetPendingFriendRequestsQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var friendships = await database.Friendships.AsNoTracking()
|
|
.Include(f => f.Requester)
|
|
.Include(f => f.Addressee)
|
|
.Where(f => f.Status == FriendshipStatus.Pending &&
|
|
(f.RequesterId == request.UserId || f.AddresseeId == request.UserId))
|
|
.ToListAsync(cancellationToken);
|
|
|
|
return friendships.Select(f => FriendshipResponse.FromEntity(f, request.UserId)).ToList();
|
|
}
|
|
}
|
|
}
|