Skip to content
/ addrb Public

Commit cb02e75

Browse files
authored
Merge pull request #7 from AbeEstrada/icloud
Use icloud.com endpoint
2 parents 3835cdf + e10369b commit cb02e75

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ would export something like this as `CARDDAV_ENDPOINT`:
3333
export CARDDAV_ENDPOINT='https://my.baik.al/dav.php/'
3434
```
3535

36+
If you're using iCloud for example, you would eport something like this as `CARDDAV_ENDPOINT`:
37+
38+
```sh
39+
export CARDDAV_ENDPOINT='https://contacts.icloud.com/<DSID>/carddavhome/card/'
40+
```
41+
3642
The `ADDRB_DB` is the local contacts database in order to not need to contact
3743
the CardDAV for every lookup. You might set it to something like this:
3844

dav/dav.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dav
33
import (
44
"context"
55
"fmt"
6+
"strings"
67

78
"github.com/emersion/go-vcard"
89
"github.com/emersion/go-webdav"
@@ -41,14 +42,18 @@ func New(endpoint, username, password string) (*DAV, error) {
4142
return nil, err
4243
}
4344

44-
dav.addrbookHomeSet, err =
45-
dav.cdClient.FindAddressBookHomeSet(
46-
context.Background(),
47-
fmt.Sprintf("principals/%s",
48-
dav.username,
49-
))
50-
if err != nil {
51-
return dav, err
45+
if strings.HasSuffix(dav.endpoint, ".icloud.com") {
46+
dav.addrbookHomeSet = dav.endpoint
47+
} else {
48+
dav.addrbookHomeSet, err =
49+
dav.cdClient.FindAddressBookHomeSet(
50+
context.Background(),
51+
fmt.Sprintf("principals/%s",
52+
dav.username,
53+
))
54+
if err != nil {
55+
return dav, err
56+
}
5257
}
5358

5459
dav.addrbooks, err =

0 commit comments

Comments
 (0)