From f34d447bde2219dc7fae162e0d3ffe90aa968baa Mon Sep 17 00:00:00 2001 From: Tyler Young Date: Sun, 9 Feb 2020 09:25:48 -0500 Subject: [PATCH] Update MoMMILink to use Kestler StatusHost handlers. --- Content.Server/Content.Server.csproj | 1 + Content.Server/MoMMILink.cs | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj index ab6085d2fe..b996bf4d65 100644 --- a/Content.Server/Content.Server.csproj +++ b/Content.Server/Content.Server.csproj @@ -13,6 +13,7 @@ + diff --git a/Content.Server/MoMMILink.cs b/Content.Server/MoMMILink.cs index 868378007e..2b7bcfc8bb 100644 --- a/Content.Server/MoMMILink.cs +++ b/Content.Server/MoMMILink.cs @@ -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("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; }