models

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: AGPL-3.0, AGPL-3.0-or-later Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NilMsgID MsgID = 0

	MsgOriginFlow      MsgOrigin = "flow"
	MsgOriginBroadcast MsgOrigin = "broadcast"
	MsgOriginTicket    MsgOrigin = "ticket"
	MsgOriginChat      MsgOrigin = "chat"

	DirectionIn  MsgDirection = "I"
	DirectionOut MsgDirection = "O"
)
View Source
const NilBroadcastID = BroadcastID(0)
View Source
const NilFlowID = FlowID(0)
View Source
const NilTicketID = TicketID(0)
View Source
const NilUserID = UserID(0)

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastID

type BroadcastID int64

type Channel

type Channel struct {
	ID     ChannelID      `json:"id"`
	UUID   ChannelUUID    `json:"uuid"`
	OrgID  OrgID          `json:"org_id"`
	Config map[string]any `json:"config"`
}

func LoadChannel

func LoadChannel(ctx context.Context, rt *runtime.Runtime, uuid ChannelUUID) (*Channel, error)

func (*Channel) Secret

func (c *Channel) Secret() string

type ChannelID

type ChannelID int64

type ChannelUUID

type ChannelUUID uuids.UUID

type ChatID

type ChatID string

func NewChatID

func NewChatID() ChatID

type Contact

type Contact struct {
	ID     ContactID `json:"id"`
	OrgID  OrgID     `json:"org_id"`
	URNID  URNID     `json:"urn_id"`
	ChatID ChatID    `json:"chat_id"`
	Email  string    `json:"email"`
}

func LoadContact

func LoadContact(ctx context.Context, rt *runtime.Runtime, orgID OrgID, chatID ChatID) (*Contact, error)

func (*Contact) UpdateEmail

func (c *Contact) UpdateEmail(ctx context.Context, rt *runtime.Runtime, email string) error

type ContactID

type ContactID int64

type DBMsg

type DBMsg struct {
	ID          MsgID        `json:"id"`
	Text        string       `json:"text"`
	Attachments []string     `json:"attachments"`
	Direction   MsgDirection `json:"direction"`
	BroadcastID BroadcastID  `json:"broadcast_id"`
	FlowID      FlowID       `json:"flow_id"`
	TicketID    TicketID     `json:"ticket_id"`
	CreatedByID UserID       `json:"created_by_id"`
	CreatedOn   time.Time    `json:"created_on"`
}

func LoadContactMessages

func LoadContactMessages(ctx context.Context, rt *runtime.Runtime, contactID ContactID, before time.Time, limit int) ([]*DBMsg, error)

func (*DBMsg) ToMsgIn

func (m *DBMsg) ToMsgIn() *MsgIn

func (*DBMsg) ToMsgOut

func (m *DBMsg) ToMsgOut(ctx context.Context, store Store) (*MsgOut, error)

type FlowID

type FlowID int64

type MsgDirection

type MsgDirection string

type MsgID

type MsgID int64

type MsgIn

type MsgIn struct {
	ID   MsgID     `json:"id"`
	Text string    `json:"text"`
	Time time.Time `json:"time"`
}

func NewMsgIn

func NewMsgIn(id MsgID, text string, t time.Time) *MsgIn

type MsgOrigin

type MsgOrigin string

type MsgOut

type MsgOut struct {
	ID          MsgID     `json:"id"`
	Text        string    `json:"text"`
	Attachments []string  `json:"attachments,omitempty"`
	Origin      MsgOrigin `json:"origin"`
	User        *User     `json:"user,omitempty"`
	Time        time.Time `json:"time"`
}

func NewMsgOut

func NewMsgOut(id MsgID, text string, attachments []string, origin MsgOrigin, user *User, t time.Time) *MsgOut

type OrgID

type OrgID int64

type Store

type Store interface {
	Start()
	Stop()
	GetChannel(context.Context, ChannelUUID) (*Channel, error)
	GetUser(context.Context, UserID) (*User, error)
}

func NewStore

func NewStore(rt *runtime.Runtime) Store

type TicketID

type TicketID int64

type URNID

type URNID int64

type User

type User struct {
	ID     UserID `json:"id"`
	Email  string `json:"email"`
	Name   string `json:"name"`
	Avatar string `json:"avatar,omitempty"`
}

func LoadUser

func LoadUser(ctx context.Context, rt *runtime.Runtime, id UserID) (*User, error)

type UserID

type UserID null.Int

Jump to

Keyboard shortcuts

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