aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Messaging/API
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Messaging/API')
-rw-r--r--src/slskd/Messaging/API/Controllers/ConversationsController.cs14
-rw-r--r--src/slskd/Messaging/API/Controllers/RoomsController.cs10
2 files changed, 12 insertions, 12 deletions
diff --git a/src/slskd/Messaging/API/Controllers/ConversationsController.cs b/src/slskd/Messaging/API/Controllers/ConversationsController.cs
index 7ed0a92c..a1c6038f 100644
--- a/src/slskd/Messaging/API/Controllers/ConversationsController.cs
+++ b/src/slskd/Messaging/API/Controllers/ConversationsController.cs
@@ -87,7 +87,7 @@ namespace slskd.Messaging.API
/// A conversation with the specified username, or a message matching the specified id could not be found.
/// </response>
[HttpPut("{username}/{id}")]
- [Authorize(Policy = AuthPolicy.Any)]
+ [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IActionResult> Acknowledge([FromRoute, UrlEncoded] string username, [FromRoute] int id)
@@ -97,7 +97,7 @@ namespace slskd.Messaging.API
return Forbid();
}
- var message = Messages.Conversations.FindMessageAsync(username, id);
+ var message = await Messages.Conversations.FindMessageAsync(username, id);
if (message == default)
{
@@ -117,7 +117,7 @@ namespace slskd.Messaging.API
/// <response code="200">The request completed successfully.</response>
/// <response code="404">A conversation with the specified username could not be found.</response>
[HttpPut("{username}")]
- [Authorize(Policy = AuthPolicy.Any)]
+ [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)]
[ProducesResponseType(200)]
[ProducesResponseType(404)]
public async Task<IActionResult> AcknowledgeAll([FromRoute, UrlEncoded] string username)
@@ -127,7 +127,7 @@ namespace slskd.Messaging.API
return Forbid();
}
- var conversation = Messages.Conversations.FindAsync(username);
+ var conversation = await Messages.Conversations.FindAsync(username);
if (conversation == default)
{
@@ -146,7 +146,7 @@ namespace slskd.Messaging.API
/// <response code="204">The request completed successfully.</response>
/// <response code="404">A conversation with the specified username could not be found.</response>
[HttpDelete("{username}")]
- [Authorize(Policy = AuthPolicy.Any)]
+ [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)]
[ProducesResponseType(404)]
[ProducesResponseType(204)]
public async Task<IActionResult> Close([FromRoute, UrlEncoded] string username)
@@ -156,7 +156,7 @@ namespace slskd.Messaging.API
return Forbid();
}
- var conversation = Messages.Conversations.FindAsync(username, includeInactive: false);
+ var conversation = await Messages.Conversations.FindAsync(username, includeInactive: false);
if (conversation == default)
{
@@ -259,7 +259,7 @@ namespace slskd.Messaging.API
/// <response code="201">The request completed successfully.</response>
/// <response code="400">The specified message is null or empty.</response>
[HttpPost("{username}")]
- [Authorize(Policy = AuthPolicy.Any)]
+ [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)]
[ProducesResponseType(201)]
[ProducesResponseType(400)]
public async Task<IActionResult> Send([FromRoute, UrlEncoded] string username, [FromBody] string message)
diff --git a/src/slskd/Messaging/API/Controllers/RoomsController.cs b/src/slskd/Messaging/API/Controllers/RoomsController.cs
index 3b2fe568..57d3b742 100644
--- a/src/slskd/Messaging/API/Controllers/RoomsController.cs
+++ b/src/slskd/Messaging/API/Controllers/RoomsController.cs
@@ -127,7 +127,7 @@ namespace slskd.Messaging.API
/// <response code="201">The request completed successfully.</response>
/// <response code="404">The specified roomName could not be found.</response>
[HttpPost("joined/{roomName}/messages")]
- [Authorize(Policy = AuthPolicy.Any)]
+ [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)]
[ProducesResponseType(201)]
[ProducesResponseType(404)]
public async Task<IActionResult> SendMessage([FromRoute, UrlEncoded] string roomName, [FromBody] string message)
@@ -155,7 +155,7 @@ namespace slskd.Messaging.API
/// <response code="201">The request completed successfully.</response>
/// <response code="404">The specified roomName could not be found.</response>
[HttpPost("joined/{roomName}/ticker")]
- [Authorize(Policy = AuthPolicy.Any)]
+ [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)]
[ProducesResponseType(201)]
[ProducesResponseType(404)]
public async Task<IActionResult> SetTicker([FromRoute, UrlEncoded] string roomName, [FromBody] string message)
@@ -183,7 +183,7 @@ namespace slskd.Messaging.API
/// <response code="201">The request completed successfully.</response>
/// <response code="404">The specified roomName could not be found.</response>
[HttpPost("joined/{roomName}/members")]
- [Authorize(Policy = AuthPolicy.Any)]
+ [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)]
[ProducesResponseType(201)]
[ProducesResponseType(404)]
public async Task<IActionResult> AddRoomMember([FromRoute, UrlEncoded] string roomName, [FromBody] string username)
@@ -298,7 +298,7 @@ namespace slskd.Messaging.API
/// <response code="201">The request completed successfully.</response>
/// <response code="304">The room has already been joined.</response>
[HttpPost("joined")]
- [Authorize(Policy = AuthPolicy.Any)]
+ [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)]
[ProducesResponseType(typeof(Room), 201)]
[ProducesResponseType(304)]
public async Task<IActionResult> JoinRoom([FromBody] string roomName)
@@ -339,7 +339,7 @@ namespace slskd.Messaging.API
/// <response code="204">The request completed successfully.</response>
/// <response code="404">The room has not been joined.</response>
[HttpDelete("joined/{roomName}")]
- [Authorize(Policy = AuthPolicy.Any)]
+ [Authorize(Policy = AuthPolicy.Any, Roles = AuthRole.ReadWriteOrAdministrator)]
[ProducesResponseType(204)]
[ProducesResponseType(404)]
public async Task<IActionResult> LeaveRoom([FromRoute, UrlEncoded] string roomName)