Documentation
¶
Overview ¶
Package contact is for managing the io.cozy.contacts documents and their groups.
Index ¶
- Constants
- Variables
- type Contact
- func Create(db prefixer.Prefixer, opts CreateOptions) (*Contact, error)
- func CreateMyself(inst *instance.Instance, settings *couchdb.JSONDoc) (*Contact, error)
- func Find(db prefixer.Prefixer, contactID string) (*Contact, error)
- func FindAllByEmail(db prefixer.Prefixer, email 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) IsExternal() bool
- func (c *Contact) IsTrusted() bool
- func (c *Contact) MarkAsTrusted(inst *instance.Instance) error
- 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 CreateOptions
- type Group
Constants ¶
const TrustedForSharingKey = "trustedForSharing"
TrustedForSharingKey is the key used to mark a contact as trusted for auto-accepting sharings
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 Create ¶
func Create(db prefixer.Prefixer, opts CreateOptions) (*Contact, error)
Create creates a contact from the provided options.
func CreateMyself ¶
CreateMyself creates the myself contact document from the instance settings.
func FindAllByEmail ¶
FindAllByEmail returns all contacts with the given email address, when possible.
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) IsExternal ¶
IsExternal returns true if this contact was created from an external source.
func (*Contact) IsTrusted ¶
IsTrusted returns true if this contact has been marked as trusted for auto-accepting sharings
func (*Contact) MarkAsTrusted ¶
MarkAsTrusted marks this contact as trusted for auto-accepting sharings
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.
type CreateOptions ¶
type CreateOptions struct {
Email string
Name string
CozyURL string
Phone string
External bool
TrustedForSharing bool
}
CreateOptions describes the input used to create a contact.