ticket

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigChannelName            string = "ticket-{{USER}}-{{ID}}"
	DefaultConfigShortChannelName       string = "t-{{USER}}-{{ID}}"
	DefaultConfigCategorizedChannelName string = "{{USER}}-{{ID}}"

	DefaultConfigEnabled       bool = false
	DefaultConfigAllowMultiple bool = true

	TicketSlugLength   int    = 8
	TicketSlugAlphabet string = "0123456789abcdefghijklmnopqrstuvwxyz"
)

Variables

View Source
var (
	ErrInvalidChannelId = errors.Unexpected("ticket: channelId is not a valid int64")
	ErrInvalidUserId    = errors.Unexpected("ticket: userId is not a valid int64")
	ErrInvalidGuildId   = errors.Unexpected("ticket: guildId is not a valid int64")

	ErrInvalidSlug = errors.Unexpected("ticket: the slug is invalid")
)

Functions

This section is empty.

Types

type PgTicketConfigRepository

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

func NewPgTicketConfigRepository

func NewPgTicketConfigRepository(db *sql.DB) *PgTicketConfigRepository

func (*PgTicketConfigRepository) Create

Create implements TicketConfigRepository.

func (*PgTicketConfigRepository) CreateDefault

func (r *PgTicketConfigRepository) CreateDefault(guildId string) (*TicketConfig, error)

CreateDefault implements TicketConfigRepository.

func (*PgTicketConfigRepository) GetByGuildId

func (r *PgTicketConfigRepository) GetByGuildId(guildId string) (*TicketConfig, error)

GetByGuildId implements TicketConfigRepository.

func (*PgTicketConfigRepository) UpdateAllowMultiple

func (r *PgTicketConfigRepository) UpdateAllowMultiple(guildId string, allowMultiple bool) error

UpdateAllowMultiple implements TicketConfigRepository.

func (*PgTicketConfigRepository) UpdateChannelCategory

func (r *PgTicketConfigRepository) UpdateChannelCategory(guildId string, channelCategoryId string) error

UpdateChannelCategory implements TicketConfigRepository.

func (*PgTicketConfigRepository) UpdateChannelName

func (r *PgTicketConfigRepository) UpdateChannelName(guildId string, channelName string) error

UpdateChannelName implements TicketConfigRepository.

func (*PgTicketConfigRepository) UpdateEnabled

func (r *PgTicketConfigRepository) UpdateEnabled(guildId string, enabled bool) error

UpdateEnabled implements TicketConfigRepository.

func (*PgTicketConfigRepository) UpdateLogsChannel

func (r *PgTicketConfigRepository) UpdateLogsChannel(guildId string, logsChannelId string) error

UpdateLogsChannel implements TicketConfigRepository.

type PgTicketRepository

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

func NewPgTicketRepository

func NewPgTicketRepository(db *sql.DB) *PgTicketRepository

func (*PgTicketRepository) Create

func (r *PgTicketRepository) Create(slug, channelId, userId, guildId string) (*Ticket, error)

Create implements TicketRepository.

func (*PgTicketRepository) DeleteByChannelId

func (r *PgTicketRepository) DeleteByChannelId(channelId string) (*Ticket, error)

DeleteByChannelId implements TicketRepository.

func (*PgTicketRepository) DeleteByMember

func (r *PgTicketRepository) DeleteByMember(guildId, userId string) ([]Ticket, error)

DeleteByMember implements TicketRepository.

func (*PgTicketRepository) DeleteBySlug

func (r *PgTicketRepository) DeleteBySlug(slug string) (*Ticket, error)

DeleteBySlug implements TicketRepository.

func (*PgTicketRepository) GenerateSlug

func (r *PgTicketRepository) GenerateSlug() string

GenerateSlug implements TicketRepository.

func (*PgTicketRepository) GetByChannelId

func (r *PgTicketRepository) GetByChannelId(channelId string) (*Ticket, error)

GetByChannelId implements TicketRepository.

func (*PgTicketRepository) GetByMember

func (r *PgTicketRepository) GetByMember(guildId, userId string) ([]Ticket, error)

GetByMember implements TicketRepository.

func (*PgTicketRepository) GetBySlug

func (r *PgTicketRepository) GetBySlug(slug string) (*Ticket, error)

GetBySlug implements TicketRepository.

type Ticket

type Ticket struct {
	// 8 Character long nanoid
	Slug      string
	CreatedAt time.Time
	// Not null
	ChannelId string
	// Not null
	UserId string
	// Not null
	GuildId string
}

type TicketConfig

type TicketConfig struct {
	GuildId       string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	Enabled       bool
	AllowMultiple bool
	// Nullable: coallessed to empty string
	//
	// The template to create the name of the ticket channel
	ChannelName string
	// Nullable: coallessed to empty string
	//
	// The discord channel category to put the ticket channels
	ChannelCategoryId string
	// Nullable: coallessed to empty string
	LogsChannelId string
}

type TicketConfigCreateData

type TicketConfigCreateData struct {
	GuildId           string
	Enabled           *bool
	AllowMultiple     *bool
	ChannelName       string
	ChannelCategoryId string
	LogsChannelId     string
}

type TicketConfigRepository

type TicketConfigRepository interface {
	// The returned TicketConfig clould be nil
	GetByGuildId(guildId string) (*TicketConfig, error)

	// The returned TicketConfig must not be nil if err != nil
	Create(data TicketConfigCreateData) (*TicketConfig, error)
	// The returned TicketConfig must not be nil if err != nil
	CreateDefault(guildId string) (*TicketConfig, error)

	UpdateEnabled(guildId string, enabled bool) error
	UpdateAllowMultiple(guildId string, allowMultiple bool) error
	UpdateChannelName(guildId string, channelName string) error
	UpdateChannelCategory(guildId string, channelCategoryId string) error
	UpdateLogsChannel(guildId string, logsChannelId string) error
}

type TicketRepository

type TicketRepository interface {
	GenerateSlug() string

	// The returned Ticket clould be nil
	GetBySlug(slug string) (*Ticket, error)
	// The returned Ticket clould be nil
	GetByChannelId(channelId string) (*Ticket, error)
	// The returned Tickets clould be nil
	GetByMember(guildId, userId string) ([]Ticket, error)

	// The returned Ticket must not be nil if err != nil
	Create(slug, channelId, userId, guildId string) (*Ticket, error)

	// The returned ticket clould be nil
	DeleteBySlug(slug string) (*Ticket, error)
	// The returned Ticket clould be nil
	DeleteByChannelId(channelId string) (*Ticket, error)
	// The returned Tickets clould be nil
	DeleteByMember(guildId, userId string) ([]Ticket, error)
}

Jump to

Keyboard shortcuts

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