schema

package
v0.0.0-...-4471eec Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserAlreadyExist = errors.New("User already exist")
	ErrUserNotExist     = errors.New("User does not exist")
	ErrUserNotValid     = errors.New("User is not valid")
)

Errors

Functions

This section is empty.

Types

type Conversation

type Conversation struct {
	ID        bson.ObjectId `bson:"_id,omitempty"`
	CreatorID bson.ObjectId `bson:"creator_id"`
	Title     string        `bson:"title"`
	Purpose   string        `bson:"purpose"`
	Topic     string        `bson:"topic"`

	Namespace struct {
		ID        bson.ObjectId `bson:"id"`
		Path      string        `bson:"path"`
		OwnerID   bson.ObjectId `bson:"owner_id"`
		OwnerType OwnerType     `bson:"owner_type"`
	} `bson:"namespace"`

	ConversationType ConversationType `bson:"conversation_type"`
	Privacy          Privacy          `bson:"privacy,ommitempty"`

	Avatar struct {
		FileSize         int    `bson:"file_size"`
		OriginalFilename string `bson:"original_filename"`
		ContenType       string `bson:"content_type"`
		Md5              string `bson:"md5"`
		Sha256           string `bson:"sha256"`
	}

	Retention struct {
		Mode  RetentionMode `bson:"mode"`
		Value int           `bson:"value,omitempty"`
	} `bson:"retention,omitempty"`

	MessagesCount     int `bson:"messages_count"`
	ParticipantsCount int `bson:"participants_count"`

	LastActiveAt time.Time `bson:"last_active_at"`
	Archived     bool      `bson:"archived"`
	ArchivedAt   time.Time `bson:"archived_at"`
	CreatedAt    time.Time `bson:"created_at"`
	UpdatedAt    time.Time `bson:"updated_at"`

	LastMessage struct {
		ContentHTML      string
		ContentPlainText string

		From struct {
			UserID bson.ObjectId
			Name   string
		} `bson:"from"`

		CreatedAt time.Time `bson:"created_at"`
		UpdatedAt time.Time `bson:"updated_at"`
	} `bson:"last_message,omitempty"`

	Errors Errors `bson:"-"`
}

Conversation represents a conversation within a namespace. Conversastions can be 1-on-1, group, or channel.

func NewConversation

func NewConversation() *Conversation

NewConversation creates a new instance of a Conversation

func (*Conversation) IsArchived

func (c *Conversation) IsArchived() bool

IsArchived is a helper method that returns if the conversation has been archived

type ConversationType

type ConversationType int

ConversationType represents the one of the 3 modes of conversation supported: private (aka 1-on-1s), group, and channels (aka. Rooms)

const (
	ConversationTypePrivate ConversationType = iota
	ConversationTypeGroup
	ConversationTypeChannel
)

Conversation Types

func (ConversationType) MarshalJSON

func (r ConversationType) MarshalJSON() ([]byte, error)

MarshalJSON is generated so ConversationType satisfies json.Marshaler.

func (ConversationType) String

func (t ConversationType) String() string

func (*ConversationType) UnmarshalJSON

func (r *ConversationType) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so ConversationType satisfies json.Unmarshaler.

type Device

type Device struct {
	Id        bson.ObjectId `json:"id" bson:"_id,omitempty"`
	UserId    bson.ObjectId `json:"user_id" bson:"user_id,omitempty"`
	CreatedAt time.Time     `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time     `json:"updated_at" bson:"updated_at"`
	Errors    Errors        `json:"-" bson:"-"`
}

type EmailAddress

type EmailAddress struct {
	Email       string    `json:"email" bson:"email"`
	IsConfirmed bool      `json:"confirmed" bson:"confirmed"`
	ConfirmedAt time.Time `json:"confirmed_at" bson:"confirmed_at"`
	DeletedAt   time.Time `json:"deleted_at" bson:"deleted_at"`
}

EmailAddress is the list of all email addresses of a user. Can contain the primary email address, but is not obligatory

type Errors

type Errors struct {
	Messages map[string]string
}

func NewErrors

func NewErrors() *Errors

func (*Errors) Add

func (errors *Errors) Add(field string, message string)

func (*Errors) Clear

func (errors *Errors) Clear()

func (*Errors) HasMessages

func (errors *Errors) HasMessages() bool

type Integration

type Integration struct {
	Id        bson.ObjectId `json:"id" bson:"_id,omitempty"`
	Name      string        `json:"name" bson:"name"`
	CreatedAt time.Time     `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time     `json:"updated_at" bson:"updated_at"`
	Errors    Errors        `json:"-" bson:"-"`
}

type Member

type Member struct {
	ID               bson.ObjectId `bson:"_id,omitempty"`
	UserID           bson.ObjectId `bson:"user_id"`
	OrganizationID   bson.ObjectId `bson:"org_id"`
	State            string        `bson:"state"`
	Published        bool          `bson:"published"`
	Role             MemberRole    `bson:"role"`
	InvitedBy        bson.ObjectId `bson:"invited_by,omitempty"`
	InviteEmail      string        `bson:"invite_email,omitempty"`
	InviteToken      string        `bson:"invite_token,omitempty"`
	InviteSentAt     time.Time     `bson:"invite_sent_at,omitempty"`
	InviteAcceptedAt time.Time     `bson:"invite_accepted_at,omitempty"`
	CreatedAt        time.Time     `bson:"created_at"`
	UpdatedAt        time.Time     `bson:"updated_at"`

	Errors Errors `json:"-" bson:"-"`
}

Member represents an organization membership for a user

func (*Member) IsActive

func (m *Member) IsActive() bool

IsActive returns if the organization membership state is active

func (*Member) IsGuest

func (m *Member) IsGuest() bool

IsGuest returns if the user is part of the Guest member role group

func (*Member) IsMember

func (m *Member) IsMember() bool

IsMember returns if the user is part of the Member role group

func (*Member) IsOwner

func (m *Member) IsOwner() bool

IsOwner retusn if the user is part of the Owners role group

func (*Member) IsPending

func (m *Member) IsPending() bool

IsPending returns if the organization membership state is pending

func (*Member) IsPrivate

func (m *Member) IsPrivate() bool

IsPrivate returns if the organization membership visibility is concealed

func (*Member) IsPublished

func (m *Member) IsPublished() bool

IsPublished returns if the organization membership visibility is public

type MemberRole

type MemberRole int

MemberRole describes the Membership role

const (
	MemberRoleOwner MemberRole = iota
	MemberRoleMember
	MemberRoleGuest
)

Member roles

func (MemberRole) String

func (m MemberRole) String() string

type Message

type Message struct {
	Id bson.ObjectId `bson:"_id,omitempty"`

	ContentHTML      string
	ContentPlainText string

	From struct {
		UserID bson.ObjectId
		Name   string
	} `bson:"from"`

	CreatedAt time.Time `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time `json:"updated_at" bson:"updated_at"`
	Errors    Errors    `bson:"-"`
}

type Namespace

type Namespace struct {
	Errors Errors `bson:"-"`

	ID        bson.ObjectId `bson:"_id"`
	Path      string        `bson:"path"`
	OwnerID   bson.ObjectId `bson:"owner_id,omitempty"`
	OwnerType OwnerType     `bson:"owner_type"`
	CreatedAt time.Time     `bson:"created_at"`
	UpdatedAt time.Time     `bson:"updated_at"`
}

Namespace represents the slug path for a User or Organization

func (*Namespace) BelongsToOrganization

func (n *Namespace) BelongsToOrganization() bool

BelongsToOrganization returns true if the naemspace owner is an organization

func (*Namespace) BelongsToUser

func (n *Namespace) BelongsToUser() bool

BelongsToUser returns true if the naemspace owner is a user

func (*Namespace) Slug

func (n *Namespace) Slug() string

Slug returns the URL friendly path for the organization

type Organization

type Organization struct {
	ID bson.ObjectId `bson:"_id"`

	Namespace struct {
		ID        bson.ObjectId `bson:"id"`
		Path      string        `bson:"path"`
		OwnerType OwnerType     `bson:"owner_type"`
	} `bson:"namespace"`

	Name         string    `bson:"name"`
	Description  string    `bson:"description"`
	URL          string    `bson:"url"`
	Location     string    `bson:"location"`
	Email        string    `bson:"email"`
	BillingEmail string    `bson:"billing_email"`
	CreatedAt    time.Time `bson:"created_at"`
	UpdatedAt    time.Time `bson:"updated_at"`
	Errors       Errors    `bson:"-"`
}

Organization represents the an organization, team, group or company in the system

type OwnerType

type OwnerType int

OwnerType represents the type of namespace owner

const (
	OwnerTypeUser OwnerType = iota
	OwnerTypeOrganization
)

Owner types

func (OwnerType) MarshalJSON

func (t OwnerType) MarshalJSON() ([]byte, error)

MarshalJSON turns a OwnerType into a json.Marshaller.

func (OwnerType) String

func (t OwnerType) String() string

type Privacy

type Privacy int

Privacy represents the type of privacy and security a conversation has

const (
	PrivacyPersonal Privacy = iota
	PrivacyPublic
	PrivacyPrivate
	PrivacyProtected
	PrivacySecret
)

Privacy modes

func (Privacy) MarshalJSON

func (r Privacy) MarshalJSON() ([]byte, error)

MarshalJSON is generated so Privacy satisfies json.Marshaler.

func (Privacy) String

func (p Privacy) String() string

func (*Privacy) UnmarshalJSON

func (r *Privacy) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so Privacy satisfies json.Unmarshaler.

type RetentionMode

type RetentionMode int

RetentionMode describes the type of rentention policy for messages in a conversation

const (
	RetentionModeAll RetentionMode = iota
	RetentionModeNone
	RetentionModeAge
	RetentionModeDays
)

Retention modes

func (RetentionMode) MarshalJSON

func (r RetentionMode) MarshalJSON() ([]byte, error)

MarshalJSON is generated so RetentionMode satisfies json.Marshaler.

func (RetentionMode) String

func (m RetentionMode) String() string

func (*RetentionMode) UnmarshalJSON

func (r *RetentionMode) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so RetentionMode satisfies json.Unmarshaler.

type User

type User struct {
	ID bson.ObjectId `json:"id" bson:"_id,omitempty"`

	Namespace struct {
		ID        bson.ObjectId `bson:"id"`
		Path      string        `bson:"path"`
		OwnerType OwnerType     `bson:"owner_type"`
	} `bson:"namespace"`

	Username       string `json:"username" bson:"username"`
	GivenName      string `json:"given_name,omitempty" bson:"given_name,omitempty"`
	FamilyName     string `json:"family_name,omitempty" bson:"family_name,omitempty"`
	HashedPassword string `json:"-" bson:"hashed_password"`

	Emails    []EmailAddress `json:"emails" bson:"emails"`
	CreatedAt time.Time      `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time      `json:"updated_at" bson:"updated_at"`
	Errors    Errors         `json:"-" bson:"-"`
	// contains filtered or unexported fields
}

User represents the object of individual and member of organization.

func (*User) AbbreviatedName

func (u *User) AbbreviatedName() string

AbbreviatedName returns the abbreviated name for the user

func (*User) AddEmailAddress

func (u *User) AddEmailAddress(email string)

AddEmailAddress adds a new email address to the user's account

func (*User) FullName

func (u *User) FullName() string

FullName returns the full user's name

func (*User) GetPrimaryEmail

func (u *User) GetPrimaryEmail() string

GetPrimaryEmail returns the user's primary email address

func (*User) HasEmailAddress

func (u *User) HasEmailAddress(email string) bool

HasEmailAddress returns true if the user has the provided email address registered already

func (*User) ListOfEmails

func (u *User) ListOfEmails() []string

ListOfEmails returns the list of email address that the user have registered in the system

func (*User) RemoveEmailAddress

func (u *User) RemoveEmailAddress(email string)

RemoveEmailAddress removes the email address from the user's account

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword updates the password for the user

func (*User) SetPrimaryEmail

func (u *User) SetPrimaryEmail(email string)

SetPrimaryEmail sets the provided email address as the primary email for the account

func (*User) ValidatePassword

func (u *User) ValidatePassword(password string) (bool, error)

ValidatePassword verifies if the provided password matches the one in the database

Jump to

Keyboard shortcuts

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