From d88e4a31f35d9197e79ff0d55ecd75085404be9a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 25 Nov 2022 15:02:08 -0600 Subject: add IsRelayAgent to Program, simplify checks --- .../Messaging/API/Controllers/RoomsController.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/slskd/Messaging/API/Controllers/RoomsController.cs') diff --git a/src/slskd/Messaging/API/Controllers/RoomsController.cs b/src/slskd/Messaging/API/Controllers/RoomsController.cs index 1036e10e..0f2ccf25 100644 --- a/src/slskd/Messaging/API/Controllers/RoomsController.cs +++ b/src/slskd/Messaging/API/Controllers/RoomsController.cs @@ -58,7 +58,6 @@ namespace slskd.Messaging.API private IStateMonitor ApplicationStateMonitor { get; } private IRoomTracker Tracker { get; } private IOptionsSnapshot OptionsSnapshot { get; } - private bool IsAgent => OptionsSnapshot.Value.Relay.Mode.ToEnum() == RelayMode.Agent; /// /// Gets all rooms. @@ -70,7 +69,7 @@ namespace slskd.Messaging.API [ProducesResponseType(typeof(Dictionary>), 200)] public IActionResult GetAll() { - if (IsAgent) + if (Program.IsRelayAgent) { return Forbid(); } @@ -91,7 +90,7 @@ namespace slskd.Messaging.API [ProducesResponseType(404)] public IActionResult GetByRoomName([FromRoute]string roomName) { - if (IsAgent) + if (Program.IsRelayAgent) { return Forbid(); } @@ -118,7 +117,7 @@ namespace slskd.Messaging.API [ProducesResponseType(404)] public async Task SendMessage([FromRoute]string roomName, [FromBody]string message) { - if (IsAgent) + if (Program.IsRelayAgent) { return Forbid(); } @@ -146,7 +145,7 @@ namespace slskd.Messaging.API [ProducesResponseType(404)] public async Task SetTicker([FromRoute] string roomName, [FromBody] string message) { - if (IsAgent) + if (Program.IsRelayAgent) { return Forbid(); } @@ -174,7 +173,7 @@ namespace slskd.Messaging.API [ProducesResponseType(404)] public async Task AddRoomMember([FromRoute]string roomName, [FromBody]string username) { - if (IsAgent) + if (Program.IsRelayAgent) { return Forbid(); } @@ -201,7 +200,7 @@ namespace slskd.Messaging.API [ProducesResponseType(404)] public IActionResult GetUsersByRoomName([FromRoute]string roomName) { - if (IsAgent) + if (Program.IsRelayAgent) { return Forbid(); } @@ -230,7 +229,7 @@ namespace slskd.Messaging.API [ProducesResponseType(404)] public IActionResult GetMessagesByRoomName([FromRoute]string roomName) { - if (IsAgent) + if (Program.IsRelayAgent) { return Forbid(); } @@ -255,7 +254,7 @@ namespace slskd.Messaging.API [ProducesResponseType(typeof(List), 200)] public async Task GetRooms() { - if (IsAgent) + if (Program.IsRelayAgent) { return Forbid(); } @@ -289,7 +288,7 @@ namespace slskd.Messaging.API [ProducesResponseType(304)] public async Task JoinRoom([FromBody]string roomName) { - if (IsAgent) + if (Program.IsRelayAgent) { return Forbid(); } @@ -330,7 +329,7 @@ namespace slskd.Messaging.API [ProducesResponseType(404)] public async Task LeaveRoom([FromRoute]string roomName) { - if (IsAgent) + if (Program.IsRelayAgent) { return Forbid(); } -- cgit v1.2.3