recipient

package
v0.0.0-...-fb1264c Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	ID        int64  `db:"id"`
	ContactID int64  `db:"contact_id"`
	Type      string `db:"type"`
	Address   string `db:"address"`
}

func (*Address) TableName

func (a *Address) TableName() string

type Contact

type Contact struct {
	ID               int64          `db:"id"`
	FullName         string         `db:"full_name"`
	Username         sql.NullString `db:"username"`
	DefaultChannelID int64          `db:"default_channel_id"`
	Addresses        []*Address     `db:"-"`
}

func (*Contact) GetContactsAt

func (c *Contact) GetContactsAt(t time.Time) []*Contact

func (*Contact) MarshalLogObject

func (c *Contact) MarshalLogObject(encoder zapcore.ObjectEncoder) error

MarshalLogObject implements the zapcore.ObjectMarshaler interface.

func (*Contact) String

func (c *Contact) String() string

type Group

type Group struct {
	ID        int64      `db:"id"`
	Name      string     `db:"name"`
	Members   []*Contact `db:"-"`
	MemberIDs []int64    `db:"-"`
}

func (*Group) GetContactsAt

func (g *Group) GetContactsAt(t time.Time) []*Contact

func (*Group) MarshalLogObject

func (g *Group) MarshalLogObject(encoder zapcore.ObjectEncoder) error

MarshalLogObject implements the zapcore.ObjectMarshaler interface.

func (*Group) String

func (g *Group) String() string

func (*Group) TableName

func (g *Group) TableName() string

type Key

type Key struct {
	// Only one of the members is allowed to be a non-zero value.
	ContactID  types.Int `db:"contact_id"`
	GroupID    types.Int `db:"contactgroup_id"`
	ScheduleID types.Int `db:"schedule_id"`
}

func ToKey

func ToKey(r Recipient) Key

func (Key) MarshalLogObject

func (r Key) MarshalLogObject(encoder zapcore.ObjectEncoder) error

MarshalLogObject implements the zapcore.ObjectMarshaler interface.

This allows us to use `zap.Inline(Key)` or `zap.Object("recipient", Key)` wherever fine-grained logging context is needed, without having to add all the individual fields ourselves each time. https://pkg.go.dev/go.uber.org/zap/zapcore#ObjectMarshaler

func (Key) MarshalText

func (r Key) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface to allow JSON marshaling of map[Key]T.

type Recipient

type Recipient interface {
	fmt.Stringer
	zapcore.ObjectMarshaler

	GetContactsAt(t time.Time) []*Contact
}

type Rotation

type Rotation struct {
	ID            int64             `db:"id"`
	ScheduleID    int64             `db:"schedule_id"`
	ActualHandoff types.UnixMilli   `db:"actual_handoff"`
	Priority      int32             `db:"priority"`
	Name          string            `db:"name"`
	Members       []*RotationMember `db:"-"`
}

func (*Rotation) MarshalLogObject

func (r *Rotation) MarshalLogObject(encoder zapcore.ObjectEncoder) error

MarshalLogObject implements the zapcore.ObjectMarshaler interface.

type RotationMember

type RotationMember struct {
	ID                int64                       `db:"id"`
	RotationID        int64                       `db:"rotation_id"`
	Contact           *Contact                    `db:"-"`
	ContactID         sql.NullInt64               `db:"contact_id"`
	ContactGroup      *Group                      `db:"-"`
	ContactGroupID    sql.NullInt64               `db:"contactgroup_id"`
	TimePeriodEntries map[int64]*timeperiod.Entry `db:"-"`
}

func (*RotationMember) MarshalLogObject

func (r *RotationMember) MarshalLogObject(encoder zapcore.ObjectEncoder) error

type Schedule

type Schedule struct {
	ID   int64  `db:"id"`
	Name string `db:"name"`

	Rotations []*Rotation `db:"-"`
	// contains filtered or unexported fields
}

func (*Schedule) GetContactsAt

func (s *Schedule) GetContactsAt(t time.Time) []*Contact

GetContactsAt returns the contacts that are active in the schedule at the given time.

func (*Schedule) MarshalLogObject

func (s *Schedule) MarshalLogObject(encoder zapcore.ObjectEncoder) error

MarshalLogObject implements the zapcore.ObjectMarshaler interface.

func (*Schedule) RefreshRotations

func (s *Schedule) RefreshRotations()

RefreshRotations updates the internally cached rotations.

This must be called after the Rotations member was updated for the change to become active.

func (*Schedule) String

func (s *Schedule) String() string

Jump to

Keyboard shortcuts

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