aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Controllers/PublicChatController.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2020-12-30 21:16:50 -0600
committerJP Dillingham <jpdillingham@gmail.com>2020-12-30 21:16:50 -0600
commit8f1068ac3135bcccf09374bc787ef22049b43461 (patch)
tree5d80a254f5ee7b7c6b3956f6a7307591bc5a93e2 /src/slskd/Controllers/PublicChatController.cs
parentec4a85e4e8b64a0ae91c494e3c8ef520f0a8b8c3 (diff)
downloadslskd-8f1068ac3135bcccf09374bc787ef22049b43461.tar.gz
copy files from example
Diffstat (limited to 'src/slskd/Controllers/PublicChatController.cs')
-rw-r--r--src/slskd/Controllers/PublicChatController.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/slskd/Controllers/PublicChatController.cs b/src/slskd/Controllers/PublicChatController.cs
new file mode 100644
index 00000000..f3f2c297
--- /dev/null
+++ b/src/slskd/Controllers/PublicChatController.cs
@@ -0,0 +1,50 @@
+namespace slskd.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("1")]
+ [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);
+ }
+ }
+}