services

package
v0.0.0-...-f1c6d0e Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotCEOError = errors.New("cannot choose corp: user is not CEO")
)

Functions

func InitAsCommandLineAdminUser

func InitAsCommandLineAdminUser(ctx context.Context, db *db.DB, userID string) error

Types

type AllianceIconSize

type AllianceIconSize string
const (
	A64  AllianceIconSize = "alliance64"
	A128 AllianceIconSize = "alliance128"
)

func (AllianceIconSize) Apply

func (AllianceIconSize) GetEveMediaFn

func (a AllianceIconSize) GetEveMediaFn(d *db.DB) GetEveMediaFn

func (AllianceIconSize) SetEveMediaFn

func (a AllianceIconSize) SetEveMediaFn(d *db.DB) SetEveMediaFn

type Character

type Character struct {
	Character         *esi.Character
	TokenNeedsRescope bool
}

type CorpIconSize

type CorpIconSize string
const (
	C64  CorpIconSize = "corp64"
	C128 CorpIconSize = "corp128"
	C256 CorpIconSize = "corp256"
)

func (CorpIconSize) Apply

func (c CorpIconSize) Apply(u *esi.CorpIconURLs) *url.URL

func (CorpIconSize) GetEveMediaFn

func (c CorpIconSize) GetEveMediaFn(d *db.DB) GetEveMediaFn

func (CorpIconSize) SetEveMediaFn

func (c CorpIconSize) SetEveMediaFn(d *db.DB) SetEveMediaFn

type ESI

type ESI struct {
	DB               *db.DB
	OAC              *esi.OAuth2Client
	L                *zerolog.Logger
	ESIClient        *esi.Client
	PeriodicRefresh  time.Duration
	PeriodicKeyFetch time.Duration
}

func (*ESI) DoesCharacterNeedRescope

func (e *ESI) DoesCharacterNeedRescope(c context.Context, charID int32) (bool, error)

func (*ESI) GetCharactersForUser

func (e *ESI) GetCharactersForUser(c context.Context, userID string) ([]Character, error)

func (*ESI) GetEvePublicKeys

func (e *ESI) GetEvePublicKeys(c context.Context) (*esi.OAuthKeysMetadata, error)

func (*ESI) GetEveToken

func (e *ESI) GetEveToken(c context.Context, charID int32) (*esi.Tokens, error)

func (*ESI) GoPeriodicallyFetchEvePublicKeys

func (e *ESI) GoPeriodicallyFetchEvePublicKeys(m *async.Messenger)

func (*ESI) GoPeriodicallyRefreshAllTokens

func (e *ESI) GoPeriodicallyRefreshAllTokens(m *async.Messenger)

func (*ESI) HasCharacterForUser

func (e *ESI) HasCharacterForUser(c context.Context, userID string, charID int32) (bool, error)

func (*ESI) SearchCorporations

func (e *ESI) SearchCorporations(c context.Context, query string, lang language.Tag) ([]*esi.Corporation, error)

func (*ESI) SetEveTokens

func (e *ESI) SetEveTokens(c context.Context, userID string, t *esi.Tokens) error

type Features

type Features struct {
	DB *db.DB
	E  *features.Engine
}

func (*Features) ChangeEnabled

func (f *Features) ChangeEnabled(ctx context.Context, enableIDs, disableIDs []string) error

TODO: Call this

func (*Features) DiffChangeEnabled

func (f *Features) DiffChangeEnabled(ctx context.Context, enableIDs, disableIDs []string) (added, removed []features.Scope, err error)

TODO: Call this after selecting different features, before calling ChangeEnabled.

func (*Features) GetAdminCEOInitialFeatures

func (f *Features) GetAdminCEOInitialFeatures(ctx context.Context, langs ...language.Tag) ([]features.Feature, error)

func (*Features) GetAllFeatures

func (f *Features) GetAllFeatures(ctx context.Context, langs ...language.Tag) ([]features.Feature, error)

TODO: Call this

func (*Features) GetByIDs

func (f *Features) GetByIDs(ctx context.Context, ids []string, langs ...language.Tag) ([]features.Feature, error)

func (*Features) GetEnabledFeatures

func (f *Features) GetEnabledFeatures(ctx context.Context, langs ...language.Tag) ([]features.Feature, error)

type GetEveMediaFn

type GetEveMediaFn func(context.Context, int32) (image.Image, time.Time, error)

type LatestTag

type LatestTag struct {
	T data.Tag
	S []data.Snippet
}

type Media

type Media struct {
	DB                    *db.DB
	ESIClient             *esi.Client
	DefaultExpiryDuration time.Duration
}

func (*Media) CreateMedia

func (m *Media) CreateMedia(c context.Context, name, contentType string, b []byte) (id string, err error)

func (*Media) DeleteMedia

func (m *Media) DeleteMedia(c context.Context, id string) error

func (*Media) GetAllianceIcon

func (m *Media) GetAllianceIcon(c context.Context, aID int32, size AllianceIconSize) (image.Image, error)

func (*Media) GetCorporationIcon

func (m *Media) GetCorporationIcon(c context.Context, corpID int32, size CorpIconSize) (image.Image, error)

func (*Media) GetMedia

func (m *Media) GetMedia(c context.Context, id string) (name, contentType string, b []byte, err error)

func (*Media) GetPortrait

func (m *Media) GetPortrait(c context.Context, charID int32, size PortraitMediaSize) (image.Image, error)

type PortraitMediaSize

type PortraitMediaSize string
const (
	P64  PortraitMediaSize = "portrait64"
	P128 PortraitMediaSize = "portrait128"
	P256 PortraitMediaSize = "portrait256"
	P512 PortraitMediaSize = "portrait512"
)

func (PortraitMediaSize) Apply

func (p PortraitMediaSize) Apply(u *esi.PortraitURLs) *url.URL

func (PortraitMediaSize) GetEveMediaFn

func (p PortraitMediaSize) GetEveMediaFn(d *db.DB) GetEveMediaFn

func (PortraitMediaSize) SetEveMediaFn

func (p PortraitMediaSize) SetEveMediaFn(d *db.DB) SetEveMediaFn

type Posts

type Posts struct {
	DB    *db.DB
	F     app.Framework
	Queue *async.Queue
}

func (*Posts) CreateNewPost

func (p *Posts) CreateNewPost(c context.Context, title, body, user string, tags []data.Tag, lang language.Tag) (*url.URL, error)

type Privileges

type Privileges struct{}

func DefaultPrivileges

func DefaultPrivileges() Privileges

type SetEveMediaFn

type SetEveMediaFn func(context.Context, int32, image.Image, time.Time) error

type State

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

State solely manages the state of the dharma application in the face of complexity.

The complexity arises because the problem space is:

  1. There are X accounts on dharma, a subset of which are admin,
  2. There are numerous EVE Online character(s) associated with accounts on dharma,
  3. There is exactly one CEO (EVE Online character) of the corporation using dharma,
  4. Optionally, there is an executor corporation of an alliance, where an alliance is a collection of one or more alliances
  5. Finally, while not a game mechanic, there is the concept of coalitions which already are effecively alliances that federate for a common cause

In the spirit of decentralized leadership, it simplifies the problem space by enforcing the following constraints to simplify software administration and push power downwards:

  1. A dharma account with no characters or only non-CEO characters does not enable management of any corporation.
  2. Dharma manages ONE and ONLY one corporation.
  3. A dharma administrative account, paired with an EVE Online character that is a CEO, makes that CEO's corporation "eligible" to be managed by dharma
  4. Corporations managed by dharma, that are also in alliances, have automatic federating behaviors that occur but only towards peer software managing corporations that are also in the same alliance.
  5. Dharma does nothing special for coalitions, these are covered by the existing ad-hoc federation controls and states.

Note that #0 and #2 imply that there can be many administrative accounts in dharma, but only one of which requires a CEO EVE Online character. This ensures that the in-game CEO always has the maximum tools necessary to administrate dharma, yet retains the option to delegate devops to others.

func NewState

func NewState(c util.Context, db *db.DB, esi *esi.Client) (*State, error)

func (*State) ChooseCorporation

func (s *State) ChooseCorporation(c util.Context, userID string, corpID int32) error

func (*State) RequiresCorpToBeManaged

func (s *State) RequiresCorpToBeManaged() bool

RequiresCorpToBeManaged determines if the current state requires an admin account to log in with a CEO character to manage that corporation.

func (*State) ShouldCorpReceiveAllianceData

func (s *State) ShouldCorpReceiveAllianceData() bool

ShouldCorpReceiveAllianceData determines if the current state requires the corporation to receive alliance-level data from peers automatically.

func (*State) ShouldCorpSendAllianceData

func (s *State) ShouldCorpSendAllianceData() bool

ShouldCorpSendAllianceData determines if the current state requires the corporation to send alliance-level data to peers automatically.

type Tags

type Tags struct {
	DB *db.DB
}

func (*Tags) GetLatestSnippets

func (t *Tags) GetLatestSnippets(ctx util.Context, display []data.Tag, n, length, maxHtmlDepth int, preferLang language.Tag) (map[string]*LatestTag, error)

GetLatestSnippets obtains the latest snippets

func (*Tags) GetThreadPreviewsForTag

func (t *Tags) GetThreadPreviewsForTag(ctx util.Context, g data.Tag, n, maxDepth, page int, preferLang language.Tag) ([]data.ThreadPreview, error)

GetThreadsPreviewsForTag obtains the latest threads for a given tag

type Threads

type Threads struct {
	DB *db.DB
}

func (*Threads) GetPosts

func (t *Threads) GetPosts(ctx util.Context, id string, n, page int, preferLang language.Tag) ([]data.Post, error)

type Users

type Users struct {
	F  app.Framework
	M  *mail.Mailer
	DB *db.DB
}

func (*Users) CreateUser

func (u *Users) CreateUser(ctx context.Context, username, email, password string, lang language.Tag) error

func (*Users) IsUserVerified

func (u *Users) IsUserVerified(c context.Context, userID string) (bool, error)

func (*Users) MarkUserVerified

func (u *Users) MarkUserVerified(c context.Context, token string) error

Jump to

Keyboard shortcuts

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