Documentation ¶
Index ¶
- Variables
- type AuthService
- func (s *AuthService) AllPermissions() map[string]string
- func (s *AuthService) CheckPermission(ctx context.Context, op string, obj interface{}) error
- func (s *AuthService) CheckToken(ctx context.Context, tokenString string) (token models.Token, err error)
- func (s *AuthService) CreateKey(ctx context.Context, name, user string) (*models.Key, error)
- func (s *AuthService) FindKey(ctx context.Context, id string) (*models.Key, error)
- func (s *AuthService) FindUser(ctx context.Context, id string) (*models.User, error)
- func (s *AuthService) RequestWithToken(r *http.Request) *http.Request
- func (s *AuthService) SpinOffContext(ctx context.Context) context.Context
- func (s *AuthService) TokenFromContext(ctx context.Context) *models.Token
- type Bundle
- type ChangeService
- func (s *ChangeService) Find(ctx context.Context, id string) (*models.Change, error)
- func (s *ChangeService) List(ctx context.Context, filter models.ChangeFilter) ([]*models.Change, error)
- func (s *ChangeService) Submit(ctx context.Context, model models.ChangeModel, op string, listed bool, ...)
- func (s *ChangeService) Subscribe(ctx context.Context, filter models.ChangeFilter) <-chan *models.Change
- type ChannelService
- func (s *ChannelService) Create(ctx context.Context, name string, logged, hub bool, ...) (*models.Channel, error)
- func (s *ChannelService) Delete(ctx context.Context, name string) (*models.Channel, error)
- func (s *ChannelService) Ensure(ctx context.Context, name string) (*models.Channel, error)
- func (s *ChannelService) Find(ctx context.Context, id string) (*models.Channel, error)
- func (s *ChannelService) List(ctx context.Context, filter models.ChannelFilter) ([]*models.Channel, error)
- func (s *ChannelService) Update(ctx context.Context, name string, update models.ChannelUpdate) (*models.Channel, error)
- type CharacterService
- func (s *CharacterService) AddNick(ctx context.Context, id string, nick string) (*models.Character, error)
- func (s *CharacterService) Create(ctx context.Context, nick, name, shortName, author, description string) (*models.Character, error)
- func (s *CharacterService) Delete(ctx context.Context, id string) (*models.Character, error)
- func (s *CharacterService) Find(ctx context.Context, id string) (*models.Character, error)
- func (s *CharacterService) FindNick(ctx context.Context, nick string) (*models.Character, error)
- func (s *CharacterService) List(ctx context.Context, filter models.CharacterFilter) ([]*models.Character, error)
- func (s *CharacterService) RemoveNick(ctx context.Context, id string, nick string) (*models.Character, error)
- func (s *CharacterService) Update(ctx context.Context, id string, name, shortName, description *string) (*models.Character, error)
- type FileService
- func (s *FileService) Edit(ctx context.Context, id string, name *string, public *bool) (*models.File, error)
- func (s *FileService) Find(ctx context.Context, id string) (*models.File, error)
- func (s *FileService) List(ctx context.Context, filter models.FileFilter) ([]*models.File, error)
- func (s *FileService) Remove(ctx context.Context, id string) (*models.File, error)
- func (s *FileService) Upload(ctx context.Context, reader io.Reader, name string, public bool, size int64) (*models.File, error)
- type LogService
- func (s *LogService) AddPost(ctx context.Context, logId string, time time.Time, kind, nick, text string) (*models.Post, error)
- func (s *LogService) Create(ctx context.Context, title, description, channelName, eventName string, ...) (*models.Log, error)
- func (s *LogService) Delete(ctx context.Context, id string) (*models.Log, error)
- func (s *LogService) DeletePost(ctx context.Context, id string) (*models.Post, error)
- func (s *LogService) EditPost(ctx context.Context, id string, update models.PostUpdate) (*models.Post, error)
- func (s *LogService) Find(ctx context.Context, id string) (*models.Log, error)
- func (s *LogService) FindPosts(ctx context.Context, id string) (*models.Post, error)
- func (s *LogService) FixImportDateBug(ctx context.Context) error
- func (s *LogService) Import(ctx context.Context, importer models.LogImporter, date time.Time, ...) ([]*models.Log, error)
- func (s *LogService) List(ctx context.Context, filter *models.LogFilter) ([]*models.Log, error)
- func (s *LogService) ListPosts(ctx context.Context, filter *models.PostFilter) ([]*models.Post, error)
- func (s *LogService) ListUnknownNicks() []*models.UnknownNick
- func (s *LogService) MergeLogs(ctx context.Context, targetID string, sourceID string, removeAfter bool) (*models.Log, error)
- func (s *LogService) MovePost(ctx context.Context, id string, position int) ([]*models.Post, error)
- func (s *LogService) NextLogs(ctx context.Context, log *models.Log) ([]*models.LogSuggestion, error)
- func (s *LogService) PrevLogs(ctx context.Context, log *models.Log) ([]*models.LogSuggestion, error)
- func (s *LogService) RefreshAllLogCharacters(ctx context.Context) error
- func (s *LogService) RefreshLogCharacters(ctx context.Context, log models.Log) (*models.Log, error)
- func (s *LogService) SplitLog(ctx context.Context, logId string, startPostId string) (*models.Log, error)
- func (s *LogService) Update(ctx context.Context, id string, update models.LogUpdate) (*models.Log, error)
- type StoryService
- func (s *StoryService) AddStoryTag(ctx context.Context, story models.Story, tag models.Tag) (*models.Story, error)
- func (s *StoryService) CreateChapter(ctx context.Context, story models.Story, title, source string, author *string, ...) (*models.Chapter, error)
- func (s *StoryService) CreateComment(ctx context.Context, chapter models.Chapter, ...) (*models.Comment, error)
- func (s *StoryService) CreateStory(ctx context.Context, name string, author *string, ...) (*models.Story, error)
- func (s *StoryService) EditChapter(ctx context.Context, chapter *models.Chapter, title, source *string, ...) (*models.Chapter, error)
- func (s *StoryService) EditComment(ctx context.Context, comment *models.Comment, ...) (*models.Comment, error)
- func (s *StoryService) EditStory(ctx context.Context, story *models.Story, name *string, ...) (*models.Story, error)
- func (s *StoryService) FindChapter(ctx context.Context, id string) (*models.Chapter, error)
- func (s *StoryService) FindComment(ctx context.Context, id string) (*models.Comment, error)
- func (s *StoryService) FindStory(ctx context.Context, id string) (*models.Story, error)
- func (s *StoryService) ListChapters(ctx context.Context, story models.Story) ([]*models.Chapter, error)
- func (s *StoryService) ListComments(ctx context.Context, chapter models.Chapter, limit int) ([]*models.Comment, error)
- func (s *StoryService) ListStories(ctx context.Context, filter models.StoryFilter) ([]*models.Story, error)
- func (s *StoryService) MoveChapter(ctx context.Context, chapter *models.Chapter, from, to models.Story) (*models.Chapter, error)
- func (s *StoryService) RemoveChapter(ctx context.Context, chapter *models.Chapter) error
- func (s *StoryService) RemoveComment(ctx context.Context, comment *models.Comment) error
- func (s *StoryService) RemoveStory(ctx context.Context, story *models.Story) error
- func (s *StoryService) RemoveStoryTag(ctx context.Context, story models.Story, tag models.Tag) (*models.Story, error)
- type TagService
Constants ¶
This section is empty.
Variables ¶
var ErrCouldNotReadHead = errors.New("could not read file head")
var ErrCouldNotUploadFile = errors.New("could not upload file")
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.
var ErrExpired = errors.New("claims have already expired")
ErrExpired is returned by parseClaims if the expiry date is in the past
var ErrInvalidClaims = errors.New("invalid claims in token")
ErrInvalidClaims is returned by parseClaims if the claims cannot be parsed
var ErrInvalidFileSize = errors.New("file is not of a correct size (min: 320B, max: 16MB)")
var ErrInvalidFileType = errors.New("file type could not be recognized or is not allowed")
var ErrInvalidName = errors.New("invalid name")
var ErrInvalidOperation = errors.New("no permission exists for this operation")
ErrInvalidOperation is returned for operations that should never be allowed
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is returned if the key wasn't found.
var ErrNoKid = errors.New("missing \"kid\" field in token")
ErrNoKid is returned if the key id is missing from the jwt token header,
var ErrPrivateNoAuthor = errors.New("cannot search for private files without an author")
var ErrUnauthenticated = errors.New("you are not authenticated")
ErrUnauthenticated is returned when the user is not authenticated
ErrUnauthorized is returned when the user doesn't have access to this resource
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 ¶
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) 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.
type ChangeService ¶
type ChangeService struct {
// contains filtered or unexported fields
}
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) List ¶
func (s *ChannelService) List(ctx context.Context, filter models.ChannelFilter) ([]*models.Channel, error)
type CharacterService ¶
type CharacterService struct {
// contains filtered or unexported fields
}
func (*CharacterService) List ¶
func (s *CharacterService) List(ctx context.Context, filter models.CharacterFilter) ([]*models.Character, error)
List lists the characters. If the only filter active is `IDs`, the loader is used to batch together requests.
func (*CharacterService) RemoveNick ¶
type FileService ¶
type FileService struct {
// contains filtered or unexported fields
}
FileService is a service for files.
func (*FileService) List ¶
func (s *FileService) List(ctx context.Context, filter models.FileFilter) ([]*models.File, error)
type LogService ¶
type LogService struct {
// contains filtered or unexported fields
}
func (*LogService) DeletePost ¶
func (*LogService) EditPost ¶
func (s *LogService) EditPost(ctx context.Context, id string, update models.PostUpdate) (*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) 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) 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 ¶
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 (*StoryService) CreateChapter ¶
func (*StoryService) CreateComment ¶
func (*StoryService) CreateStory ¶
func (*StoryService) EditChapter ¶
func (*StoryService) EditComment ¶
func (*StoryService) FindChapter ¶
func (*StoryService) FindComment ¶
func (*StoryService) ListChapters ¶
func (*StoryService) ListComments ¶
func (*StoryService) ListStories ¶
func (s *StoryService) ListStories(ctx context.Context, filter models.StoryFilter) ([]*models.Story, error)