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

Implement systemtags through webdav #37609

Merged
merged 2 commits into from
Apr 28, 2023
Merged

Implement systemtags through webdav #37609

merged 2 commits into from
Apr 28, 2023

Conversation

tobiasKaminsky
Copy link
Member

@tobiasKaminsky tobiasKaminsky commented Apr 6, 2023

Exposes system tags under the {http://nextcloud.org/ns}system-tags property.

@icewind1991
Copy link
Member

icewind1991 commented Apr 11, 2023

https://github.com/nextcloud/server/blob/215aef3cbdc1963be1bb6bca5218ee0a4b7f1665/apps/dav/lib/Connector/Sabre/TagsPlugin.php might provide the info you need already with {http://owncloud.org/ns}tags

@tobiasKaminsky
Copy link
Member Author

Strange, it does always return empty, but not 404:

	<d:response>
		<d:href>/remote.php/dav/files/tobias/temp/tags/1.md</d:href>
		<d:propstat>
			<d:prop>
				<oc:id>07264386ocmk9xspynvl</oc:id>
				<oc:fileid>7264386</oc:fileid>
				<d:displayname>1.md</d:displayname>
				<d:resourcetype/>
				<oc:favorite>0</oc:favorite>
				<nc:mount-type></nc:mount-type>
				<d:creationdate>1970-01-01T00:00:00+00:00</d:creationdate>
				<d:getetag>&quot;643647e3a10a7&quot;</d:getetag>
				<oc:permissions>RGDNVW</oc:permissions>
				<oc:share-types/>
				<oc:owner-id>tobias</oc:owner-id>
				<d:getcontenttype>text/markdown</d:getcontenttype>
				<nc:sharees/>
				<oc:tags/>
			</d:prop>
			<d:status>HTTP/1.1 200 OK</d:status>
		</d:propstat>
		<d:propstat>
			<d:prop>
				<nc:is-encrypted/>
				<nc:share-expiration/>
				<nc:rich-workspace/>
				<nc:X-Hash-MD5/>
				<d:quota-used-bytes/>
			</d:prop>
			<d:status>HTTP/1.1 404 Not Found</d:status>
		</d:propstat>
	</d:response>

Double tested, and also with our c.nc.c.

Request is:

curl --request PROPFIND \
  --url https://cloud.nextcloud.com/remote.php/dav/files/tobias/temp/tags/ \
  --header 'Content-Type: application/xml' \
  --data '<?xml version="1.0" encoding="UTF-8"?>
<D:propfind xmlns:D="DAV:">
<D:prop>
<id xmlns="http://owncloud.org/ns"/>
<fileid xmlns="http://owncloud.org/ns"/>
<D:displayname/>
<D:resourcetype/>
<favorite xmlns="http://owncloud.org/ns"/>
<is-encrypted xmlns="http://nextcloud.org/ns"/>
<mount-type xmlns="http://nextcloud.org/ns"/>
<D:creationdate/>
<id xmlns="http://owncloud.org/ns"/>
<D:getetag/>
<permissions xmlns="http://owncloud.org/ns"/>
<share-types xmlns="http://owncloud.org/ns"/>
<share-expiration xmlns="http://nextcloud.org/ns"/>
<rich-workspace xmlns="http://nextcloud.org/ns"/>
<owner-id xmlns="http://owncloud.org/ns"/>
	<X-Hash-MD5 xmlns="http://nextcloud.org/ns"/>
	<D:quota-used-bytes/>
<D:getcontenttype/>
<sharees  xmlns="http://nextcloud.org/ns"/>
<tags xmlns="http://owncloud.org/ns"/>
</D:prop></D:propfind>'

@icewind1991
Copy link
Member

icewind1991 commented Apr 17, 2023

Looks like that dav property return the user-specific tags (not sure if they are used for anything but favorites atm) instead of system tags.

Will look into exposing system tags

@icewind1991
Copy link
Member

Implemented showing system tags with the {http://nextcloud.org/ns}system-tags prop

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Psalm found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@skjnldsv
Copy link
Member

not sure if they are used for anything but favorites atm

they are not

@tobiasKaminsky
Copy link
Member Author

Many thanks!
This works!

@icewind1991 icewind1991 force-pushed the showTags branch 2 times, most recently from f52d757 to 1ea01b2 Compare April 19, 2023 16:21
@tobiasKaminsky
Copy link
Member Author

<nc:system-tag oc:can-assign="true" oc:id="3" oc:user-assignable="true" oc:user-visible="true">important</nc:system-tag>

can it happen that this webdav request will return an entry with: user-visible=false?
Do clients have to check this?

@icewind1991
Copy link
Member

No, those should be filtered out server side

apps/dav/lib/SystemTag/SystemTagPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/SystemTag/SystemTagPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/SystemTag/SystemTagPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/SystemTag/SystemTagPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/SystemTag/SystemTagPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/SystemTag/SystemTagList.php Fixed Show fixed Hide fixed
apps/dav/lib/SystemTag/SystemTagPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/SystemTag/SystemTagPlugin.php Fixed Show fixed Hide fixed
apps/dav/lib/SystemTag/SystemTagList.php Fixed Show fixed Hide fixed
apps/dav/lib/SystemTag/SystemTagPlugin.php Fixed Show fixed Hide fixed
@tobiasKaminsky
Copy link
Member Author

Can we merge this soon, as I need it to have proper tests on Android.

Signed-off-by: Robin Appelman <robin@icewind.nl>
@skjnldsv

This comment was marked as resolved.

@skjnldsv skjnldsv force-pushed the showTags branch 2 times, most recently from 82bb849 to c03b784 Compare April 28, 2023 09:12
@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Apr 28, 2023
@skjnldsv skjnldsv requested review from a team, ArtificialOwl, icewind1991 and blizzz and removed request for a team April 28, 2023 09:12
@blizzz
Copy link
Member

blizzz commented Apr 28, 2023

There are some similarities to #37961, but also differences (like depth is respected here, and we use the search there, plus get more meta data)

P.S.: After a second look: different use case, not competing.

@skjnldsv skjnldsv added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Apr 28, 2023
@skjnldsv
Copy link
Member

skjnldsv commented Apr 28, 2023

Hum, phpunit is failing

1) OCA\DAV\Tests\unit\SystemTag\SystemTagPluginTest::testGetProperties with data set #0 (OC\SystemTag\SystemTag Object (...), array(), array('{http://owncloud.org/ns}id', '{http://owncloud.org/ns}display-name', '{http://owncloud.org/ns}user-visible', '{http://owncloud.org/ns}user-...gnable', '{http://owncloud.org/ns}can-assign'), array('1', 'Test', 'true', 'true', 'true'))
226 | TypeError: Cannot assign PHPUnit\Framework\MockObject\MockBuilder to property OCA\DAV\Tests\unit\SystemTag\SystemTagPluginTest::$tagMapper of type OCP\SystemTag\ISystemTagObjectMapper
227 |  
228 | /drone/src/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php:114

EDIT pushed a fix

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
@skjnldsv skjnldsv changed the title initial start to have tags via webdav Impleent systemtags through webdav Apr 28, 2023
@skjnldsv skjnldsv changed the title Impleent systemtags through webdav Implement systemtags through webdav Apr 28, 2023
@skjnldsv skjnldsv merged commit 74f31ba into master Apr 28, 2023
@skjnldsv skjnldsv deleted the showTags branch April 28, 2023 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish enhancement feature: dav feature: tags
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants