diff options
Diffstat (limited to 'storage-backend/lib')
-rw-r--r-- | storage-backend/lib/functions.filetransfer.inc.php | 31 | ||||
-rw-r--r-- | storage-backend/lib/version.inc.php | 5 |
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 |