Split MariaDB message storage out into its own library.

This commit is contained in:
flash 2025-04-27 01:54:46 +00:00
commit f1d4051fb5
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
23 changed files with 255 additions and 228 deletions

View file

@ -26,7 +26,7 @@ public class DeleteChannelClientCommand : ClientCommand {
return;
}
if(!ctx.User.Permissions.HasFlag(UserPermissions.DeleteChannel) && delChan.IsOwner(ctx.User)) {
if(!ctx.User.Permissions.HasFlag(UserPermissions.DeleteChannel) && delChan.IsOwner(ctx.User.UserId)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.CHANNEL_DELETE_FAILED, true, delChan.Name));
return;
}

View file

@ -1,4 +1,4 @@
using SharpChat.EventStorage;
using SharpChat.Messages;
using SharpChat.SockChat.S2CPackets;
namespace SharpChat.ClientCommands;
@ -27,14 +27,14 @@ public class DeleteMessageClientCommand : ClientCommand {
return;
}
StoredEventInfo? delMsg = await ctx.Chat.Events.GetEvent(delSeqId);
Message? delMsg = await ctx.Chat.Messages.GetMessage(delSeqId);
if(delMsg?.SenderId is null || delMsg.SenderRank > ctx.User.Rank || (!deleteAnyMessage && delMsg.SenderId != ctx.User.UserId)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.MESSAGE_DELETE_ERROR));
return;
}
await ctx.Chat.Events.RemoveEvent(delMsg);
await ctx.Chat.Messages.DeleteMessage(delMsg);
await ctx.Chat.Send(new ChatMessageDeleteS2CPacket(delMsg.Id));
}
}

View file

@ -11,7 +11,7 @@ public class PasswordChannelClientCommand : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Permissions.HasFlag(UserPermissions.SetChannelPassword) || ctx.Channel.IsOwner(ctx.User)) {
if(!ctx.User.Permissions.HasFlag(UserPermissions.SetChannelPassword) || ctx.Channel.IsOwner(ctx.User.UserId)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return;
}

View file

@ -12,7 +12,7 @@ public class RankChannelClientCommand : ClientCommand {
public async Task Dispatch(ClientCommandContext ctx) {
long msgId = ctx.Chat.RandomSnowflake.Next();
if(!ctx.User.Permissions.HasFlag(UserPermissions.SetChannelMinimumRank) || ctx.Channel.IsOwner(ctx.User)) {
if(!ctx.User.Permissions.HasFlag(UserPermissions.SetChannelMinimumRank) || ctx.Channel.IsOwner(ctx.User.UserId)) {
await ctx.Chat.SendTo(ctx.User, new CommandResponseS2CPacket(msgId, LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}"));
return;
}