Changeset 463 for TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState
- Timestamp:
- Aug 17, 2023, 4:57:23 PM (15 months ago)
- Location:
- TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState/Animal.openapi.yaml
r460 r463 34 34 - WorldState 35 35 summary: Animals list 36 description: Fetch a list of the currently spawned animals in the world36 description: Fetch a list of the currently spawned (non-hostile) animals in the world 37 37 operationId: animal.get 38 38 responses: -
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.