From 3973a5f737ff92ba2accba0679f7df6397d630e4 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Wed, 17 Oct 2018 22:10:42 +0200 Subject: adds API method to get spec and implementation version of the storage backend --- storage-backend/lib/functions.filetransfer.inc.php | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'storage-backend/lib/functions.filetransfer.inc.php') 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; } -- cgit v1.2.3