Skip to content

Commit

Permalink
refactor: Get the users with whom a file is being shared (#72)
Browse files Browse the repository at this point in the history
* feat: Get the users with whom a file is being shared

Endpoint to get the users with whom a file is shared.
Testing has not been implemented yet

* refactor: Enpoint correction in addition to updating the spec

---------

Co-authored-by: Andvelavi <[email protected]>
  • Loading branch information
AndreaVelasquezA and Andvelavi authored Oct 19, 2023
1 parent a30478b commit 9373052
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/spec.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ paths:
schema:
$ref: "#/components/schemas/statusResponse"

/file/shared-with-who:
/file/{fileUUID}/shared-with-who:
get:
tags:
- Files
Expand Down
29 changes: 29 additions & 0 deletions src/controllers/files/shared_with_who/_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from src.config.soap_client import soap_client
from src.lib.helpers import is_valid_uuid


def shared_with_who_handler(token, file_uuid):
try:
if not is_valid_uuid(file_uuid):
return {"msg": "Not valid file UUID provided"}, 400

request_data = {"fileUUID": file_uuid, "token": token}
response = soap_client.service.share_list_with_who(request_data)

if response.usernames is None:
return {"msg": response["msg"]}, response["code"]

usernames = [
{
"users": usernames,
}
for usernames in response.usernames
]

return {
"users": usernames,
"msg": "List of users the file is shared with",
}, 200
except Exception as e:
print("[Exception] shared_with_who_handler ->", e)
return {"msg": "There was an error listing the shared with"}, 500

0 comments on commit 9373052

Please sign in to comment.