shares

package
v0.0.0-...-1a3a2fa Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PruneInterval = time.Hour * 4
)
View Source
const (
	SlugLength = 20
)
View Source
const StoreCtxKey storeCtxKey = "store"

Variables

View Source
var (
	ErrExpirationTooSoon = errors.New("expiration too soon")
	ErrBadType           = errors.New("bad share type")
)
View Source
var (
	ErrNoShare = errors.New("no such share")
)

Functions

func CtxWithStore

func CtxWithStore(ctx context.Context, s Shares) context.Context

func NewService

func NewService() *service

func NewStore

func NewStore() *postgresStore

Types

type CreateShareParams

type CreateShareParams struct {
	Type       EntityType          `json:"entityType"`
	EntityID   uuid.UUID           `json:"entityID"`
	Expiration *jsontypes.Duration `json:"expiration"`
}

type EntityType

type EntityType string
const (
	EntityIncident EntityType = "incident"
	EntityCall     EntityType = "call"
)

func (EntityType) IsValid

func (et EntityType) IsValid() bool

type Service

type Service interface {
	Shares

	Go(ctx context.Context)
}

type Share

type Share struct {
	ID         string          `json:"id"`
	Type       EntityType      `json:"entityType"`
	Date       *jsontypes.Time `json:"entityDate,omitempty"` // we handle this for the user
	OwnerID    users.UserID    `json:"-"`
	Owner      *string         `json:"owner,omitempty"`
	EntityID   uuid.UUID       `json:"entityID"`
	Expiration *jsontypes.Time `json:"expiration"`
}

func (*Share) GetName

func (s *Share) GetName() string

func (*Share) GetResourceName

func (s *Share) GetResourceName() string

func (*Share) GetRoles

func (s *Share) GetRoles() []string

func (*Share) String

func (s *Share) String() string

type Shares

type Shares interface {
	// NewShare creates a new share.
	NewShare(ctx context.Context, sh CreateShareParams) (*Share, error)

	// Share retrieves a share record.
	GetShare(ctx context.Context, id string) (*Share, error)

	// Shares retrieves shares visible by the context Subject.
	Shares(ctx context.Context, p SharesParams) (shares []*Share, totalCount int, err error)

	// Create stores a new share record.
	Create(ctx context.Context, share *Share) error

	// Delete deletes a share record.
	Delete(ctx context.Context, id string) error

	// Prune removes expired share records.
	Prune(ctx context.Context) error
}

func FromCtx

func FromCtx(ctx context.Context) Shares

type SharesParams

type SharesParams struct {
	common.Pagination
	Direction *common.SortDirection `json:"dir"`
}

Jump to

Keyboard shortcuts

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