aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/API/Controllers/PublicChatController.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-02-13 07:58:15 -0600
committerJP Dillingham <jpdillingham@gmail.com>2021-02-13 07:58:15 -0600
commit936ed099a6e5258f9fd5a5ac026afc0630359b98 (patch)
treef406e1f1b9fc29391e471c65b708ba6d94b72027 /src/slskd/API/Controllers/PublicChatController.cs
parent87f024fa2561f751fc26c129bfaa373a966f1c67 (diff)
downloadslskd-936ed099a6e5258f9fd5a5ac026afc0630359b98.tar.gz
move controllers and DTOs to API namespace
Diffstat (limited to 'src/slskd/API/Controllers/PublicChatController.cs')
-rw-r--r--src/slskd/API/Controllers/PublicChatController.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/slskd/API/Controllers/PublicChatController.cs b/src/slskd/API/Controllers/PublicChatController.cs
new file mode 100644
index 00000000..63a91ff4
--- /dev/null
+++ b/src/slskd/API/Controllers/PublicChatController.cs
@@ -0,0 +1,50 @@
+namespace slskd.API.Controllers
+{
+ using Microsoft.AspNetCore.Authorization;
+ using Microsoft.AspNetCore.Http;
+ using Microsoft.AspNetCore.Mvc;
+ using Soulseek;
+ using System.Threading.Tasks;
+
+ /// <summary>
+ /// Server
+ /// </summary>
+ [Route("api/v{version:apiVersion}/[controller]")]
+ [ApiVersion("0")]
+ [ApiController]
+ [Produces("application/json")]
+ [Consumes("application/json")]
+ public class PublicChatController : ControllerBase
+ {
+ private ISoulseekClient Client { get; }
+
+ public PublicChatController(ISoulseekClient client)
+ {
+ Client = client;
+ }
+
+ /// <summary>
+ /// Starts public chat.
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost]
+ [Authorize]
+ public async Task<IActionResult> Start()
+ {
+ await Client.StartPublicChatAsync();
+ return StatusCode(StatusCodes.Status201Created);
+ }
+
+ /// <summary>
+ /// Stops public chat.
+ /// </summary>
+ /// <returns></returns>
+ [HttpDelete]
+ [Authorize]
+ public async Task<IActionResult> Stop()
+ {
+ await Client.StopPublicChatAsync();
+ return StatusCode(StatusCodes.Status204NoContent);
+ }
+ }
+}