mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:29 +01:00
add missing @type: Card(Group) in Addressbook REST API
This commit is contained in:
parent
4c8f88f3a0
commit
a5796c8b41
@ -16,8 +16,8 @@ use EGroupware\Api;
|
||||
/**
|
||||
* Rendering contacts as JSON using new JsContact format
|
||||
*
|
||||
* @link https://datatracker.ietf.org/doc/html/draft-ietf-jmap-jscontact-07 (newer, here implemented format)
|
||||
* @link https://datatracker.ietf.org/doc/html/rfc7095 jCard (older vCard compatible contact data as JSON, NOT implemented here!)
|
||||
* @link https://datatracker.ietf.org/doc/html/rfc9553 rfc9553: JSContact: A JSON Representation of Contact Data
|
||||
* @link https://datatracker.ietf.org/doc/html/rfc9555 rfc9555: JSContact: Converting from and to vCard
|
||||
*/
|
||||
class JsContact extends Api\CalDAV\JsBase
|
||||
{
|
||||
@ -27,11 +27,13 @@ class JsContact extends Api\CalDAV\JsBase
|
||||
const MIME_TYPE_JSCARD = "application/jscontact+json;type=card";
|
||||
const MIME_TYPE_JSCARDGROUP = "application/jscontact+json;type=cardgroup";
|
||||
|
||||
const TYPE_CARD = 'Card';
|
||||
|
||||
/**
|
||||
* Get jsCard for given contact
|
||||
*
|
||||
* @param int|array $contact
|
||||
* @param bool|"pretty" $encode=true true: JSON encode, "pretty": JSON encode with pretty-print, false: return raw data eg. from listing
|
||||
* @param bool|"pretty" $encode true: JSON encode, "pretty": JSON encode with pretty-print, false: return raw data eg. from listing
|
||||
* @return string|array
|
||||
* @throws Api\Exception\NotFound
|
||||
*/
|
||||
@ -42,6 +44,7 @@ class JsContact extends Api\CalDAV\JsBase
|
||||
throw new Api\Exception\NotFound();
|
||||
}
|
||||
$data = array_filter([
|
||||
self::AT_TYPE => self::TYPE_CARD,
|
||||
'uid' => self::uid($contact['uid']),
|
||||
'prodId' => 'EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['api']['version'],
|
||||
'created' => self::UTCDateTime($contact['created']),
|
||||
@ -1067,11 +1070,13 @@ class JsContact extends Api\CalDAV\JsBase
|
||||
return $value;
|
||||
}
|
||||
|
||||
const TYPE_CARDGROUP = 'CardGroup';
|
||||
|
||||
/**
|
||||
* Get jsCardGroup for given group
|
||||
*
|
||||
* @param int|array $group
|
||||
* @param bool|"pretty" $encode=true true: JSON, "pretty": JSON pretty-print, false: array
|
||||
* @param bool|"pretty" $encode true: JSON, "pretty": JSON pretty-print, false: array
|
||||
* @return array|string
|
||||
* @throws Api\Exception\NotFound
|
||||
*/
|
||||
@ -1082,6 +1087,7 @@ class JsContact extends Api\CalDAV\JsBase
|
||||
throw new Api\Exception\NotFound();
|
||||
}
|
||||
$data = array_filter([
|
||||
self::AT_TYPE => self::TYPE_CARDGROUP,
|
||||
'uid' => self::uid($group['list_uid']),
|
||||
'name' => $group['list_name'],
|
||||
'card' => self::getJsCard([
|
||||
|
@ -22,6 +22,7 @@ curl https://example.org/egroupware/groupdav.php/<username>/addressbook/ -H "Acc
|
||||
{
|
||||
"responses": {
|
||||
"/<username>/addressbook/1833": {
|
||||
"@type": "Card",
|
||||
"uid": "5638-8623c4830472a8ede9f9f8b30d435ea4",
|
||||
"prodId": "EGroupware Addressbook 21.1.001",
|
||||
"created": "2010-10-21T09:55:42Z",
|
||||
@ -55,6 +56,7 @@ curl https://example.org/egroupware/groupdav.php/<username>/addressbook/ -H "Acc
|
||||
],
|
||||
},
|
||||
"/<username>/addressbook/list-36": {
|
||||
"@type": "CardGroup",
|
||||
"uid": "urn:uuid:dfa5cac5-987b-448b-85d7-6c8b529a835c",
|
||||
"name": "Example distribution list",
|
||||
"card": {
|
||||
@ -160,6 +162,7 @@ curl 'https://example.org/egroupware/groupdav.php/addressbook/?sync-token=https:
|
||||
"responses": {
|
||||
"/addressbook/5597": null,
|
||||
"/addressbook/5593": {
|
||||
"@type": "Card",
|
||||
"uid": "5638-8623c4830472a8ede9f9f8b30d435ea4",
|
||||
"prodId": "EGroupware Addressbook 21.1.001",
|
||||
"created": "2010-10-21T09:55:42Z",
|
||||
@ -184,6 +187,7 @@ curl 'https://example.org/egroupware/groupdav.php/addressbook/?sync-token=https:
|
||||
```
|
||||
curl 'https://example.org/egroupware/groupdav.php/addressbook/6502' -H "Accept: application/pretty+json" --user <username>
|
||||
{
|
||||
"@type": "Card",
|
||||
"uid": "addressbook-6502-8623c4830472a8ede9f9f8b30d435ea4",
|
||||
"prodId": "EGroupware Addressbook 21.1.003",
|
||||
"created": "2022-12-14T13:35:02Z",
|
||||
@ -506,5 +510,5 @@ HTTP/1.1 204 No content
|
||||
* [Vendor-specific Property Extensions and Values](https://datatracker.ietf.org/doc/html/draft-ietf-jmap-jscontact-07#section-1.3)
|
||||
use `<domain-name>:<name>` like in JsCalendar
|
||||
* top-level objects need a `@type` attribute with one of the following values:
|
||||
`NameComponent`, `Organization`, `Title`, `Phone`, `Resource`, `File`, `ContactLanguage`,
|
||||
`Card`, `CardGroup`, `NameComponent`, `Organization`, `Title`, `Phone`, `Resource`, `File`, `ContactLanguage`,
|
||||
`Address`, `StreetComponent`, `Anniversary`, `PersonalInformation`
|
Loading…
Reference in New Issue
Block a user