domain

package
v0.0.0-...-bf7cbd6 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const InvitationCodeLength = 32

Variables

View Source
var InvitationValidFor = time.Hour

Functions

func StatusCode

func StatusCode(err error) int

Types

type AuthService

type AuthService interface {
	GetUser(ctx context.Context, id string) (*User, error)
	SignUp(ctx context.Context, username string, password password.Password) (*User, error)
}

type AuthorizationError

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

func NewAuthorizationError

func NewAuthorizationError(cause error, msg string) AuthorizationError

func (AuthorizationError) Error

func (ae AuthorizationError) Error() string

func (AuthorizationError) Message

func (ae AuthorizationError) Message() string

type Award

type Award struct {
	CheevoID string

	UserID string

	Awarded time.Time
}

func (*Award) Model

func (a *Award) Model() string

func (*Award) Validate

func (a *Award) Validate() error

type BadRequestError

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

func NewBadRequestError

func NewBadRequestError(err error) BadRequestError

func (BadRequestError) Error

func (bre BadRequestError) Error() string

func (BadRequestError) Message

func (bre BadRequestError) Message() string

type Cheevo

type Cheevo struct {
	// A unique identifer for the cheevo.
	ID string

	// The short name for the cheevo.
	Name string

	// A description of the act that the achievement is recognizing.
	Description string

	OrganizationID string
}

Cheevo represents an achievement that can be awarded to a user by authorized members of an organization.

func (*Cheevo) Model

func (c *Cheevo) Model() string

func (*Cheevo) Normalize

func (c *Cheevo) Normalize()

func (*Cheevo) Validate

func (c *Cheevo) Validate() error

type CheevosService

type CheevosService interface {
	AwardCheevoToUser(ctx context.Context, recipientID, cheevoID string) error
	CreateCheevo(ctx context.Context, name, description, orgID string) (*Cheevo, error)
	GetCheevo(ctx context.Context, id string) (*Cheevo, error)
}

type FieldError

type FieldError struct {
	Field string
	Msg   string
}

type Invitation

type Invitation struct {
	ID string

	Email string

	OrganizationID string

	Expires time.Time
}

func (*Invitation) Expired

func (i *Invitation) Expired() bool

func (*Invitation) Model

func (i *Invitation) Model() string

func (*Invitation) Normalize

func (i *Invitation) Normalize()

func (*Invitation) Validate

func (i *Invitation) Validate() error

type InvitationExpiredError

type InvitationExpiredError struct{}

func (InvitationExpiredError) Error

func (iee InvitationExpiredError) Error() string

func (InvitationExpiredError) Message

func (ieee InvitationExpiredError) Message() string

type Membership

type Membership struct {
	OrganizationID string

	UserID string

	Joined time.Time
}

func (*Membership) Model

func (m *Membership) Model() string

func (*Membership) Validate

func (m *Membership) Validate() error

type Model

type Model interface {
	Model() string
}

type Organization

type Organization struct {
	// A unique identifier for the organization.
	ID string

	// The name of the organization.
	Name string

	OwnerID string
}

Organization represents a group of users belonging to a related parent entity. This may be an actual organization or simply a group of friends who want to recognize each other for significant events. An organization also acts as a boundary for managing cheevos, since every cheevo is "owned" by an organization and can only be granted to members of that organization.

func (*Organization) Model

func (o *Organization) Model() string

func (*Organization) Normalize

func (o *Organization) Normalize()

func (*Organization) Validate

func (o *Organization) Validate() error

type RosterService

type RosterService interface {
	AcceptInvitation(ctx context.Context, userID, code string) error
	CreateOrganization(ctx context.Context, name, ownerID string) (*Organization, error)
	DeclineInvitation(ctx context.Context, code string) error
	GetInvitation(ctx context.Context, id string) (*Invitation, error)
	InviteUserToOrganization(ctx context.Context, email, orgID string) (*Invitation, error)
	IsMember(ctx context.Context, orgID, userID string) error
	RefreshInvitation(ctx context.Context, id string) (*Invitation, error)
}

type User

type User struct {
	// A unique identifier for the user.
	ID string

	// The username for display.
	Username string
}

User represents a single user of the system. A user can be a member of many organizations, but they are all tied to the same underlying account.

func (*User) Model

func (u *User) Model() string

func (*User) Normalize

func (u *User) Normalize()

func (*User) Validate

func (u *User) Validate() error

type ValidationError

type ValidationError struct {
	Model       string
	FieldErrors []FieldError
}

func NewValidationError

func NewValidationError(model string, fieldErrors []FieldError) ValidationError

func ValidationErrorFromError

func ValidationErrorFromError(err error) (ValidationError, bool)

func (ValidationError) Error

func (ve ValidationError) Error() string

func (ValidationError) FindFieldError

func (ve ValidationError) FindFieldError(name string) (FieldError, bool)

func (ValidationError) Message

func (ve ValidationError) Message() string

Jump to

Keyboard shortcuts

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