This commit is contained in:
sam 2024-08-13 13:08:50 +02:00
commit ded4f4db26
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
43 changed files with 2052 additions and 0 deletions

View file

@ -0,0 +1,60 @@
using System.ComponentModel.DataAnnotations.Schema;
using Catalogger.Backend.Extensions;
using Remora.Rest.Core;
namespace Catalogger.Backend.Database.Models;
public class Guild
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public required ulong Id { get; init; }
[Column(TypeName = "jsonb")]
public ChannelConfig Channels { get; init; } = new();
public List<string> BannedSystems { get; init; } = [];
public List<ulong> KeyRoles { get; init; } = [];
public bool IsMessageIgnored(Snowflake channelId, Snowflake userId)
{
if (Channels is { MessageDelete: 0, MessageUpdate: 0, MessageDeleteBulk: 0 } ||
Channels.IgnoredChannels.Contains(channelId.ToUlong()) ||
Channels.IgnoredUsers.Contains(userId.ToUlong())) return true;
if (Channels.IgnoredUsersPerChannel.TryGetValue(channelId.ToUlong(),
out var thisChannelIgnoredUsers))
return thisChannelIgnoredUsers.Contains(userId.ToUlong());
return false;
}
public class ChannelConfig
{
public List<ulong> IgnoredChannels { get; init; } = [];
public List<ulong> IgnoredUsers { get; init; } = [];
public Dictionary<ulong, List<ulong>> IgnoredUsersPerChannel { get; init; } = [];
public Dictionary<ulong, ulong> Redirects { get; init; } = [];
public ulong GuildUpdate { get; init; }
public ulong GuildEmojisUpdate { get; init; }
public ulong GuildRoleCreate { get; init; }
public ulong GuildRoleUpdate { get; init; }
public ulong GuildRoleDelete { get; init; }
public ulong ChannelCreate { get; init; }
public ulong ChannelUpdate { get; init; }
public ulong ChannelDelete { get; init; }
public ulong GuildMemberAdd { get; init; }
public ulong GuildMemberUpdate { get; init; }
public ulong GuildKeyRoleUpdate { get; init; }
public ulong GuildMemberNickUpdate { get; init; }
public ulong GuildMemberAvatarUpdate { get; init; }
public ulong GuildMemberRemove { get; init; }
public ulong GuildMemberKick { get; init; }
public ulong GuildBanAdd { get; init; }
public ulong GuildBanRemove { get; init; }
public ulong InviteCreate { get; init; }
public ulong InviteDelete { get; init; }
public ulong MessageUpdate { get; init; }
public ulong MessageDelete { get; init; }
public ulong MessageDeleteBulk { get; init; }
}
}

View file

@ -0,0 +1,8 @@
namespace Catalogger.Backend.Database.Models;
public class Invite
{
public required ulong GuildId { get; init; }
public required string Code { get; init; }
public required string Name { get; set; }
}

View file

@ -0,0 +1,27 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace Catalogger.Backend.Database.Models;
public class Message
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public required ulong Id { get; init; }
public ulong? OriginalId { get; set; }
public required ulong UserId { get; set; }
public required ulong ChannelId { get; init; }
public required ulong GuildId { get; init; }
public string? Member { get; set; }
public string? System { get; set; }
[Column("username")] public byte[] EncryptedUsername { get; set; } = [];
[Column("content")] public byte[] EncryptedContent { get; set; } = [];
[Column("metadata")] public byte[]? EncryptedMetadata { get; set; }
public int AttachmentSize { get; set; } = 0;
}
public record IgnoredMessage(
[property: DatabaseGenerated(DatabaseGeneratedOption.None)]
ulong Id);

View file

@ -0,0 +1,13 @@
using NodaTime;
namespace Catalogger.Backend.Database.Models;
public class Watchlist
{
public required ulong GuildId { get; init; }
public required ulong UserId { get; init; }
public Instant AddedAt { get; init; }
public required ulong ModeratorId { get; set; }
public required string Reason { get; set; }
}