add `UserBanType` schema from API

modify ``ChatMessageHandler.Chat`` to check for bans before sending out message
This commit is contained in:
Alan Moon 2025-02-27 18:00:46 -08:00
parent 86b9d39266
commit 998efe5624
2 changed files with 28 additions and 1 deletions

View File

@ -1,4 +1,6 @@
using sodoffmmo.Attributes;
using System.Net;
using System.Net.Http.Json;
using sodoffmmo.Attributes;
using sodoffmmo.Core;
using sodoffmmo.Data;
using sodoffmmo.Management;
@ -37,6 +39,21 @@ class ChatMessageHandler : CommandHandler {
return;
}
// send an http request to api to check for 'IndefiniteOpenChatBan' or 'TemporaryOpenChatBan'
HttpClient httpClient = new();
var content = new FormUrlEncodedContent(
new Dictionary<string, string> {
{ "token", client.PlayerData.UNToken }
}
);
httpClient.Timeout = new TimeSpan(0, 0, 3);
var response = httpClient.PostAsync($"{Configuration.ServerConfiguration.ApiUrl}/Moderation/CheckForVikingBan", content).Result;
UserBanType? banType = response.Content.ReadFromJsonAsync<UserBanType>().Result;
if (banType != null && (banType == UserBanType.IndefiniteOpenChatBan || banType == UserBanType.TemporaryOpenChatBan))
{ client.Send(Utils.ArrNetworkPacket(new string[] { "CB", "-1", "1" }, "CB")); return; }
client.Room.Send(Utils.BuildChatMessage(client.PlayerData.Uid, message, client.PlayerData.DiplayName), client);
NetworkObject cmd = new();

10
src/Core/UserBanType.cs Normal file
View File

@ -0,0 +1,10 @@
namespace sodoffmmo.Core;
public enum UserBanType
{
NotBanned = 0,
IndefiniteOpenChatBan = 1,
TemporaryOpenChatBan = 2,
IndefiniteAccountBan = 3,
TemporaryAccountBan = 4
}