carddav: add AddressObject.Remove

This commit is contained in:
emersion 2017-09-14 11:52:19 +02:00
parent e8ff91c542
commit 38f6f04e75
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 12 additions and 0 deletions

View File

@ -170,6 +170,18 @@ func (ao *addressObject) SetCard(card vcard.Card) error {
return nil return nil
} }
func (ao *addressObject) Remove() error {
resps, err := ao.ab.c.DeleteContacts([]string{ao.contact.ID})
if err != nil {
return err
}
if len(resps) != 1 {
return errors.New("hydroxide/carddav: expected exactly one response when deleting contact")
}
resp := resps[0]
return resp.Err()
}
type addressBook struct { type addressBook struct {
c *protonmail.Client c *protonmail.Client
cache map[string]*addressObject cache map[string]*addressObject