- Timestamp:
- Aug 17, 2023, 4:57:23 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState/Player.cs
r459 r463 1 1 using System; 2 using System.Collections.Generic;3 2 using System.Net; 4 3 using JetBrains.Annotations; … … 215 214 } 216 215 217 protected override void HandleRestPost (RequestContext _context, IDictionary<string, object> _jsonInput, byte[] _jsonInputData) {218 if (!JsonCommons.TryGetJsonField (_jsonInput, "command", out string commandString)) {219 SendEmptyResponse (_context, HttpStatusCode.BadRequest, _jsonInputData, "NO_COMMAND");220 return;221 }222 223 WebCommandResult.ResultType responseType = WebCommandResult.ResultType.Full;224 225 if (JsonCommons.TryGetJsonField (_jsonInput, "format", out string formatString)) {226 if (formatString.EqualsCaseInsensitive ("raw")) {227 responseType = WebCommandResult.ResultType.Raw;228 } else if (formatString.EqualsCaseInsensitive ("simple")) {229 responseType = WebCommandResult.ResultType.ResultOnly;230 }231 }232 233 int commandSepIndex = commandString.IndexOf (' ');234 string commandPart = commandSepIndex > 0 ? commandString.Substring (0, commandSepIndex) : commandString;235 string argumentsPart = commandSepIndex > 0236 ? commandString.Substring (commandPart.Length + 1)237 : "";238 239 IConsoleCommand command = SdtdConsole.Instance.GetCommand (commandPart, true);240 241 if (command == null) {242 SendEmptyResponse (_context, HttpStatusCode.NotFound, _jsonInputData, "UNKNOWN_COMMAND");243 return;244 }245 246 int commandPermissionLevel = GameManager.Instance.adminTools.Commands.GetCommandPermissionLevel (command.GetCommands ());247 248 if (_context.PermissionLevel > commandPermissionLevel) {249 SendEmptyResponse (_context, HttpStatusCode.Forbidden, _jsonInputData, "NO_PERMISSION");250 return;251 }252 253 _context.Response.SendChunked = true;254 WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, responseType, _context);255 SdtdConsole.Instance.ExecuteAsync (commandString, wcr);256 }257 258 216 public override int DefaultPermissionLevel () => AdminWebModules.PermissionLevelGuest; 259 217 }
Note:
See TracChangeset
for help on using the changeset viewer.