Skip to content

Commit

Permalink
Adapted Reva JSON, see cs3org/reva#4240
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Oct 9, 2023
1 parent f0ac93c commit fc5c8a7
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions lib/Controller/OcmController.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,10 @@ private function shareInfoToCs3Share(IShare $share, string $direction, $token =
$payload = [
// use OCM name, if null use efss share native name, if null fall back to "unknown"
"name" => $ocmShareData["name"] ?? ($share->getName() ?? "unknown"),
"token" => $token ?? "unknown",
// TODO: @Mahdi what permissions is the correct one? share permissions has different value than the share->node permissions.
// maybe use the ocmData for this one? needs testing for different scenarios to see which is the best/correct one.
"permissions" => $share->getNode()->getPermissions() ?? 0,
"token" => $token,
"id" => [
// https://github.com/cs3org/go-cs3apis/blob/d297419/cs3/sharing/ocm/v1beta1/resources.pb.go#L423
"opaque_id" => $shareId ?? "unknown",
"opaque_id" => $shareId,
],
"resource_id" => [
"opaque_id" => $opaqueId,
Expand Down Expand Up @@ -324,26 +321,19 @@ private function shareInfoToCs3Share(IShare $share, string $direction, $token =
"mtime" => [
"seconds" => isset($ocmShareData["mtime"]) ? (int)$ocmShareData["ctime"] : ($share->getShareTime()->getTimestamp() ?? 0)
],
"access_methods" => [
"protocols" => [
"transfer" => [
"source_uri" => $ocmShareProtocols["transfer"]["source_uri"] ?? "unknown",
// TODO: @Mahdi this feels redundant, already included in top-level token and webdav shared_secret.
"shared_secret" => $ocmShareProtocols["transfer"]["shared_secret"] ?? "unknown",
// TODO: @Mahdi should the default value be an integer?
"size" => $ocmShareProtocols["transfer"]["size"] ?? "unknown",
"size" => $ocmShareProtocols["transfer"]["size"] ?? 0,
],
"webapp" => [
"uri_template" => $ocmShareProtocols["webapp"]["uri_template"] ?? "unknown",
"view_mode" => $ocmShareProtocols["webapp"]["view_mode"] ?? "unknown",
],
"webdav" => [
// TODO: @Mahdi it is better to have sharedSecret and permissions in this part of code.
"uri" => $ocmShareProtocols["webdav"]["uri"] ?? "unknown",
// TODO: @Mahdi it is interesting this function accepts token as argument! is token different that the share secret?
// why do we have to pass token while the share object already has the information about token?
// $share->getToken();
"shared_secret" => $ocmShareProtocols["webdav"]["shared_secret"] ?? "unknown",
"permissions" => $ocmShareProtocols["webdav"]["permissions"] ?? "unknown",
"uri" => $ocmShareProtocols["webdav"]["uri"],
// these are the share "OCS" permissions (integer)
"permissions" => $share->getPermissions() ?? 0, // is $ocmShareProtocols["webdav"]["permissions"] an int?
],
]
];
Expand Down

0 comments on commit fc5c8a7

Please sign in to comment.