diff options
author | steckbrief <steckbrief@chefmail.de> | 2018-10-17 22:10:42 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2018-10-17 22:10:42 +0200 |
commit | 3973a5f737ff92ba2accba0679f7df6397d630e4 (patch) | |
tree | 92340cb944187b7b96d96ec95b112e6a8ebbe38c /storage-backend/lib/functions.filetransfer.inc.php | |
parent | bc439cd988dd308a64d0111f766716d54d3648d5 (diff) |
adds API method to get spec and implementation version of the storage backend
Diffstat (limited to '')
-rw-r--r-- | storage-backend/lib/functions.filetransfer.inc.php | 31 |
1 files changed, 30 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; } |