native

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 9 Imported by: 0

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

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.

func (Message) TableName

func (Message) TableName() string

TableName is the adopted kernel table.

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

AdminClose is POST /api/v2/admin/ticket/:id/close.

func (*Service) AdminList

AdminList is GET /api/v2/admin/ticket.

func (*Service) AdminReply

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

UserClose is POST /api/v2/user/ticket/:id/close.

func (*Service) UserCreate

UserCreate is POST /api/v2/user/ticket: a ticket with its first message.

func (*Service) UserGet

UserGet is GET /api/v2/user/ticket/:id: one of the caller's tickets with its messages.

func (*Service) UserList

UserList is GET /api/v2/user/ticket: the caller's tickets.

func (*Service) UserReply

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).

func (Ticket) TableName

func (Ticket) TableName() string

TableName is the adopted kernel table.

Jump to

Keyboard shortcuts

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