Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement SEARCH according to rfc5323 #351

Merged
merged 1 commit into from Aug 30, 2023

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Aug 3, 2023

This implements the WebDAV search request.
One real life example would be if you want to query recently changed files from Nextcloud, then this can be used like this:

const query = `<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:" xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
	<d:basicsearch>
		<d:select>
			<d:prop>
			<d:getcontentlength />
			<d:getcontenttype />
			<d:getetag />
			<d:getlastmodified />
			</d:prop>
		</d:select>
		<d:from>
			<d:scope>
				<d:href>/files/YOUR_USER_ID/</d:href>
				<d:depth>infinity</d:depth>
			</d:scope>
		</d:from>
		<d:where>
			<d:gt>
				<d:prop>
					<d:getlastmodified/>
				</d:prop>
				<d:literal>${Math.round(Date.now() / 1000 - 24 * 60 * 60)}</d:literal>
			</d:gt>
		</d:where>
		<d:limit>
			<d:nresults>100</d:nresults>
			<ns:firstresult>0</ns:firstresult>
		</d:limit>
	</d:basicsearch>
</d:searchrequest>`;

// client with base path `SERVER/remote.php/dav`
client.search('/', { data: query })

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@perry-mitchell
Copy link
Owner

This is amazing stuff @susnux! Honestly a huge feature. Thanks for all the work here.

@perry-mitchell perry-mitchell merged commit 9a0a168 into perry-mitchell:master Aug 30, 2023
6 checks passed
@susnux susnux deleted the feat/implement-search branch August 30, 2023 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for search method
2 participants