Documentation
¶
Overview ¶
Package native implements the ticket package's v2 routes in the package itself, on the kernel's v2_ticket and v2_ticket_message tables adopted in place (kernel.storage.adopt). Legacy handlers and native routes share the tables, so a route can switch between them at any time. Responses are byte-compatible with the legacy handlers (internal/tests/ticketcompat).
Index ¶
- type Message
- type Service
- func (s *Service) AdminClose(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
- func (s *Service) AdminList(ctx context.Context, _ pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
- func (s *Service) AdminReply(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
- func (s *Service) Handlers() map[string]pluginhostsdk.NativeHandler
- func (s *Service) UserClose(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
- func (s *Service) UserCreate(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
- func (s *Service) UserGet(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
- func (s *Service) UserList(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
- func (s *Service) UserReply(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
- type Ticket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct {
ID uint `gorm:"primaryKey" json:"id"`
TicketID uint `gorm:"index" json:"ticket_id"`
UserID uint `gorm:"index" json:"user_id"`
Message string `gorm:"type:text" json:"message"`
IsAdmin int `gorm:"default:0" json:"is_admin"`
CreatedAt time.Time `json:"created_at"`
}
Message is a v2_ticket_message row.
type Service ¶
type Service struct {
// Open returns the package's storage connection, on which the adopted
// tables are visible.
Open func(ctx context.Context) (*gorm.DB, error)
// Now defaults to time.Now.
Now func() time.Time
}
Service holds what the native routes need.
func (*Service) AdminClose ¶
func (s *Service) AdminClose(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
AdminClose is POST /api/v2/admin/ticket/:id/close.
func (*Service) AdminList ¶
func (s *Service) AdminList(ctx context.Context, _ pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
AdminList is GET /api/v2/admin/ticket.
func (*Service) AdminReply ¶
func (s *Service) AdminReply(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
AdminReply is POST /api/v2/admin/ticket/reply.
func (*Service) Handlers ¶
func (s *Service) Handlers() map[string]pluginhostsdk.NativeHandler
Handlers returns the native handlers by route id.
func (*Service) UserClose ¶
func (s *Service) UserClose(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
UserClose is POST /api/v2/user/ticket/:id/close.
func (*Service) UserCreate ¶
func (s *Service) UserCreate(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
UserCreate is POST /api/v2/user/ticket: a ticket with its first message.
func (*Service) UserGet ¶
func (s *Service) UserGet(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
UserGet is GET /api/v2/user/ticket/:id: one of the caller's tickets with its messages.
func (*Service) UserList ¶
func (s *Service) UserList(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
UserList is GET /api/v2/user/ticket: the caller's tickets.
func (*Service) UserReply ¶
func (s *Service) UserReply(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)
UserReply is POST /api/v2/user/ticket/:id/reply: it reopens the ticket.
type Ticket ¶
type Ticket struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
Subject string `gorm:"size:255" json:"subject"`
Level int `gorm:"default:1" json:"level"`
Status int `gorm:"default:0" json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Messages []Message `gorm:"foreignKey:TicketID" json:"messages,omitempty"`
}
Ticket is a v2_ticket row. Its JSON matches the kernel model, which the create and detail answers return as is (the kernel's User relation is never loaded there, so it is omitted).