Split MariaDB message storage out into its own library.
This commit is contained in:
parent
8eff4127b5
commit
f1d4051fb5
23 changed files with 255 additions and 228 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue