Skip to content

Commit bdc0c83

Browse files
feat(recent-search): allow ordering by nc:last_activity when capability is true
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
1 parent 749e6c4 commit bdc0c83

1 file changed

Lines changed: 4 additions & 28 deletions

File tree

lib/dav/davProperties.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ export function getFavoritesReport(): string {
141141
* ```
142142
*/
143143
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
144+
const capabilities = getCapabilities() as { dav?: { search_supports_last_activity?: boolean } }
145+
const supportsLastActivity = capabilities.dav?.search_supports_last_activity
146+
const orderByProp = supportsLastActivity ? '<nc:last_activity/>' : '<d:getlastmodified/>'
146147

147148
return `<?xml version="1.0" encoding="UTF-8"?>
148149
<d:searchrequest ${getDavNameSpaces()}
@@ -177,37 +178,12 @@ export function getRecentSearch(timestamp: number): string {
177178
<d:literal>0</d:literal>
178179
</d:eq>
179180
</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-
`}
205181
</d:and>
206182
</d:where>
207183
<d:orderby>
208184
<d:order>
209185
<d:prop>
210-
<d:getlastmodified/>
186+
${orderByProp}
211187
</d:prop>
212188
<d:descending/>
213189
</d:order>

0 commit comments

Comments
 (0)