Skip to content

Commit

Permalink
feat: update metadata route to add details (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
ze42 authored Oct 25, 2024
2 parents 3b24870 + be27846 commit b9e7523
Show file tree
Hide file tree
Showing 10 changed files with 385 additions and 196 deletions.
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>CidgravityGateway</name>
<summary>An application to display files/directory metadata on decentralized web for CIDgravity storage files</summary>
<description>An application to display files/directory metadata on decentralized web for CIDgravity storage files</description>
<version>1.1.4</version>
<version>1.1.5</version>
<licence>agpl</licence>
<author homepage="https://cidgravity.com">CIDgravity</author>
<author>CIDgravity</author>
Expand All @@ -17,6 +17,6 @@
<website>https://github.com/CIDgravity/nextcloud-cidgravity-gateway-app</website>
<repository type="git">https://github.com/CIDgravity/nextcloud-cidgravity-gateway-app</repository>
<dependencies>
<nextcloud min-version="29" max-version="29" />
<nextcloud min-version="29" max-version="30" />
</dependencies>
</info>
26 changes: 22 additions & 4 deletions l10n/en_GB.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,37 @@ OC.L10N.register(
{
"CIDgravity": "CIDgravity",
"Select an IPFS gateway": "Select an IPFS gateway",
"Directory metadata": "Directory metadata",
"File metadata": "File metadata",
"Directory details": "Directory details",
"File details": "File details",
"Something went wrong while loading metadata": "Something went wrong while loading metadata",
"Click to open": "Click to open",
"IPFS public link": "IPFS public link",
"Copy link": "Copy link",
"CID": "CID",
"Copy CID": "Copy CID",
"Not metadata available": "Not metadata available",
"No metadata available": "No metadata available",
"This {contentType} is not located on a CIDgravity external storage.": "This {contentType} is not located on a CIDgravity external storage.",
"CID copied": "CID copied",
"Unable to copy the CID": "Unable to copy the CID",
"Public link copied": "Public link copied",
"Unable to copy the public link": "Unable to copy the public link"
"Unable to copy the public link": "Unable to copy the public link",
"retrievable copies": "retrievable copies",
"retrievable copy": "retrievable copy",
"Preparing to push to Filecoin.": "Preparing to push to Filecoin.",
"Actively transferring to Filecoin.": "Actively transferring to Filecoin.",
"At least one copy is stored and accessible on Filecoin.": "At least one copy is stored and accessible on Filecoin.",
"All expected copies are stored and distributed on Filecoin.": "All expected copies are stored and distributed on Filecoin.",
"Number of copies that can be retrieved from Filecoin.": "Number of copies that can be retrieved from Filecoin.",
"Use default storage gateway": "Use default storage gateway",
"Use pinata.cloud gateway": "Use pinata.cloud gateway",
"Use ipfs.io gateway": "Use ipfs.io gateway",
"Use dweb.link gateway": "Use dweb.link gateway",
"IPFS gateway updated": "IPFS gateway updated",
"Status": "Status",
"Staging": "Staging",
"Offloading": "Offloading",
"Partially offloaded": "Partially offloaded",
"Offloaded": "Offloaded",
"Unknown": "Unknown"
},
"nplurals=2; plural=(n != 1);");
24 changes: 21 additions & 3 deletions l10n/en_GB.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ "translations": {
"CIDgravity": "CIDgravity",
"Select an IPFS gateway": "Select an IPFS gateway",
"Directory metadata": "Directory metadata",
"File metadata": "File metadata",
"Directory details": "Directory details",
"File details": "File details",
"Something went wrong while loading metadata": "Something went wrong while loading metadata",
"Click to open": "Click to open",
"IPFS public link": "IPFS public link",
Expand All @@ -14,6 +14,24 @@
"CID copied": "CID copied",
"Unable to copy the file CID": "Unable to copy the CID",
"Public link copied": "Public link copied",
"Unable to copy the public link": "Unable to copy the public link"
"Unable to copy the public link": "Unable to copy the public link",
"retrievable copies": "retrievable copies",
"retrievable copy": "retrievable copy",
"Preparing to push to Filecoin.": "Preparing to push to Filecoin.",
"Actively transferring to Filecoin.": "Actively transferring to Filecoin.",
"At least one copy is stored and accessible on Filecoin.": "At least one copy is stored and accessible on Filecoin.",
"All expected copies are stored and distributed on Filecoin.": "All expected copies are stored and distributed on Filecoin.",
"Number of copies that can be retrieved from Filecoin.": "Number of copies that can be retrieved from Filecoin.",
"Use default storage gateway": "Use default storage gateway",
"Use pinata.cloud gateway": "Use pinata.cloud gateway",
"Use ipfs.io gateway": "Use ipfs.io gateway",
"Use dweb.link gateway": "Use dweb.link gateway",
"IPFS gateway updated": "IPFS gateway updated",
"Status": "Status",
"Staging": "Staging",
"Offloading": "Offloading",
"Partially offloaded": "Partially offloaded",
"Offloaded": "Offloaded",
"Unknown": "Unknown"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
16 changes: 1 addition & 15 deletions lib/Controller/ExternalStorageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,7 @@ public function getMetadataForSpecificFile(int $fileId): DataResponse {
}

$fileMetadata = $this->externalStorageService->getMetadataForSpecificFile($user, $fileId);

if (!isset($fileMetadata['error'])) {
if ($fileMetadata['result']['success']) {
return new DataResponse(['success' => true, 'metadata' => $fileMetadata['result']], Http::STATUS_OK);
} else {
return new DataResponse(['success' => false, 'error' => $fileMetadata['result']['error']], Http::STATUS_OK);
}
}

return new DataResponse([
'success' => false,
'error' => $fileMetadata['error'],
'errorMessage' => $fileMetadata['result']
], Http::STATUS_INTERNAL_SERVER_ERROR);

return new DataResponse($fileMetadata, Http::STATUS_OK);
} catch (Exception $e) {
return new DataResponse(['success' => false, 'error' => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
}
Expand Down
14 changes: 9 additions & 5 deletions lib/Service/ExternalStorageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public function getMetadataForSpecificFile(IUser $nextcloudUser, int $fileId): a

if (!isset($externalStorageConfiguration['error'])) {
$requestBody = [
"user" => $nextcloudUser->getUID(),
"filepath" => $externalStorageConfiguration['filepath'],
"verbose" => true,
"filePath" => $externalStorageConfiguration['filepath'],
];

$response = $this->httpClient->post(
Expand All @@ -74,14 +74,18 @@ public function getMetadataForSpecificFile(IUser $nextcloudUser, int $fileId): a
$externalStorageConfiguration['password'],
);

return ['result' => $response];
if ($response['success']) {
return ['success' => true, 'metadata' => $response['result']];
} else {
return ['success' => false, 'error' => $response['error']];
}

} else {
return $externalStorageConfiguration;
return ['success' => false, 'error' => 'unable to find external storage configuration'];
}

} catch (Exception $e) {
return ['message' => 'error getting metadata for file ' . $fileId, 'error' => $e->getMessage()];
return ['success' => false, 'error' => 'error getting metadata for file ' . $fileId];
}
}

Expand Down
Loading

0 comments on commit b9e7523

Please sign in to comment.