Skip to content

Commit 1f94f1c

Browse files
feat(recent-search): add parameter to allow dynamic limit of returned items
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
1 parent 749e6c4 commit 1f94f1c

1 file changed

Lines changed: 3 additions & 30 deletions

File tree

lib/dav/davProperties.ts

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export function getFavoritesReport(): string {
123123
* Get the SEARCH body to search for recently modified/uploaded files
124124
*
125125
* @param timestamp Oldest timestamp to include (Unix timestamp)
126+
* @param limit Maximum number of items to return
126127
* @example
127128
* ```ts
128129
* // SEARCH for recent files need a different DAV endpoint
@@ -140,10 +141,7 @@ export function getFavoritesReport(): string {
140141
* }) as ResponseDataDetailed<FileStat[]>
141142
* ```
142143
*/
143-
export function getRecentSearch(timestamp: number): string {
144-
const capabilities = getCapabilities() as { dav?: { search_supports_upload_time?: boolean } }
145-
const supportsUploadTime = capabilities.dav?.search_supports_upload_time
146-
144+
export function getRecentSearch(timestamp: number, limit: number = 100): string {
147145
return `<?xml version="1.0" encoding="UTF-8"?>
148146
<d:searchrequest ${getDavNameSpaces()}
149147
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
@@ -177,31 +175,6 @@ export function getRecentSearch(timestamp: number): string {
177175
<d:literal>0</d:literal>
178176
</d:eq>
179177
</d:or>
180-
${supportsUploadTime
181-
? `
182-
<d:or>
183-
<d:gt>
184-
<d:prop>
185-
<d:getlastmodified/>
186-
</d:prop>
187-
<d:literal>${timestamp}</d:literal>
188-
</d:gt>
189-
<d:gt>
190-
<d:prop>
191-
<nc:upload_time/>
192-
</d:prop>
193-
<d:literal>${timestamp}</d:literal>
194-
</d:gt>
195-
</d:or>
196-
`
197-
: `
198-
<d:gt>
199-
<d:prop>
200-
<d:getlastmodified/>
201-
</d:prop>
202-
<d:literal>${timestamp}</d:literal>
203-
</d:gt>
204-
`}
205178
</d:and>
206179
</d:where>
207180
<d:orderby>
@@ -213,7 +186,7 @@ export function getRecentSearch(timestamp: number): string {
213186
</d:order>
214187
</d:orderby>
215188
<d:limit>
216-
<d:nresults>100</d:nresults>
189+
<d:nresults>${limit}</d:nresults>
217190
<ns:firstresult>0</ns:firstresult>
218191
</d:limit>
219192
</d:basicsearch>

0 commit comments

Comments
 (0)