mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
Update MoMMILink to use Kestler StatusHost handlers.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
</PropertyGroup>
|
||||
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="8.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Interfaces.Chat;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Newtonsoft.Json;
|
||||
using Robust.Server.Interfaces.ServerStatus;
|
||||
using Robust.Server.ServerStatus;
|
||||
@@ -79,9 +80,9 @@ namespace Content.Server
|
||||
}
|
||||
}
|
||||
|
||||
private bool _handleChatPost(HttpMethod method, HttpListenerRequest request, HttpListenerResponse response)
|
||||
private bool _handleChatPost(HttpMethod method, HttpRequest request, HttpResponse response)
|
||||
{
|
||||
if (method != HttpMethod.Post || request.Url.AbsolutePath != "/ooc")
|
||||
if (method != HttpMethod.Post || request.Path != "/ooc")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -89,7 +90,7 @@ namespace Content.Server
|
||||
var password = _configurationManager.GetCVar<string>("status.mommipassword");
|
||||
OOCPostMessage message;
|
||||
|
||||
using (var streamReader = new StreamReader(request.InputStream, EncodingHelpers.UTF8))
|
||||
using (var streamReader = new StreamReader(request.Body, EncodingHelpers.UTF8))
|
||||
using (var jsonReader = new JsonTextReader(streamReader))
|
||||
{
|
||||
var serializer = new JsonSerializer();
|
||||
@@ -99,26 +100,26 @@ namespace Content.Server
|
||||
}
|
||||
catch (JsonSerializationException)
|
||||
{
|
||||
response.Respond(method, "400 Bad Request", HttpStatusCode.BadRequest, "text/plain");
|
||||
response.StatusCode = (int) HttpStatusCode.BadRequest;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (message == null)
|
||||
{
|
||||
response.Respond(method, "400 Bad Request", HttpStatusCode.BadRequest, "text/plain");
|
||||
response.StatusCode = (int) HttpStatusCode.BadRequest;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (message.Password != password)
|
||||
{
|
||||
response.Respond(method, "Incorrect password", HttpStatusCode.Forbidden, "text/plain");
|
||||
response.StatusCode = (int) HttpStatusCode.Forbidden;
|
||||
return true;
|
||||
}
|
||||
|
||||
_taskManager.RunOnMainThread(() => _chatManager.SendHookOOC(message.Sender, message.Contents));
|
||||
|
||||
response.Respond(method, "Message received", HttpStatusCode.OK, "text/plain");
|
||||
response.StatusCode = (int) HttpStatusCode.OK;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user