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,9 @@
|
||||
namespace Ping.Application.Contracts
|
||||
{
|
||||
public record CallAccessToken(string Jwt, string RoomName);
|
||||
|
||||
public interface ICallTokenService
|
||||
{
|
||||
CallAccessToken CreateAccessToken(string roomName, string identity, string? displayName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ping.Domain.Entities;
|
||||
|
||||
namespace Ping.Application.Contracts
|
||||
{
|
||||
public interface IDatabase
|
||||
{
|
||||
DbSet<User> Users { get; }
|
||||
|
||||
DbSet<Friendship> Friendships { get; }
|
||||
|
||||
DbSet<Server> Servers { get; }
|
||||
|
||||
DbSet<ServerMember> ServerMembers { get; }
|
||||
|
||||
DbSet<Channel> Channels { get; }
|
||||
|
||||
DbSet<ChannelMember> ChannelMembers { get; }
|
||||
|
||||
DbSet<Message> Messages { get; }
|
||||
|
||||
DbSet<Attachment> Attachments { get; }
|
||||
|
||||
Task<IDatabaseTransaction> BeginTransactionAsync(System.Data.IsolationLevel isolationLevel, CancellationToken cancellationToken);
|
||||
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Ping.Application.Contracts
|
||||
{
|
||||
public interface IDatabaseTransaction : IAsyncDisposable
|
||||
{
|
||||
Task CommitAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Ping.Application.Contracts
|
||||
{
|
||||
public enum PresenceStatus
|
||||
{
|
||||
Offline,
|
||||
Online,
|
||||
Busy
|
||||
}
|
||||
|
||||
public interface IPresenceTracker
|
||||
{
|
||||
PresenceStatus GetStatus(long userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Ping.Application.Messages.Responses;
|
||||
|
||||
namespace Ping.Application.Contracts
|
||||
{
|
||||
public interface IRealtimeNotifier
|
||||
{
|
||||
Task MessageCreatedAsync(Guid channelId, MessageResponse message, CancellationToken cancellationToken);
|
||||
|
||||
Task MessageUpdatedAsync(Guid channelId, MessageResponse message, CancellationToken cancellationToken);
|
||||
|
||||
Task MessageDeletedAsync(Guid channelId, Guid messageId, CancellationToken cancellationToken);
|
||||
|
||||
Task FriendRequestReceivedAsync(long addresseeId, Guid friendshipId, CancellationToken cancellationToken);
|
||||
|
||||
Task FriendshipUpdatedAsync(long userId, Guid friendshipId, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Ping.Application.Contracts
|
||||
{
|
||||
public interface IStorageService
|
||||
{
|
||||
Task<Stream> GetFileAsync(string bucket, string key, CancellationToken cancellationToken);
|
||||
|
||||
Task<string> GetUrlAsync(string bucket, string key, TimeSpan expirationTime, CancellationToken cancellationToken);
|
||||
|
||||
Task<string> GetUploadUrlAsync(
|
||||
string bucket,
|
||||
string key,
|
||||
string contentType,
|
||||
TimeSpan expirationTime,
|
||||
CancellationToken cancellationToken,
|
||||
bool preventOverwrite = true);
|
||||
|
||||
Task<ObjectMetaData?> HeadObjectAsync(string bucket, string key, CancellationToken cancellationToken);
|
||||
|
||||
Task RemoveFileAsync(string bucket, string key, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Ping.Application.Contracts
|
||||
{
|
||||
public record ObjectMetaData(string? ContentType, long ContentLength);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Ping.Application.Contracts
|
||||
{
|
||||
public record StorageObject(string Key, DateTime LastModified);
|
||||
}
|
||||
Reference in New Issue
Block a user