From 3a4607d297b9ddabaca32470d4c58ec2918effd1 Mon Sep 17 00:00:00 2001 From: inalone Date: Fri, 11 Nov 2022 17:32:26 +0000 Subject: Add 'get full directory' to FileList This commit adds a new {username}/directory/{directory} endpoint which returns the contents of a given directory from a user. This has been implemented in the frontend by adding a "Get Full Directory" button to FileList, which is rendered if a "getFullDirectory" function is passed a as a prop. This is not needed in Browse, so this is currently just added to the search. --- src/slskd/Users/API/Controllers/UsersController.cs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/slskd/Users/API/Controllers') diff --git a/src/slskd/Users/API/Controllers/UsersController.cs b/src/slskd/Users/API/Controllers/UsersController.cs index 0f06a677..6ef9fc3e 100644 --- a/src/slskd/Users/API/Controllers/UsersController.cs +++ b/src/slskd/Users/API/Controllers/UsersController.cs @@ -123,6 +123,29 @@ namespace slskd.Users.API return NotFound(); } + /// + /// Retrieves the files from the specified from the specified . + /// + /// The desired directory. + /// The username of the user. + /// + [HttpGet("{username}/directory/{directory}")] + [Authorize(Policy = AuthPolicy.Any)] + [ProducesResponseType(typeof(IEnumerable), 200)] + [ProducesResponseType(404)] + public async Task Directory([FromRoute, Required] string username, [FromRoute, Required] string directory) + { + try + { + var result = await Client.GetDirectoryContentsAsync(username, directory); + return Ok(result); + } + catch (UserOfflineException ex) + { + return NotFound(ex.Message); + } + } + /// /// Retrieves information about the specified . /// -- cgit v1.2.3