Skip to content

Commit

Permalink
updated code and drone env for master and stable
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Panta committed Jul 5, 2024
1 parent 0fe2314 commit 2586268
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .drone.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The version of OCIS to use in pipelines that test against OCIS
OCIS_COMMITID=c18d71788351ac878d2016b178e3e87c673e62a3
OCIS_COMMITID=aa6041abb6e8094306216fbe354403df14b47c70
OCIS_BRANCH=master
OCIS_STABLE_COMMITID=48ab941943a9eb3b510b7029ba39ba445a6aac1b
OCIS_STABLE_COMMITID=214491134f5674ac735635ea259969663d9ad4c7
OCIS_STABLE_BRANCH=stable-5.0
2 changes: 1 addition & 1 deletion src/Drive.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public function emptyTrashbin(): bool
*/
public function getRoles(): array
{
if((version_compare($this->ocisVersion, '6.0.0', '<'))) {
if((version_compare($this->ocisVersion, '6.0.0', '<='))) {
throw new EndPointNotImplementedException(Ocis::ENDPOINT_NOT_IMPLEMENTED_ERROR_MESSAGE);
};
$guzzle = new Client(
Expand Down
19 changes: 8 additions & 11 deletions src/Ocis.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class Ocis
private Configuration $graphApiConfig;
private Client $guzzle;
private string $notificationsEndpoint = '/ocs/v2.php/apps/notifications/api/v1/notifications?format=json';
private string $ocisVersion;

/**
* @phpstan-var ConnectionConfig
Expand Down Expand Up @@ -114,7 +113,6 @@ public function __construct(
$this->graphApiConfig = Configuration::getDefaultConfiguration()->setHost(
$this->serviceUrl . '/graph'
);
$this->getOcisVersion();
}

public function getServiceUrl(): string
Expand Down Expand Up @@ -313,13 +311,12 @@ private function getServiceUrlFromWebfinger(string $webfingerUrl): string
/**
* saves current oCIS version in semantic versioning format ( e.g. "5.0.5" )
*
* @return void
* @return string
* @throws InvalidResponseException
*/
private function getOcisVersion(): void
private function getOcisVersion(): string
{
$fullUrl = self::getServiceUrl() . '/ocs/v1.php/cloud/capabilities';
$response = $this->guzzle->request('GET', $fullUrl);
$response = $this->guzzle->get($this->serviceUrl . '/ocs/v1.php/cloud/capabilities');
$responseContent = $response->getBody()->getContents();

$body = simplexml_load_string($responseContent);
Expand All @@ -329,7 +326,7 @@ private function getOcisVersion(): void
$version = (string)$body->data->capabilities->core->status->productversion;
$pattern = '(\d\.\d\.\d)';
preg_match($pattern, $version, $matches);
$this->ocisVersion = $matches[0];
return $matches[0];
}

/**
Expand Down Expand Up @@ -385,7 +382,7 @@ public function getAllDrives(
$this->connectionConfig,
$this->serviceUrl,
$this->accessToken,
$this->ocisVersion
$this->getOcisVersion()
);
$drives[] = $drive;
}
Expand Down Expand Up @@ -443,7 +440,7 @@ public function getMyDrives(
$this->connectionConfig,
$this->serviceUrl,
$this->accessToken,
$this->ocisVersion
$this->getOcisVersion()
);
$drives[] = $drive;
}
Expand Down Expand Up @@ -501,7 +498,7 @@ public function getDriveById(string $driveId): Drive
$this->connectionConfig,
$this->serviceUrl,
$this->accessToken,
$this->ocisVersion
$this->getOcisVersion()
);
}

Expand Down Expand Up @@ -554,7 +551,7 @@ public function createDrive(
$this->connectionConfig,
$this->serviceUrl,
$this->accessToken,
$this->ocisVersion
$this->getOcisVersion()
);
}
throw new InvalidResponseException(
Expand Down

0 comments on commit 2586268

Please sign in to comment.