dav: minify xml

Signed-off-by: Varun Patil <radialapps@gmail.com>
dexie
Varun Patil 2023-09-29 20:56:09 -07:00
parent 248a3cd7a0
commit 10bc05eaea
1 changed files with 4 additions and 39 deletions

View File

@ -88,52 +88,17 @@ async function getFilesInternal2(fileIds: number[]): Promise<IFileInfo[]> {
return [];
}
// https://jsonformatter.org/xml-formatter
const filter = fileIds
.map(
(fileId) => `
<d:eq>
<d:prop>
<oc:fileid/>
</d:prop>
<d:literal>${fileId}</d:literal>
</d:eq>
`
)
.map((fileId) => `<d:eq><d:prop><oc:fileid/></d:prop><d:literal>${fileId}</d:literal></d:eq>`)
.join('');
const options = {
method: 'SEARCH',
headers: {
'content-Type': 'text/xml',
},
data: `<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:"
xmlns:oc="http://owncloud.org/ns"
xmlns:nc="http://nextcloud.org/ns"
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns"
xmlns:ocs="http://open-collaboration-services.org/ns">
<d:basicsearch>
<d:select>
<d:prop>
<oc:fileid />
</d:prop>
</d:select>
<d:from>
<d:scope>
<d:href>${prefixPath}</d:href>
<d:depth>0</d:depth>
</d:scope>
</d:from>
<d:where>
<d:or>
${filter}
</d:or>
</d:where>
</d:basicsearch>
</d:searchrequest>`,
headers: { 'content-Type': 'text/xml' },
data: `<?xml version="1.0" encoding="UTF-8"?><d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns" xmlns:ns="https://github.com/icewind1991/SearchDAV/ns" xmlns:ocs="http://open-collaboration-services.org/ns"><d:basicsearch><d:select><d:prop><oc:fileid /></d:prop></d:select><d:from><d:scope><d:href>${prefixPath}</d:href><d:depth>0</d:depth></d:scope></d:from><d:where><d:or>${filter}</d:or></d:where></d:basicsearch></d:searchrequest>`,
deep: true,
details: true,
responseType: 'text',
};
const response: any = await client.getDirectoryContents('', options);