Skip to content

Commit 3b29150

Browse files
authored
Merge pull request #1498 from nextcloud-libraries/feat/1698/recent-files-include-recently-uploaded
feat(recent-search): include recently uploaded files in addition to modified files
2 parents 9baccb0 + 2647836 commit 3b29150

1 file changed

Lines changed: 32 additions & 9 deletions

File tree

lib/dav/davProperties.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ export function getFavoritesReport(): string {
119119
}
120120

121121
/**
122-
* Get the SEARCH body to search for recently modified files
122+
* Get the SEARCH body to search for recently modified/uploaded files
123123
*
124-
* @param lastModified Oldest timestamp to include (Unix timestamp)
124+
* @param timestamp Oldest timestamp to include (Unix timestamp)
125125
* @example
126126
* ```ts
127127
* // SEARCH for recent files need a different DAV endpoint
@@ -139,7 +139,11 @@ export function getFavoritesReport(): string {
139139
* }) as ResponseDataDetailed<FileStat[]>
140140
* ```
141141
*/
142-
export function getRecentSearch(lastModified: number): string {
142+
export function getRecentSearch(timestamp: number): string {
143+
const major = Number.parseInt((window.OC?.config?.version ?? '0').split('.')[0])
144+
const patch = Number.parseInt((window.OC?.config?.version ?? '0').split('.')[2])
145+
const supportsUploadTime = major > 33 || (major === 33 && patch > 0)
146+
143147
return `<?xml version="1.0" encoding="UTF-8"?>
144148
<d:searchrequest ${getDavNameSpaces()}
145149
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
@@ -173,12 +177,31 @@ export function getRecentSearch(lastModified: number): string {
173177
<d:literal>0</d:literal>
174178
</d:eq>
175179
</d:or>
176-
<d:gt>
177-
<d:prop>
178-
<d:getlastmodified/>
179-
</d:prop>
180-
<d:literal>${lastModified}</d:literal>
181-
</d:gt>
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+
`}
182205
</d:and>
183206
</d:where>
184207
<d:orderby>

0 commit comments

Comments
 (0)