.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.
26 lines
931 B
C#
26 lines
931 B
C#
using Ping.Application.Contracts;
|
|
using Ping.Application.Users.Responses;
|
|
using Ping.Domain.Entities;
|
|
using Ping.Domain.ValueObjects;
|
|
|
|
namespace Ping.Application.Friends.Responses
|
|
{
|
|
public record FriendshipResponse(
|
|
Guid Id, UserResponse OtherUser, FriendshipStatus Status, bool IsIncoming, DateTime CreatedAt, PresenceStatus Presence)
|
|
{
|
|
public static FriendshipResponse FromEntity(Friendship friendship, long currentUserId, PresenceStatus presence = PresenceStatus.Offline)
|
|
{
|
|
var isIncoming = friendship.AddresseeId == currentUserId;
|
|
var other = isIncoming ? friendship.Requester : friendship.Addressee;
|
|
|
|
return new FriendshipResponse(
|
|
friendship.Id,
|
|
UserResponse.FromEntity(other!),
|
|
friendship.Status,
|
|
isIncoming,
|
|
friendship.CreatedAt,
|
|
presence);
|
|
}
|
|
}
|
|
}
|