Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions lib/dav/davProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ export function getFavoritesReport(): string {
}

/**
* Get the SEARCH body to search for recently modified files
* Get the SEARCH body to search for recently modified/uploaded files
*
* @param lastModified Oldest timestamp to include (Unix timestamp)
* @param timestamp Oldest timestamp to include (Unix timestamp)
* @example
* ```ts
* // SEARCH for recent files need a different DAV endpoint
Expand All @@ -139,7 +139,11 @@ export function getFavoritesReport(): string {
* }) as ResponseDataDetailed<FileStat[]>
* ```
*/
export function getRecentSearch(lastModified: number): string {
export function getRecentSearch(timestamp: number): string {
const major = Number.parseInt((window.OC?.config?.version ?? '0').split('.')[0])
const patch = Number.parseInt((window.OC?.config?.version ?? '0').split('.')[2])
const supportsUploadTime = major > 33 || (major === 33 && patch > 0)

return `<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest ${getDavNameSpaces()}
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
Expand Down Expand Up @@ -173,12 +177,31 @@ export function getRecentSearch(lastModified: number): string {
<d:literal>0</d:literal>
</d:eq>
</d:or>
<d:gt>
<d:prop>
<d:getlastmodified/>
</d:prop>
<d:literal>${lastModified}</d:literal>
</d:gt>
${supportsUploadTime
? `
<d:or>
<d:gt>
<d:prop>
<d:getlastmodified/>
</d:prop>
<d:literal>${timestamp}</d:literal>
</d:gt>
<d:gt>
<d:prop>
<nc:upload_time/>
</d:prop>
<d:literal>${timestamp}</d:literal>
</d:gt>
</d:or>
`
: `
<d:gt>
<d:prop>
<d:getlastmodified/>
</d:prop>
<d:literal>${timestamp}</d:literal>
</d:gt>
`}
</d:and>
</d:where>
<d:orderby>
Expand Down