Documentation ¶
Overview ¶
Package contact is for managing the io.cozy.contacts documents and their groups.
Index ¶
- Variables
- type Contact
- func CreateMyself(inst *instance.Instance, settings *couchdb.JSONDoc) (*Contact, error)
- func Find(db prefixer.Prefixer, contactID string) (*Contact, error)
- func FindByEmail(db prefixer.Prefixer, email string) (*Contact, error)
- func GetMyself(db prefixer.Prefixer) (*Contact, error)
- func New() *Contact
- func (c *Contact) AddCozyURL(db prefixer.Prefixer, cozyURL string) error
- func (c *Contact) AddNameIfMissing(db prefixer.Prefixer, name, email string) error
- func (c *Contact) ChangeCozyURL(db prefixer.Prefixer, cozyURL string) error
- func (c *Contact) DocType() string
- func (c *Contact) GroupIDs() []string
- func (c *Contact) PrimaryCozyURL() string
- func (c *Contact) PrimaryName() string
- func (c *Contact) PrimaryPhoneNumber() string
- func (c *Contact) SortingKey() string
- func (c *Contact) ToMailAddress() (*mail.Address, error)
- type Group
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoMailAddress is returned when trying to access the email address of // a contact that has no known email address. ErrNoMailAddress = errors.New("The contact has no email address") // ErrNotFound is returned when no contact has been found for a query ErrNotFound = errors.New("No contact has been found") )
Functions ¶
This section is empty.
Types ¶
type Contact ¶
Contact is a struct containing all the informations about a contact. We are using maps/slices/interfaces instead of structs, as it is a doctype that can also be used in front applications and they can add new fields. It would be complicated to maintain a up-to-date mapping, and failing to do so means that we can lose some data on JSON round-trip.
func CreateMyself ¶
CreateMyself creates the myself contact document from the instance settings.
func FindByEmail ¶
FindByEmail returns the contact with the given email address, when possible
func (*Contact) AddCozyURL ¶
AddCozyURL adds a cozy URL to this contact (unless the contact has already this cozy URL) and saves the contact.
func (*Contact) AddNameIfMissing ¶
AddNameIfMissing can be used to add a name if there was none. We need the email address to ignore it if the displayName was updated with it by a service of the contacts application.
func (*Contact) ChangeCozyURL ¶
ChangeCozyURL is used when a contact has moved their Cozy to a new URL.
func (*Contact) GroupIDs ¶
GroupIDs returns the list of the group identifiers that this contact belongs to.
func (*Contact) PrimaryCozyURL ¶
PrimaryCozyURL returns the URL of the primary cozy, or a blank string if the contact has no known cozy.
func (*Contact) PrimaryName ¶
PrimaryName returns the name of the contact
func (*Contact) PrimaryPhoneNumber ¶
PrimaryPhoneNumber returns the preferred phone number, or a blank string if the contact has no known phone number.
func (*Contact) SortingKey ¶
SortingKey returns a string that can be used for sorting the contacts like in the contacts app.