history

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package history provides ticket history formatting and display utilities.

Package history provides ticket history recording and formatting utilities.

Index

Constants

View Source
const (
	TypeNewTicket      = "NewTicket"
	TypeOwnerUpdate    = "OwnerUpdate"
	TypeStateUpdate    = "StateUpdate"
	TypeAddNote        = "AddNote"
	TypePriorityUpdate = "PriorityUpdate"
	TypeQueueMove      = "Move"
	TypeSetPendingTime = "SetPendingTime"
	TypeMerged         = "Merged"
	TypeTimeAccounting = "TimeAccounting"
)

HistoryType constants for common ticket history events.

Variables

This section is empty.

Functions

func ChangeMessage

func ChangeMessage(field, oldVal, newVal string) string

ChangeMessage generates a history message for a field change.

func Excerpt

func Excerpt(s string, maxLen int) string

Excerpt returns a truncated version of the input string, suitable for history messages.

func NormalizeHistoryName

func NormalizeHistoryName(entry models.TicketHistoryEntry) string

NormalizeHistoryName converts the raw ticket_history.name field into a human readable label. OTRS stores structured payloads using double-percent (%%) delimiters; when those appear we decode the payload based on the reported history type and fall back to a reasonable string otherwise. This allows imported tickets to render meaningful events.

Types

type HistoryInserter

type HistoryInserter interface {
	AddTicketHistoryEntry(ctx context.Context, exec interface{}, entry models.TicketHistoryInsert) error
}

HistoryInserter is an interface for inserting ticket history entries.

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder records ticket history entries.

func NewRecorder

func NewRecorder(repo interface{}) *Recorder

NewRecorder creates a new history recorder with the given repository. The repository should implement AddTicketHistoryEntry method. Returns nil if repo is nil.

func (*Recorder) Record

func (r *Recorder) Record(ctx context.Context, tx interface{}, ticket interface{}, articleID interface{}, historyType string, message string, userID int) error

Record records a history entry for a ticket. The tx parameter can be nil to use the default database connection. ticket can be either a *models.Ticket or an int (ticket ID). articleID is optional and can be nil (accepts *int or *uint).

func (*Recorder) RecordByTicketID

func (r *Recorder) RecordByTicketID(ctx context.Context, tx interface{}, ticketID int, articleID interface{}, historyType string, message string, userID int) error

RecordByTicketID records a history entry using a ticket ID directly. This is a convenience method when you only have a ticket ID.

type TicketGetter

type TicketGetter interface {
	GetByID(id uint) (*models.Ticket, error)
}

TicketGetter is an interface for getting ticket data needed for history snapshots.

Jump to

Keyboard shortcuts

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