aboutsummaryrefslogtreecommitdiffstats
path: root/storage-backend/lib
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2018-10-17 22:10:42 +0200
committersteckbrief <steckbrief@chefmail.de>2018-10-17 22:10:42 +0200
commit3973a5f737ff92ba2accba0679f7df6397d630e4 (patch)
tree92340cb944187b7b96d96ec95b112e6a8ebbe38c /storage-backend/lib
parentbc439cd988dd308a64d0111f766716d54d3648d5 (diff)
adds API method to get spec and implementation version of the storage backend
Diffstat (limited to 'storage-backend/lib')
-rw-r--r--storage-backend/lib/functions.filetransfer.inc.php31
-rw-r--r--storage-backend/lib/version.inc.php5
2 files changed, 35 insertions, 1 deletions
diff --git a/storage-backend/lib/functions.filetransfer.inc.php b/storage-backend/lib/functions.filetransfer.inc.php
index af71ac1..b89ac7a 100644
--- a/storage-backend/lib/functions.filetransfer.inc.php
+++ b/storage-backend/lib/functions.filetransfer.inc.php
@@ -24,7 +24,35 @@ function loadSlotParameters($slotUUID, $config) {
return $slotParameters;
}
-function readSlots($jid) {
+function listFiles($jid, $limit = -1, $offset = 0) {
+ // Read complete set of existing slots per jid (unsorted)
+ $slots = readSlots($jid, $limit, $offset);
+
+ // Sort ascending by timestamp
+ usort($slots, function($a, $b) {
+ return $a['sent_time'] - $b['sent_time'];
+ });
+
+ // Select requested slot subset
+ $offsetCounter = 0;
+ $resultSet = array();
+ foreach ($slots as $slot) {
+ if (0 < $offset && $offsetCounter < $offset) {
+ $offsetCounter++;
+ continue;
+ }
+ $resultSet[] = $slot;
+
+ if (0 < $limit && $limit == count($resultSet)) {
+ break;
+ }
+ }
+ return ['count' => count($slots),
+ 'hasMore' => $offset + count($resultSet) < count($slots),
+ 'files' => $resultSet];
+}
+
+function readSlots($jid, $limit = -1, $offset = 0) {
global $config;
$jid = getBareJid($jid);
@@ -60,5 +88,6 @@ function readSlots($jid) {
}
}
}
+
return $slots;
}
diff --git a/storage-backend/lib/version.inc.php b/storage-backend/lib/version.inc.php
new file mode 100644
index 0000000..f4e6dcd
--- /dev/null
+++ b/storage-backend/lib/version.inc.php
@@ -0,0 +1,5 @@
+<?php
+return [
+ 'spec' => '0.3',
+ 'impl' => '0.3-dev'
+]; \ No newline at end of file