Keep track of super user status.

This commit is contained in:
flash 2023-11-07 14:49:12 +00:00
parent 294471dcfd
commit a9ca3705ad
5 changed files with 17 additions and 4 deletions

View file

@ -138,6 +138,7 @@ namespace SharpChat
string statusText = null,
int? rank = null,
ChatUserPermissions? perms = null,
bool? isSuper = null,
bool silent = false
) {
if(user == null)
@ -184,6 +185,11 @@ namespace SharpChat
hasChanged = true;
}
if(isSuper.HasValue) {
user.IsSuper = isSuper.Value;
hasChanged = true;
}
if(hasChanged)
SendToUserChannels(user, new UserUpdatePacket(user, previousName));
}

View file

@ -12,6 +12,7 @@ namespace SharpChat {
public ChatColour Colour { get; set; }
public int Rank { get; set; }
public ChatUserPermissions Permissions { get; set; }
public bool IsSuper { get; set; }
public string NickName { get; set; }
public ChatUserStatus Status { get; set; }
public string StatusText { get; set; }
@ -42,7 +43,8 @@ namespace SharpChat {
ChatUserPermissions perms,
string nickName = null,
ChatUserStatus status = ChatUserStatus.Online,
string statusText = null
string statusText = null,
bool isSuper = false
) {
UserId = userId;
UserName = userName ?? throw new ArgumentNullException(nameof(userName));

View file

@ -35,7 +35,7 @@ namespace SharpChat.Commands {
return;
}
if(banUser == ctx.User || banUser.Rank >= ctx.User.Rank) {
if(banUser.Rank >= ctx.User.Rank && banUser != ctx.User) {
ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.KICK_NOT_ALLOWED, true, banUser.LegacyName));
return;
}

View file

@ -25,5 +25,8 @@ namespace SharpChat.Misuzu {
[JsonPropertyName("perms")]
public ChatUserPermissions Permissions { get; set; }
[JsonPropertyName("super")]
public bool IsSuper { get; set; }
}
}

View file

@ -108,7 +108,8 @@ namespace SharpChat.PacketHandlers {
fai.UserName,
fai.Colour,
fai.Rank,
fai.Permissions
fai.Permissions,
isSuper: fai.IsSuper
);
else
ctx.Chat.UpdateUser(
@ -116,7 +117,8 @@ namespace SharpChat.PacketHandlers {
userName: fai.UserName,
colour: fai.Colour,
rank: fai.Rank,
perms: fai.Permissions
perms: fai.Permissions,
isSuper: fai.IsSuper
);
// Enforce a maximum amount of connections per user