Provide Drive ID and File ID of matching Shares Jail item from sharing endpoints
- Dominant language
- Go
- Stars
- 2.1k
- Forks
- 274
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 103
Description
## Is your feature request related to a problem? Please describe.
### Scenario:
- user `admin` shares the file `Chemiephoto.JPG` with `einstein` from a space that `einstein` has no access to
- user `einstein` (re)shares the file to `admin`
- user `einstein` requests a list of items he shares with others via `/ocs/v2.php/apps/files_sharing/api/v1/shares`
### Problem:
- the returned share's XML for the re-share of `Chemiephoto.JPG` shares no ID with what's returned by the `PROPFIND` for the Shares Jail
- to determine the share's File ID in the Shares Jail, the client would need to look through the `mountpoint` drives returned by `/graph/v1.0/me/drives` and check if any of the drive's `root.remoteItem.id` matches the share's `id`, then use that drives `root.id` to find the matching item in Shares Jail
### Additional Problem:
For shares shared *with* the user, the client already needs to perform string operations to gain the File ID of the item in the Shares Jail and keep track of the context (is a share representing an item "shared with" or "shared by"?) a share was received in.
Here's the current implementation:
```objc
NSString *itemSource;
if ((itemSource = shareNode.keyValues[@"item_source"]) != nil)
{
if ([itemSource containsString:@"!"] && [state isEqual:OCShareStateAccepted] && (share.category == OCShareCategoryWithMe))
{
// Compute location and FileID in Shares Jail
share.itemFileID = [OCDriveIDSharesJail stringByAppendingFormat:@"!%@", shareID]; // Item ID in Shares Jail = OCDriveIDSharesJail + "!" + shareID (via https://github.com/owncloud/web/blob/master/packages/web-client/src/helpers/space/functions.ts#L53 )
share.itemLocation = [[OCLocation alloc] initWithDriveID:OCDriveIDSharesJail path:[@"/" stringByAppendingString:sharePath.lastPathComponent]]; // Item is located in Shares Jail
}
else
{
// OCIS (drive ID could be extracted from item_source, which follows format "[driveID]![fileID]")
NSArray *itemSourceIDs = [itemSource componentsSeparatedByString:@"!"];
if (itemSourceIDs.count == 2)
{
share.itemFileID = itemSource;
share.itemLocation = [[OCLocation alloc] initWithDriveID:itemSourceIDs.firstObject path:sharePath];
}
}
}
```
I'm fine with having to do a simple string operation to extract the Drive ID from the File ID, but the client shouldn't have to know the context of a response to determine whether to use a Drive ID - or throw away the contained drive ID and use a completely different Drive ID (Shares Jail) altogether.
## Describe the solution you'd like
The sharing APIs should directly provide the Drive ID / File ID (`oc:id`) of the shared file in a non-`mountpoint` drive the user has access to:
- if the user shares a file from a drive the user has access to, it should point to the item on that drive.
- if the user re-shares a file from a drive the user has no access to, it should point to the item in the Shares Jail.
What the client should not need to do is retrieve data from multiple endpoints, align that data, or - worst case - go through trial and error to determine the location of an item returned by the Sharing API on a non-`mountpoint` drive.
## Additional context
Some responses as context for the described scenario:
From `/ocs/v2.php/apps/files_sharing/api/v1/shares`:
```xml
1284d238-aa92-42ce-bdc4-0b0000009157:88439805-75db-4b24-85b3-548af3a7afeb:e7155749-251f-44b6-b3ed-de6185866ba6
0
einstein
Albert Einstein
einstein@example.org
17
1673193340
88439805-75db-4b24-85b3-548af3a7afeb
0
/Chemiephoto.JPG
file
image/jpeg
shared::/Shares/Chemiephoto.JPG
0
1284d238-aa92-42ce-bdc4-0b0000009157$88439805-75db-4b24-85b3-548af3a7afeb!905da7cc-9a5c-4de3-bbec-d336416f639d
1284d238-aa92-42ce-bdc4-0b0000009157$88439805-75db-4b24-85b3-548af3a7afeb!905da7cc-9a5c-4de3-bbec-d336416f639d
1284d238-aa92-42ce-bdc4-0b0000009157$88439805-75db-4b24-85b3-548af3a7afeb!88439805-75db-4b24-85b3-548af3a7afeb
/Shares/Chemiephoto.JPG
admin
0
Admin
admin@example.org
0
```
From `PROPFIND` on Shares Jail (`/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668/`):
```xml
/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668/Chemiephoto.JPG
Thu, 08 Dec 2022 08:23:23 GMT
1268382
image/jpeg
"d1d23d13fd496717fe0e26a0a17fbaf2"
a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!1284d238-aa92-42ce-bdc4-0b0000009157:88439805-75db-4b24-85b3-548af3a7afeb:e9e32aa7-aeef-42e7-a72a-1d10b98b76f0
1268382
SR
0
0
HTTP/1.1 200 OK
```
From `/graph/v1.0/me/drives`:
```json
{
"driveAlias": "mountpoint/chemiephoto.jpg",
"driveType": "mountpoint",
"id": "a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!1284d238-aa92-42ce-bdc4-0b0000009157:88439805-75db-4b24-85b3-548af3a7afeb:e9e32aa7-aeef-42e7-a72a-1d10b98b76f0",
"name": "Chemiephoto.JPG",
"owner": {
"user": {
"id": "88439805-75db-4b24-85b3-548af3a7afeb"
}
},
"quota": {
"remaining": 0,
"state": "exceeded",
"total": 0,
"used": 0
},
"root": {
"id": "a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!1284d238-aa92-42ce-bdc4-0b0000009157:88439805-75db-4b24-85b3-548af3a7afeb:e9e32aa7-aeef-42e7-a72a-1d10b98b76f0",
"remoteItem": {
"eTag": "\"d1d23d13fd496717fe0e26a0a17fbaf2\"",
"file": {
"mimeType": "image/jpeg"
},
"id": "1284d238-aa92-42ce-bdc4-0b0000009157$88439805-75db-4b24-85b3-548af3a7afeb!905da7cc-9a5c-4de3-bbec-d336416f639d",
"lastModifiedDateTime": "2022-12-08T08:23:23.013321488Z",
"name": "Chemiephoto.JPG",
"size": 1268382,
"webDavUrl": "https://ocis.test.local/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157$88439805-75db-4b24-85b3-548af3a7afeb%21905da7cc-9a5c-4de3-bbec-d336416f639d"
},
"webDavUrl": "https://ocis.test.local/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668%211284d238-aa92-42ce-bdc4-0b0000009157:88439805-75db-4b24-85b3-548af3a7afeb:e9e32aa7-aeef-42e7-a72a-1d10b98b76f0"
},
"webUrl": "https://ocis.test.local/f/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668%211284d238-aa92-42ce-bdc4-0b0000009157:88439805-75db-4b24-85b3-548af3a7afeb:e9e32aa7-aeef-42e7-a72a-1d10b98b76f0"
}
```
Contributor guide
Assessment
This issue has not been assessed yet.