services

package
v0.0.0-...-09d31aa Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: ISC Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCouldNotReadHead = errors.New("could not read file head")
View Source
var ErrCouldNotUploadFile = errors.New("could not upload file")
View Source
var ErrDeletedUser = errors.New("user was not found")

ErrDeletedUser is returned by CheckToken if the key can represent this user, but the user doesn't exist.

View Source
var ErrExpired = errors.New("claims have already expired")

ErrExpired is returned by parseClaims if the expiry date is in the past

View Source
var ErrInvalidClaims = errors.New("invalid claims in token")

ErrInvalidClaims is returned by parseClaims if the claims cannot be parsed

View Source
var ErrInvalidFileSize = errors.New("file is not of a correct size (min: 320B, max: 16MB)")
View Source
var ErrInvalidFileType = errors.New("file type could not be recognized or is not allowed")
View Source
var ErrInvalidName = errors.New("invalid name")
View Source
var ErrInvalidOperation = errors.New("no permission exists for this operation")

ErrInvalidOperation is returned for operations that should never be allowed

View Source
var ErrKeyNotFound = errors.New("key not found")

ErrKeyNotFound is returned if the key wasn't found.

View Source
var ErrNoKid = errors.New("missing \"kid\" field in token")

ErrNoKid is returned if the key id is missing from the jwt token header,

View Source
var ErrPrivateNoAuthor = errors.New("cannot search for private files without an author")
View Source
var ErrUnauthenticated = errors.New("you are not authenticated")

ErrUnauthenticated is returned when the user is not authenticated

View Source
var ErrUnauthorized = errors.New("you are not authorized to perform this action")

ErrUnauthorized is returned when the user doesn't have access to this resource

View Source
var ErrWrongUser = errors.New("key is not valid for this user")

ErrWrongUser is returned by CheckToken if the key cannot represent this user

Functions

This section is empty.

Types

type AuthService

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

AuthService is a service for handling the 'orizations and 'entications.

func (*AuthService) AllPermissions

func (s *AuthService) AllPermissions() map[string]string

AllPermissions gets all permissions and their purpose

func (*AuthService) CheckPermission

func (s *AuthService) CheckPermission(ctx context.Context, op string, obj interface{}) error

CheckPermission does some magic.

func (*AuthService) CheckToken

func (s *AuthService) CheckToken(ctx context.Context, tokenString string) (token models.Token, err error)

CheckToken reads the token string and returns a token if everything is kosher.

func (*AuthService) CreateKey

func (s *AuthService) CreateKey(ctx context.Context, name, user string) (*models.Key, error)

CreateKey generates a new key for the user and name. This does not allow generating wildcard keys, they have to be manually inserted into the DB.

func (*AuthService) FindKey

func (s *AuthService) FindKey(ctx context.Context, id string) (*models.Key, error)

FindKey finds a key by id.

func (*AuthService) FindUser

func (s *AuthService) FindUser(ctx context.Context, id string) (*models.User, error)

FindUser finds a user by id.

func (*AuthService) RequestWithToken

func (s *AuthService) RequestWithToken(r *http.Request) *http.Request

RequestWithToken either returns the request, or the request with a new context that has the token.

func (*AuthService) SpinOffContext

func (s *AuthService) SpinOffContext(ctx context.Context) context.Context

SpinOffContext adds the auth token to a background context.

func (*AuthService) TokenFromContext

func (s *AuthService) TokenFromContext(ctx context.Context) *models.Token

TokenFromContext gets the token from context.

type Bundle

type Bundle struct {
	Tags       *TagService
	Characters *CharacterService
	Changes    *ChangeService
	Logs       *LogService
	Channels   *ChannelService
	Stories    *StoryService
	Auth       *AuthService
	Files      *FileService
}

A Bundle contains all services.

func NewBundle

func NewBundle(db database.Database, spaceClient *space.Client) *Bundle

NewBundle creates a new bundle.

type ChangeService

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

func (*ChangeService) Find

func (s *ChangeService) Find(ctx context.Context, id string) (*models.Change, error)

func (*ChangeService) List

func (s *ChangeService) List(ctx context.Context, filter models.ChangeFilter) ([]*models.Change, error)

func (*ChangeService) Submit

func (s *ChangeService) Submit(ctx context.Context, model models.ChangeModel, op string, listed bool, keys []models.ChangeKey, objects ...interface{})

func (*ChangeService) Subscribe

func (s *ChangeService) Subscribe(ctx context.Context, filter models.ChangeFilter) <-chan *models.Change

type ChannelService

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

ChannelService is an application service for dealing with channels.

func (*ChannelService) Create

func (s *ChannelService) Create(ctx context.Context, name string, logged, hub bool, eventName, locationName string) (*models.Channel, error)

func (*ChannelService) Delete

func (s *ChannelService) Delete(ctx context.Context, name string) (*models.Channel, error)

func (*ChannelService) Ensure

func (s *ChannelService) Ensure(ctx context.Context, name string) (*models.Channel, error)

func (*ChannelService) Find

func (s *ChannelService) Find(ctx context.Context, id string) (*models.Channel, error)

func (*ChannelService) List

func (*ChannelService) Update

func (s *ChannelService) Update(ctx context.Context, name string, update models.ChannelUpdate) (*models.Channel, error)

type CharacterService

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

func (*CharacterService) AddNick

func (s *CharacterService) AddNick(ctx context.Context, id string, nick string) (*models.Character, error)

func (*CharacterService) Create

func (s *CharacterService) Create(ctx context.Context, nick, name, shortName, author, description string) (*models.Character, error)

func (*CharacterService) Delete

func (s *CharacterService) Delete(ctx context.Context, id string) (*models.Character, error)

func (*CharacterService) Find

Find uses the loader to find the character by the ID.

func (*CharacterService) FindNick

func (s *CharacterService) FindNick(ctx context.Context, nick string) (*models.Character, error)

Find uses the loader to find the character by the ID.

func (*CharacterService) List

List lists the characters. If the only filter active is `IDs`, the loader is used to batch together requests.

func (*CharacterService) RemoveNick

func (s *CharacterService) RemoveNick(ctx context.Context, id string, nick string) (*models.Character, error)

func (*CharacterService) Update

func (s *CharacterService) Update(ctx context.Context, id string, name, shortName, description *string) (*models.Character, error)

type FileService

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

FileService is a service for files.

func (*FileService) Edit

func (s *FileService) Edit(ctx context.Context, id string, name *string, public *bool) (*models.File, error)

func (*FileService) Find

func (s *FileService) Find(ctx context.Context, id string) (*models.File, error)

func (*FileService) List

func (s *FileService) List(ctx context.Context, filter models.FileFilter) ([]*models.File, error)

func (*FileService) Remove

func (s *FileService) Remove(ctx context.Context, id string) (*models.File, error)

func (*FileService) Upload

func (s *FileService) Upload(ctx context.Context, reader io.Reader, name string, public bool, size int64) (*models.File, error)

type LogService

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

func (*LogService) AddPost

func (s *LogService) AddPost(ctx context.Context, logId string, time time.Time, kind, nick, text string) (*models.Post, error)

func (*LogService) Create

func (s *LogService) Create(ctx context.Context, title, description, channelName, eventName string, open bool) (*models.Log, error)

func (*LogService) Delete

func (s *LogService) Delete(ctx context.Context, id string) (*models.Log, error)

func (*LogService) DeletePost

func (s *LogService) DeletePost(ctx context.Context, id string) (*models.Post, error)

func (*LogService) EditPost

func (s *LogService) EditPost(ctx context.Context, id string, update models.PostUpdate) (*models.Post, error)

func (*LogService) Find

func (s *LogService) Find(ctx context.Context, id string) (*models.Log, error)

func (*LogService) FindPosts

func (s *LogService) FindPosts(ctx context.Context, id string) (*models.Post, error)

func (*LogService) FixImportDateBug

func (s *LogService) FixImportDateBug(ctx context.Context) error

func (*LogService) Import

func (s *LogService) Import(ctx context.Context, importer models.LogImporter, date time.Time, tz *time.Location, channelName string, sessionThreshold time.Duration, data string) ([]*models.Log, error)

Import creates new logs from common formats.

func (*LogService) List

func (s *LogService) List(ctx context.Context, filter *models.LogFilter) ([]*models.Log, error)

func (*LogService) ListPosts

func (s *LogService) ListPosts(ctx context.Context, filter *models.PostFilter) ([]*models.Post, error)

func (*LogService) ListUnknownNicks

func (s *LogService) ListUnknownNicks() []*models.UnknownNick

func (*LogService) MergeLogs

func (s *LogService) MergeLogs(ctx context.Context, targetID string, sourceID string, removeAfter bool) (*models.Log, error)

func (*LogService) MovePost

func (s *LogService) MovePost(ctx context.Context, id string, position int) ([]*models.Post, error)

func (*LogService) NextLogs

func (s *LogService) NextLogs(ctx context.Context, log *models.Log) ([]*models.LogSuggestion, error)

func (*LogService) PrevLogs

func (s *LogService) PrevLogs(ctx context.Context, log *models.Log) ([]*models.LogSuggestion, error)

func (*LogService) RefreshAllLogCharacters

func (s *LogService) RefreshAllLogCharacters(ctx context.Context) error

func (*LogService) RefreshLogCharacters

func (s *LogService) RefreshLogCharacters(ctx context.Context, log models.Log) (*models.Log, error)

func (*LogService) SplitLog

func (s *LogService) SplitLog(ctx context.Context, logId string, startPostId string) (*models.Log, error)

func (*LogService) Update

func (s *LogService) Update(ctx context.Context, id string, update models.LogUpdate) (*models.Log, error)

type StoryService

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

StoryService is a service governing all operations on stories and child objects.

func (*StoryService) AddStoryTag

func (s *StoryService) AddStoryTag(ctx context.Context, story models.Story, tag models.Tag) (*models.Story, error)

func (*StoryService) CreateChapter

func (s *StoryService) CreateChapter(ctx context.Context, story models.Story, title, source string, author *string, createdDate time.Time, fictionalDate *time.Time, commentMode models.ChapterCommentMode) (*models.Chapter, error)

func (*StoryService) CreateComment

func (s *StoryService) CreateComment(ctx context.Context, chapter models.Chapter, subject, author, source, characterName string, characterID *string, createdDate time.Time, fictionalDate time.Time) (*models.Comment, error)

func (*StoryService) CreateStory

func (s *StoryService) CreateStory(ctx context.Context, name string, author *string, category models.StoryCategory, listed, open bool, tags []models.Tag, createdDate, fictionalDate time.Time, sortByFictionalDate bool) (*models.Story, error)

func (*StoryService) EditChapter

func (s *StoryService) EditChapter(ctx context.Context, chapter *models.Chapter, title, source *string, fictionalDate *time.Time, commentMode *models.ChapterCommentMode, commentsLocked *bool) (*models.Chapter, error)

func (*StoryService) EditComment

func (s *StoryService) EditComment(ctx context.Context, comment *models.Comment, source, characterName, characterID, subject *string, fictionalDate *time.Time) (*models.Comment, error)

func (*StoryService) EditStory

func (s *StoryService) EditStory(ctx context.Context, story *models.Story, name *string, category *models.StoryCategory, listed, open *bool, fictionalDate *time.Time, sortByFictionalDate *bool) (*models.Story, error)

func (*StoryService) FindChapter

func (s *StoryService) FindChapter(ctx context.Context, id string) (*models.Chapter, error)

func (*StoryService) FindComment

func (s *StoryService) FindComment(ctx context.Context, id string) (*models.Comment, error)

func (*StoryService) FindStory

func (s *StoryService) FindStory(ctx context.Context, id string) (*models.Story, error)

func (*StoryService) ListChapters

func (s *StoryService) ListChapters(ctx context.Context, story models.Story) ([]*models.Chapter, error)

func (*StoryService) ListComments

func (s *StoryService) ListComments(ctx context.Context, chapter models.Chapter, limit int) ([]*models.Comment, error)

func (*StoryService) ListStories

func (s *StoryService) ListStories(ctx context.Context, filter models.StoryFilter) ([]*models.Story, error)

func (*StoryService) MoveChapter

func (s *StoryService) MoveChapter(ctx context.Context, chapter *models.Chapter, from, to models.Story) (*models.Chapter, error)

func (*StoryService) RemoveChapter

func (s *StoryService) RemoveChapter(ctx context.Context, chapter *models.Chapter) error

func (*StoryService) RemoveComment

func (s *StoryService) RemoveComment(ctx context.Context, comment *models.Comment) error

func (*StoryService) RemoveStory

func (s *StoryService) RemoveStory(ctx context.Context, story *models.Story) error

func (*StoryService) RemoveStoryTag

func (s *StoryService) RemoveStoryTag(ctx context.Context, story models.Story, tag models.Tag) (*models.Story, error)

type TagService

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

TagService is a service for tag-related functions.

func (*TagService) FindTag

func (s *TagService) FindTag(ctx context.Context, source models.TagKind, id string) (*models.Tag, error)

FindTag finds one tag.

func (*TagService) ListTags

func (s *TagService) ListTags(ctx context.Context, filter models.TagFilter) ([]*models.Tag, error)

ListTags lists tags.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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