services

package
v0.0.0-...-f77d796 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicOrgID       = "45dc89a6-e6f0-11e8-8bc1-6f4d565e3ddb"
	PublicRootTopicID = "df63295e-ee02-11e8-9e36-17d56b662bc8"
)

Hard-coded constants.

Variables

View Source
var (
	ErrInvalidLogin = errors.New("not a valid login")
)

Error constants.

Functions

func DisplayName

func DisplayName(
	timerange *models.Timerange, synonyms *models.SynonymList, locale models.LocaleIdentifier,
) (string, error)

DisplayName constructs a display name from a SynonymList and a Timerange.

func NormalizeTopicName

func NormalizeTopicName(name string) (string, bool)

NormalizeTopicName returns a normalized topic name and indicates whether the name is valid.

Types

type CleanupFunc

type CleanupFunc func() error

CleanupFunc is a function that can be called to roll back the effects of a service call.

type CompleteRegistration

type CompleteRegistration struct {
	User  *models.User
	Login string
}

CompleteRegistration holds information for completing a registration.

func (CompleteRegistration) Call

Call finishes the registration process by creating an organization and a repo for the user.

type CompleteRegistrationResult

type CompleteRegistrationResult struct {
	*CreateRepositoryResult
	Alerts       []*models.Alert
	Organization *models.Organization
}

CompleteRegistrationResult holds the result of a CreateUser call.

type Connection

type Connection struct {
	Exec    boil.ContextExecutor
	Actor   *models.User
	Fetcher pageinfo.Fetcher
}

Connection holds fields used by service calls.

func New

func New(
	exec boil.ContextExecutor, actor *models.User, fetcher pageinfo.Fetcher,
) *Connection

New returns a new service connection

func (Connection) CreateGithubAccount

func (c Connection) CreateGithubAccount(
	ctx context.Context, user *models.User, username, name, primaryEmail, avatarURL string,
) (*CreateGithubAccountResult, error)

CreateGithubAccount creates a new github account.

func (Connection) CreateGithubSession

func (c Connection) CreateGithubSession(
	ctx context.Context, name, primaryEmail, githubUsername, githubAvatarURL string,
) (*CreateSessionResult, error)

CreateGithubSession creates a new session for the user. If the user is not found in the database, a new user is created.

func (Connection) CreateGoogleAccount

func (c Connection) CreateGoogleAccount(
	ctx context.Context, user *models.User, profileID, name, primaryEmail, avatarURL string,
) (*CreateGoogleAccountResult, error)

CreateGoogleAccount creates a new github account.

func (Connection) CreateGoogleSession

func (c Connection) CreateGoogleSession(
	ctx context.Context, name, primaryEmail, profileID, googleAvatarURL string,
) (*CreateSessionResult, error)

CreateGoogleSession creates a new session for the user. If the user is not found in the database, a new user is created.

func (Connection) DeleteAccount

func (c Connection) DeleteAccount(
	ctx context.Context, user *models.User,
) (*DeleteAccountResult, error)

DeleteAccount hard-deletes the account and any private data associated with it. Topics and links added to public repos are not deleted.

func (c Connection) DeleteLink(
	ctx context.Context, repo *models.Repository, link *models.Link,
) (*DeleteLinkResult, error)

DeleteLink removes a link from a repo.

func (Connection) DeleteTopicTimeRange

func (c Connection) DeleteTopicTimeRange(
	ctx context.Context, topic *models.Topic,
) (*DeleteTopicTimeRangeResult, error)

DeleteTopicTimeRange removes a time range from a topic.

func (c Connection) ReviewLink(
	ctx context.Context, link *models.Link, reviewed bool,
) (*ReviewLinkResult, error)

ReviewLink toggles whether a link has been reviewed.

func (Connection) UpdateSynonyms

func (c Connection) UpdateSynonyms(
	ctx context.Context, topic *models.Topic, synonyms []models.Synonym,
) (*UpdateSynonymsResult, error)

UpdateSynonyms updates the synonyms of the topic.

func (Connection) UpdateTopic

func (c Connection) UpdateTopic(
	ctx context.Context, topic *models.Topic, name string, description *string,
) (*UpdateTopicResult, error)

UpdateTopic updates fields on the topic.

func (Connection) UpsertTopic

func (c Connection) UpsertTopic(
	ctx context.Context, repo *models.Repository, name string, description *string,
	parentTopicIds []string,
) (*UpsertTopicResult, error)

UpsertTopic updates a topic if it exists and creates it if it does not exist.

func (Connection) UpsertTopicTimeRange

func (c Connection) UpsertTopicTimeRange(
	ctx context.Context, topic *models.Topic, startsAt time.Time, endsAt *time.Time, format models.TimeRangePrefixFormat,
) (*UpsertTopicTimeRangeResult, error)

UpsertTopicTimeRange adds a timeline to a topic.

type CreateGithubAccountResult

type CreateGithubAccountResult struct {
	Alerts  []*models.Alert
	Account *models.GithubAccount
}

CreateGithubAccountResult holds the result of attempting to create a new Github account.

type CreateGoogleAccountResult

type CreateGoogleAccountResult struct {
	Alerts  []*models.Alert
	Account *models.GoogleAccount
}

CreateGoogleAccountResult holds the result of attempting to create a new Github account.

type CreateRepository

type CreateRepository struct {
	Organization *models.Organization
	Name         string
	Owner        *models.User
	System       bool
}

CreateRepository holds parameters for creating a new repository.

func (*CreateRepository) Call

Call adds a new repository to the database.

type CreateRepositoryResult

type CreateRepositoryResult struct {
	Repository *models.Repository
	RootTopic  *models.Topic
}

CreateRepositoryResult holds the result of a CreateRepository service call.

type CreateSessionResult

type CreateSessionResult struct {
	Alerts  []*models.Alert
	Cleanup CleanupFunc
	Session *models.Session
	User    *models.User
}

CreateSessionResult holds the result of a Create{Github,Google}Session service call.

type CreateUser

type CreateUser struct {
	Name      string
	Email     string
	AvatarURL string
}

CreateUser holds the information needed to create a new user.

func (CreateUser) Call

Call creates a new user and provides a default organization and repo for him/her.

type CreateUserResult

type CreateUserResult struct {
	Alerts []*models.Alert
	User   *models.User
}

CreateUserResult holds the result of a CreateUser call.

type DeleteAccountResult

type DeleteAccountResult struct {
	Alerts        []*models.Alert
	DeletedUserID string
}

DeleteAccountResult holds the result of deleting an account.

type DeleteLinkResult

type DeleteLinkResult struct {
	Cleanup       CleanupFunc
	DeletedLinkID string
}

DeleteLinkResult holds the result of a DeleteLink call.

type DeleteTopic

type DeleteTopic struct {
	Actor *models.User
	Topic *models.Topic
}

DeleteTopic deletes a topic and associated relations.

func (DeleteTopic) Call

Call removes a time range from a topic.

type DeleteTopicResult

type DeleteTopicResult struct {
	Alerts         []*models.Alert
	DeletedTopicID *string
}

DeleteTopicResult holds the result of an attempt to delete a topic.

type DeleteTopicTimeRangeResult

type DeleteTopicTimeRangeResult struct {
	Alerts             []*models.Alert
	Topic              *models.Topic
	DeletedTimeRangeID *string
}

DeleteTopicTimeRangeResult holds the result of an attempt to delete the time range on a topic.

type ReviewLinkResult

type ReviewLinkResult struct {
	Link   *models.Link
	Review *models.UserLinkReview
}

ReviewLinkResult holds the result of a ReviewLink call.

type UpdateLinkTopics

type UpdateLinkTopics struct {
	Actor          *models.User
	ParentTopicIds []string
	Link           *models.LinkValue
}

UpdateLinkTopics is used to update the topics on a link. If there are no topics, the link is added to the "Everything" topic. The link_transitive_closure table is also updated.

func (UpdateLinkTopics) Call

Call executes the mutation

type UpdateLinkTopicsResult

type UpdateLinkTopicsResult struct {
	Link *models.LinkValue
}

UpdateLinkTopicsResult holds the result of an updating of the topics on a link

type UpdateSynonymsResult

type UpdateSynonymsResult struct {
	Alerts []*models.Alert
	Topic  *models.Topic
}

UpdateSynonymsResult holds the result after updating the synonyms on a topic.

type UpdateTopicParentTopics

type UpdateTopicParentTopics struct {
	Actor          *models.User
	Topic          *models.TopicValue
	ParentTopicIds []string
}

UpdateTopicParentTopics updates the parent topics of a topic

func (UpdateTopicParentTopics) Call

Call updates the parent topics of a topic.

type UpdateTopicParentTopicsResult

type UpdateTopicParentTopicsResult struct {
	Alerts []*models.Alert
	Topic  *models.TopicValue
}

UpdateTopicParentTopicsResult holds the result of an UpdateTopicParentTopics call.

type UpdateTopicResult

type UpdateTopicResult struct {
	Alerts []*models.Alert
	Topic  *models.Topic
}

UpdateTopicResult holds the result of an UpdateTopic call.

type UpsertLink struct {
	Actor          *models.User
	Fetcher        pageinfo.Fetcher
	ParentTopicIds []string
	ProvidedTitle  *string
	ProvidedURL    string
	Repository     *models.Repository
}

UpsertLink adds a link if it does not yet exist in the database or updates information about the link if it is found.

func (UpsertLink) Call

Call performs the mutation

type UpsertLinkResult

type UpsertLinkResult struct {
	Alerts      []*models.Alert
	Link        *models.Link
	LinkCreated bool
}

UpsertLinkResult holds the result of an UpsertLink call.

type UpsertTopicResult

type UpsertTopicResult struct {
	Alerts       []*models.Alert
	Topic        *models.Topic
	TopicCreated bool
}

UpsertTopicResult holds the result of an UpsertTopic call.

type UpsertTopicTimeRangeResult

type UpsertTopicTimeRangeResult struct {
	Alerts    []*models.Alert
	Topic     *models.Topic
	TimeRange *models.Timerange
}

UpsertTopicTimeRangeResult returns the result of an upsert call.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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