contact

package
v0.0.0-...-4b98c26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

type Contact struct {
	couchdb.JSONDoc
}

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

func CreateMyself(db couchdb.Database, settings *couchdb.JSONDoc) (*Contact, error)

CreateMyself creates the myself contact document from the instance settings.

func Find

func Find(db prefixer.Prefixer, contactID string) (*Contact, error)

Find returns the contact stored in database from a given ID

func FindByEmail

func FindByEmail(db couchdb.Database, email string) (*Contact, error)

FindByEmail returns the contact with the given email address, when possible

func GetMyself

func GetMyself(db couchdb.Database) (*Contact, error)

GetMyself returns the myself contact document, or an ErrNotFound error.

func New

func New() *Contact

New returns a new blank contact.

func (*Contact) AddCozyURL

func (c *Contact) AddCozyURL(db prefixer.Prefixer, cozyURL string) error

AddCozyURL adds a cozy URL to this contact (unless the contact has already this cozy URL) and saves the contact.

func (*Contact) ChangeCozyURL

func (c *Contact) ChangeCozyURL(db prefixer.Prefixer, cozyURL string) error

ChangeCozyURL is used when a contact has moved their Cozy to a new URL.

func (*Contact) DocType

func (c *Contact) DocType() string

DocType returns the contact document type

func (*Contact) PrimaryCozyURL

func (c *Contact) PrimaryCozyURL() string

PrimaryCozyURL returns the URL of the primary cozy, or a blank string if the contact has no known cozy.

func (*Contact) PrimaryName

func (c *Contact) PrimaryName() string

PrimaryName returns the name of the contact

func (*Contact) PrimaryPhoneNumber

func (c *Contact) PrimaryPhoneNumber() string

PrimaryPhoneNumber returns the preferred phone number, or a blank string if the contact has no known phone number.

func (*Contact) ToMailAddress

func (c *Contact) ToMailAddress() (*mail.Address, error)

ToMailAddress returns a struct that can be used by cozy-stack to send an email to this contact

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL