chat: add database types and auth middleware

This commit is contained in:
sam 2024-05-21 16:41:01 +02:00
parent 656eec81d8
commit 6f6e19bbb5
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
24 changed files with 1165 additions and 15 deletions

View file

@ -0,0 +1,9 @@
namespace Foxchat.Chat.Database.Models;
public class Channel : BaseModel
{
public Ulid GuildId { get; init; }
public Guild Guild { get; init; } = null!;
public string Name { get; set; } = null!;
public string? Topic { get; set; }
}

View file

@ -0,0 +1,11 @@
namespace Foxchat.Chat.Database.Models;
public class Guild : BaseModel
{
public string Name { get; set; } = null!;
public Ulid OwnerId { get; set; }
public User Owner { get; set; } = null!;
public List<User> Users { get; } = [];
public List<Channel> Channels { get; } = [];
}

View file

@ -0,0 +1,17 @@
namespace Foxchat.Chat.Database.Models;
public class IdentityInstance : BaseModel
{
public string Domain { get; init; } = null!;
public string BaseUrl { get; init; } = null!;
public string PublicKey { get; init; } = null!;
public InstanceStatus Status { get; set; } = InstanceStatus.Active;
public string? Reason { get; set; }
public enum InstanceStatus
{
Active,
Suspended,
}
}

View file

@ -0,0 +1,15 @@
using NodaTime;
namespace Foxchat.Chat.Database.Models;
public class Message : BaseModel
{
public Ulid ChannelId { get; init; }
public Channel Channel { get; init; } = null!;
public Ulid AuthorId { get; init; }
public User Author { get; init; } = null!;
public string? Content { get; set; }
public Instant? UpdatedAt { get; set; }
}

View file

@ -0,0 +1,14 @@
namespace Foxchat.Chat.Database.Models;
public class User : BaseModel
{
public Ulid InstanceId { get; init; }
public IdentityInstance Instance { get; init; } = null!;
public string RemoteUserId { get; init; } = null!;
public string Username { get; init; } = null!;
public string? Avatar { get; set; }
public List<Guild> Guilds { get; } = [];
public List<Guild> OwnedGuilds { get; } = [];
}