Skip to content

Commit 2ab0fd4

Browse files
feat(recent-search): use capatabilities to identify wheter upload_time is supported and use upload_time
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
1 parent 3411892 commit 2ab0fd4

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

lib/dav/davProperties.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55
import { getCurrentUser } from '@nextcloud/auth'
6+
import { getCapabilities } from '@nextcloud/capabilities'
67
import logger from '../utils/logger'
78

89
export type DavProperty = { [key: string]: string }
@@ -146,6 +147,9 @@ export const getFavoritesReport = function(): string {
146147
* ```
147148
*/
148149
export const getRecentSearch = function(lastModified: number): string {
150+
const capabilities = getCapabilities() as { dav?: { search_supports_upload_time?: boolean } }
151+
const supportsUploadTime = capabilities.dav?.search_supports_upload_time
152+
149153
return `<?xml version="1.0" encoding="UTF-8"?>
150154
<d:searchrequest ${getDavNameSpaces()}
151155
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
@@ -179,12 +183,31 @@ export const getRecentSearch = function(lastModified: number): string {
179183
<d:literal>0</d:literal>
180184
</d:eq>
181185
</d:or>
182-
<d:gt>
183-
<d:prop>
184-
<d:getlastmodified/>
185-
</d:prop>
186-
<d:literal>${lastModified}</d:literal>
187-
</d:gt>
186+
${supportsUploadTime
187+
? `
188+
<d:or>
189+
<d:gt>
190+
<d:prop>
191+
<d:getlastmodified/>
192+
</d:prop>
193+
<d:literal>${lastModified}</d:literal>
194+
</d:gt>
195+
<d:gt>
196+
<d:prop>
197+
<nc:upload_time/>
198+
</d:prop>
199+
<d:literal>${lastModified}</d:literal>
200+
</d:gt>
201+
</d:or>
202+
`
203+
: `
204+
<d:gt>
205+
<d:prop>
206+
<d:getlastmodified/>
207+
</d:prop>
208+
<d:literal>${lastModified}</d:literal>
209+
</d:gt>
210+
`}
188211
</d:and>
189212
</d:where>
190213
<d:orderby>

0 commit comments

Comments
 (0)