event

package
v0.13.12 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMemoryStore

func NewMemoryStore() *crud.MemoryStore[NewEvent, Event, FindFilters]

NewMemoryStore returns a new in memory store.

func Router

func Router(storer Storer, authService auth.Service) func(chi.Router)

Router returns a new http router that handles crud event requests for a given event service.

func URLFromID

func URLFromID(baseURL string, id string) (string, error)

URLFromID takes a base url an a event id and constructs an url pointing to the event on the web frontend.

Types

type Authorizer

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

Authorizer wraps a Storer. It checks the authorization before propagating the call to the wrapped storer.

func (*Authorizer) Create

func (a *Authorizer) Create(ctx context.Context, newEvent *NewEvent) (*Event, error)

Create can be called by all users.

func (*Authorizer) Delete

func (a *Authorizer) Delete(ctx context.Context, id string) error

Delete can be called by an admin user or the event author.

func (*Authorizer) Find

func (a *Authorizer) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)

Find can be called by everyone.

func (*Authorizer) FindByID

func (a *Authorizer) FindByID(ctx context.Context, id string) (*Event, error)

FindByID can be called by everyone.

func (*Authorizer) Update

func (a *Authorizer) Update(ctx context.Context, event *Event) (*Event, error)

Update can be called by an admin user or the event author.

type CreateOperation

type CreateOperation struct {
	Event *Event
	// contains filtered or unexported fields
}

func NewCreateOperation

func NewCreateOperation(event *Event, userID string) CreateOperation

func (CreateOperation) UserID

func (o CreateOperation) UserID() string

type DeleteOperation

type DeleteOperation struct {
	ID string
	// contains filtered or unexported fields
}

func NewDeleteOperation

func NewDeleteOperation(id string, userID string) DeleteOperation

func (DeleteOperation) UserID

func (o DeleteOperation) UserID() string

type Event

type Event struct {
	ID           string     `json:"id" db:"id"`
	Deactivated  bool       `json:"deactivated" db:"deactivated"`
	Published    bool       `json:"published" db:"published"`
	Canceled     bool       `json:"canceled" db:"canceled"`
	Parent       string     `json:"parent" db:"parent"`
	ParentListed bool       `json:"parentListed" db:"parentListed"`
	Name         string     `json:"name" db:"name"`
	Organizers   []string   `json:"organizers" db:"organizers"`
	Involved     []Involved `json:"involved" db:"involved"`
	Location     string     `json:"location" db:"location"`
	Location2    string     `json:"location2" db:"location2"`
	Description  string     `json:"description" db:"description"`
	Start        time.Time  `json:"start" db:"start"`
	End          *time.Time `json:"end" db:"end"`
	Tags         []string   `json:"tags" db:"tags"`
	Image        string     `json:"image" db:"image"`
	OwnedBy      []string   `json:"ownedBy" db:"ownedBy"`
}

Event defines a calendar event. It implements indexo.Coppyable.

func EventFromNewEvent

func EventFromNewEvent(newEvent *NewEvent, id string) *Event

func (Event) Identifier

func (e Event) Identifier() string

func (*Event) Indexable

func (e *Event) Indexable() bool

Indexable indicates wether the event should be indexed in the search. All events are indexable if they are not deactivated.

func (*Event) IsOwned

func (e *Event) IsOwned(id string) bool

IsOwned returns true if the id is in the OwnedBy field.

func (*Event) Listable

func (e *Event) Listable() bool

Listable indicates wether the event should be shown on list pages.

type FindFilters

type FindFilters struct {
	ID                  *string    `json:"id,omitempty"`
	Deactivated         *bool      `json:"deactivated,omitempty"`
	Published           *bool      `json:"published,omitempty"`
	Canceled            *bool      `json:"canceled,omitempty"`
	Parent              *string    `json:"parent,omitempty"`
	Name                *string    `json:"name,omitempty"`
	LikeName            *string    `json:"likeName,omitempty"`
	Organizers          []string   `json:"organizers,omitempty"`
	Location            *string    `json:"location,omitempty"`
	Location2           *string    `json:"location2,omitempty"`
	Description         *string    `json:"description,omitempty"`
	Start               *time.Time `json:"start,omitempty"`
	StartBefore         *time.Time `json:"startBefore,omitempty"`
	StartAfter          *time.Time `json:"startAfter,omitempty"`
	End                 *time.Time `json:"end,omitempty"`
	EndBefore           *time.Time `json:"endBefore,omitempty"`
	EndAfter            *time.Time `json:"endAfter,omitempty"`
	Tags                []string   `json:"tags,omitempty"`
	OwnedBy             []string   `json:"ownedBy,omitempty"`
	OwnedByOrOrganizers []string
}

FindFilters defines the possible filters for the find method.

type FindResponse

type FindResponse[Model any] struct {
	// in:body
	Model *Model
}

type Involved

type Involved struct {
	Name        string `json:"name" db:"name"`
	Description string `json:"description" db:"description"`
}

Involved defines an entity, that is involved with an event.

type NewEvent

type NewEvent struct {
	Published    bool       `json:"published"`
	Parent       string     `json:"parent"`
	ParentListed bool       `json:"parentListed"`
	Name         string     `json:"name"`
	Organizers   []string   `json:"organizers"`
	Involved     []Involved `json:"involved"`
	Location     string     `json:"location"`
	Location2    string     `json:"location2"`
	Description  string     `json:"description"`
	Start        time.Time  `json:"start"`
	End          *time.Time `json:"end"`
	Tags         []string   `json:"tags"`
	Image        string     `json:"image"`
	OwnedBy      []string   `json:"ownedBy"`
}

NewEvent defines the data for a new event.

func (*NewEvent) IsOwned

func (e *NewEvent) IsOwned(id string) bool

IsOwned returns true if the id is in the OwnedBy field.

type Operator

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

func NewOperator

func NewOperator(storer Storer, queue oqueue.Service) *Operator

func (*Operator) Create

func (i *Operator) Create(ctx context.Context, newEvent *NewEvent) (*Event, error)

func (*Operator) Delete

func (i *Operator) Delete(ctx context.Context, id string) error

func (*Operator) Find

func (i *Operator) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)

func (*Operator) FindByID

func (i *Operator) FindByID(ctx context.Context, id string) (*Event, error)

func (*Operator) Update

func (i *Operator) Update(ctx context.Context, event *Event) (*Event, error)

type Service

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

func NewService

func NewService(store Storer, groupOwnerService groupOwnerService) *Service

NewService returns a new event service.

func (*Service) Create

func (s *Service) Create(ctx context.Context, newEvent *NewEvent) (*Event, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

func (*Service) Find

func (s *Service) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)

func (*Service) FindByID

func (s *Service) FindByID(ctx context.Context, id string) (*Event, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, event *Event) (*Event, error)

type SqlStore

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

func NewSqlStore

func NewSqlStore(db *sqlx.DB, migrationService dbmigration.Service) (*SqlStore, error)

NewSqlStore returns a new sql db event store.

func (*SqlStore) Create

func (s *SqlStore) Create(ctx context.Context, newEvent *NewEvent) (*Event, error)

func (*SqlStore) Delete

func (s *SqlStore) Delete(ctx context.Context, id string) error

func (*SqlStore) Find

func (s *SqlStore) Find(ctx context.Context, params *crud.FindParams[FindFilters]) ([]*Event, int, error)

func (*SqlStore) FindByID

func (s *SqlStore) FindByID(ctx context.Context, id string) (*Event, error)

func (*SqlStore) Update

func (s *SqlStore) Update(ctx context.Context, event *Event) (*Event, error)

type Storer

type Storer = crud.Storer[NewEvent, Event, FindFilters]

Storer defines a service for CRUD operations on the event model.

func NewAuthorizer

func NewAuthorizer(store Storer, groupAuthorizer authorizer) Storer

NewAuthorizer returns a new authorizer limiting access to the provided store.

type UpdateOperation

type UpdateOperation struct {
	Event *Event
	// contains filtered or unexported fields
}

func NewUpdateOperation

func NewUpdateOperation(event *Event, userID string) UpdateOperation

func (UpdateOperation) UserID

func (o UpdateOperation) UserID() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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