Skip to content

Commit

Permalink
Merge pull request #42338 from nextcloud/fix/files-recent-links
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Dec 19, 2023
2 parents df32c7c + 6556465 commit bfee316
Show file tree
Hide file tree
Showing 73 changed files with 116 additions and 180 deletions.
80 changes: 8 additions & 72 deletions apps/files/src/services/Recent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @copyright Copyright (c) 2023 John Molakvoæ <[email protected]>
*
* @author John Molakvoæ <[email protected]>
* @author Ferdinand Thiessen <[email protected]>
*
* @license AGPL-3.0-or-later
*
Expand All @@ -20,84 +21,19 @@
*
*/
import type { ContentsWithRoot } from '@nextcloud/files'
import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav'
import type { FileStat, ResponseDataDetailed } from 'webdav'

import { Folder, Permission, getDavNameSpaces, getDavProperties } from '@nextcloud/files'
import { generateRemoteUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { Folder, Permission, davGetRecentSearch, davGetClient, davResultToNode, davRootPath, davRemoteURL } from '@nextcloud/files'

import { getClient, rootPath } from './WebdavClient'
import { resultToNode } from './Files'

const client = getClient(generateRemoteUrl('dav'))
const client = davGetClient()

const lastTwoWeeksTimestamp = Math.round((Date.now() / 1000) - (60 * 60 * 24 * 14))
const searchPayload = `<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest ${getDavNameSpaces()}
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
<d:basicsearch>
<d:select>
<d:prop>
${getDavProperties()}
</d:prop>
</d:select>
<d:from>
<d:scope>
<d:href>/files/${getCurrentUser()?.uid}/</d:href>
<d:depth>infinity</d:depth>
</d:scope>
</d:from>
<d:where>
<d:and>
<d:or>
<d:not>
<d:eq>
<d:prop>
<d:getcontenttype/>
</d:prop>
<d:literal>httpd/unix-directory</d:literal>
</d:eq>
</d:not>
<d:eq>
<d:prop>
<oc:size/>
</d:prop>
<d:literal>0</d:literal>
</d:eq>
</d:or>
<d:gt>
<d:prop>
<d:getlastmodified/>
</d:prop>
<d:literal>${lastTwoWeeksTimestamp}</d:literal>
</d:gt>
</d:and>
</d:where>
<d:orderby>
<d:order>
<d:prop>
<d:getlastmodified/>
</d:prop>
<d:descending/>
</d:order>
</d:orderby>
<d:limit>
<d:nresults>100</d:nresults>
<ns:firstresult>0</ns:firstresult>
</d:limit>
</d:basicsearch>
</d:searchrequest>`

interface ResponseProps extends DAVResultResponseProps {
permissions: string,
fileid: number,
size: number,
}

export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
const contentsResponse = await client.getDirectoryContents(path, {
details: true,
data: searchPayload,
data: davGetRecentSearch(lastTwoWeeksTimestamp),
headers: {
// Patched in WebdavClient.ts
method: 'SEARCH',
Expand All @@ -112,11 +48,11 @@ export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
return {
folder: new Folder({
id: 0,
source: generateRemoteUrl('dav' + rootPath),
root: rootPath,
source: `${davRemoteURL}${davRootPath}`,
root: davRootPath,
owner: getCurrentUser()?.uid || null,
permissions: Permission.READ,
}),
contents: contents.map(resultToNode),
contents: contents.map((r) => davResultToNode(r)),
}
}
4 changes: 2 additions & 2 deletions dist/5358-5358.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/5358-5358.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-legacy-unified-search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-legacy-unified-search.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-profile.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-profile.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/dav-settings-personal-availability.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dav-settings-personal-availability.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/federatedfilesharing-vue-settings-admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/federatedfilesharing-vue-settings-admin.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/federatedfilesharing-vue-settings-personal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/federatedfilesharing-vue-settings-personal.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-personal-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-personal-settings.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-reference-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-reference-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-sidebar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-sidebar.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_external-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_external-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_reminders-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_reminders-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-personal-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-personal-settings.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_versions-files_versions.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_versions-files_versions.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-admin-basic-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-admin-basic-settings.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-admin-delegation.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-admin-delegation.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-admin-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-admin-security.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-admin-sharing.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-admin-sharing.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-personal-info.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-personal-info.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-personal-password.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-personal-password.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-personal-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-personal-security.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/sharebymail-vue-settings-admin-sharebymail.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/sharebymail-vue-settings-admin-sharebymail.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit bfee316

Please sign in to comment.