server icon indicating copy to clipboard operation
server copied to clipboard

OCP API: Contacts photos format

Open marcelklehr opened this issue 3 years ago • 5 comments

Describe the bug

I'm trying to process contact photos in an app. Sometimes the photos I get from OCP\IAddressBook#search are binary blobs, sometimes they are links, that are Basic Auth protected. Is this intended?

Steps to reproduce

  1. Write a Nextcloud App
  2. OCP\Contacts\IManager#getUserAddressBooks()
  3. $cards = OCP\IAddressBook#search()
  4. file_get_contents($card['PHOTO'])

Expected behavior

Consistent data formatting, either all photos as blobs or all photos as URLs. Additionally it would be nice if those URLs didn't have Basic Auth protection, which makes it quite hard to process the photos on the server (I assume I would need to create an app password.)

Actual behavior

Sometimes PHOTO entries are URLs with Basic Auth protection, sometimes they are blobs.

Contact version

Not sure

Operating system

Not sure

PHP engine version

PHP 7.4

Web server

Apache (supported)

Database

Other

Operating system

Not sure

List of activated Apps

This is generated from third-party reports, I don't have access.

Nextcloud Signing status

No response

Configuration report

No response

Additional info

This info is generated from third-party reports, I don't have access. See the original issue on my repo: https://github.com/marcelklehr/recognize/issues/139

marcelklehr avatar May 20 '22 09:05 marcelklehr

https://github.com/nextcloud/mail/blob/51a9b5b57263565b3218f199c40b36d63f72d3a7/lib/Service/ContactsIntegration.php#L118-L130 in Mail we filter the photos as well

ChristophWurst avatar May 20 '22 10:05 ChristophWurst

Is there more info about which format can be expected in which situations? Is one format legacy and resetting the photo in the UI will cause it to be saved in the new format?

marcelklehr avatar May 20 '22 11:05 marcelklehr

That I don't know

ChristophWurst avatar May 20 '22 11:05 ChristophWurst

Yeah this is intended only for front-end usage, where you are already logged-in so you can access the URI.

It's added in https://github.com/nextcloud/server/blob/af4a90924d513fb65d0723dad322d7af3e78ae61/apps/dav/lib/CardDAV/AddressBookImpl.php#L275-L285

And then the file is served by the OCA\DAV\CardDAV\ImageExportPlugin.

This will happen anytime the property is not an actual URL but contains binary data.

We could add a new option in IAddressBook::search $options parameter to get the actual data instead of the generated URI.

In any case, can we move this to server?

tcitworld avatar May 20 '22 12:05 tcitworld

We could add a new option in IAddressBook::search $options parameter to get the actual data instead of the generated URI.

That would be great!

This will happen anytime the property is not an actual URL but contains binary data.

I've been given binary data from this endpoint before on my instances, but I'm not sure why.

In any case, can we move this to server?

Sure.

marcelklehr avatar May 20 '22 14:05 marcelklehr