invite

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

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

func (*Entity) CreateInvite

func (e *Entity) CreateInvite(ctx context.Context, code string, inviteID, guildID, authorID int64, expiresAt int64) (model.GuildInvite, error)

CreateInvite inserts records into guild_invites and guild_invite_codes in a transaction. expiresAt must be a unix seconds timestamp, will be converted to timestamptz.

func (*Entity) DeleteInviteByCode

func (e *Entity) DeleteInviteByCode(ctx context.Context, guildID int64, code string) error

DeleteInviteByCode resolves code and deletes via helper function

func (*Entity) DeleteInviteByID

func (e *Entity) DeleteInviteByID(ctx context.Context, guildID, inviteID int64) error

DeleteInviteByID removes the invite by composite key using the helper function

func (*Entity) FetchInvite

func (e *Entity) FetchInvite(ctx context.Context, code string) (model.GuildInvite, error)

FetchInvite calls function fetch_guild_invite to return a valid invite (or 0 rows)

func (*Entity) GetGuildInvites

func (e *Entity) GetGuildInvites(ctx context.Context, guildID int64) ([]model.GuildInvite, error)

GetGuildInvites returns only non-expired invites using active_guild_invites view

type Invite

type Invite interface {
	// CreateInvite inserts both guild_invites and guild_invite_codes in one transaction
	CreateInvite(ctx context.Context, code string, inviteID, guildID, authorID int64, expiresAt int64) (model.GuildInvite, error)
	// GetGuildInvites returns active invites for a guild joined with codes
	GetGuildInvites(ctx context.Context, guildID int64) ([]model.GuildInvite, error)
	// DeleteInviteByCode deletes invite by guild and code (removes mapping too)
	DeleteInviteByCode(ctx context.Context, guildID int64, code string) error
	// DeleteInviteByID deletes invite by guild and invite_id
	DeleteInviteByID(ctx context.Context, guildID, inviteID int64) error
	// FetchInvite uses DB function fetch_guild_invite to resolve code and return a valid invite (or no rows)
	FetchInvite(ctx context.Context, code string) (model.GuildInvite, error)
}

func New

func New(c *sqlx.DB) Invite

Jump to

Keyboard shortcuts

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