Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix OCS Client with non empty base Path
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Feb 29, 2016
1 parent 1b054e3 commit 646a886
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions core/src/plugins/core.ocs/src/Client/OCSClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,27 @@ class OCSClient implements IFederated, IServiceDiscovery
*/
public function sendInvitation(ShareInvitation $invitation)
{
$url = rtrim($invitation->getTargetHost(), "/");
$path = parse_url($url, PHP_URL_PATH);
if($path == "/") $path = "";

$client = new GuzzleClient([
'base_url' => $invitation->getTargetHost()
'base_url' => $url."/"
]);

$endpoints = self::findEndpointsForClient($client);

$response = $client->post($endpoints['share'], [
'body' => [
'shareWith' => $invitation->getTargetUser(),
'token' => $invitation->getLinkHash(),
'name' => $invitation->getDocumentName(),
'remoteId' => $invitation->getId(),
'owner' => $invitation->getOwner(),
'remote' => AJXP_Utils::detectServerUrl()
]
$body = [
'shareWith' => $invitation->getTargetUser(),
'token' => $invitation->getLinkHash(),
'name' => $invitation->getDocumentName(),
'remoteId' => $invitation->getId(),
'owner' => $invitation->getOwner(),
'remote' => AJXP_Utils::detectServerUrl()
];

$response = $client->post($path.$endpoints['share'], [
'body' => $body
]);

if ($response->getStatusCode() != 200) {
Expand All @@ -71,19 +77,23 @@ public function sendInvitation(ShareInvitation $invitation)
*
* Cancels a sent invitation
*
* @param ShareInvitation $inviation
* @return boolean success
* @param ShareInvitation $invitation
* @return bool success
* @throws \Exception
*/
public function cancelInvitation(ShareInvitation $invitation)
{
$url = rtrim($invitation->getTargetHost(), "/");
$path = parse_url($url, PHP_URL_PATH);
if($path == "/") $path = "";

$client = new GuzzleClient([
'base_url' => $invitation->getTargetHost()
'base_url' => $url."/"
]);

$endpoints = self::findEndpointsForClient($client);

$response = $client->post($endpoints['share'] . '/' . $invitation->getId() . '/unshare', [
$response = $client->post($path.$endpoints['share'] . '/' . $invitation->getId() . '/unshare', [
'body' => [
'token' => $invitation->getLinkHash()
]
Expand Down Expand Up @@ -157,7 +167,7 @@ public function declineInvitation(RemoteShare $remoteShare)
*/
public static function findEndpointsForURL($url) {
$client = new GuzzleClient([
'base_url' => $url
'base_url' => rtrim($url, "/") . "/"
]);

return self::findEndpointsForClient($client);
Expand Down

0 comments on commit 646a886

Please sign in to comment.