models

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2023 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIRateLimit

func APIRateLimit(ak *APIKey) (rate.Limit, int)

func Bootstrap

func Bootstrap(
	ctx context.Context,
	name, email, password, key string,
)

Create a user and API key. No validation is done. If A User exists no further operations are done.

func CacheRateLimit

func CacheRateLimit(c *CachedSite) (rate.Limit, int)

func ChangeSiteVisibility

func ChangeSiteVisibility(ctx context.Context, site *Site, public bool)

func Check

func Check(ctx context.Context) bool

Check performs health check on the database. This make sure we can query the database

func CleanupDOmain

func CleanupDOmain(domain string) string

func CloseDB

func CloseDB(db *gorm.DB) error

func CountOwnedSites

func CountOwnedSites(ctx context.Context, uid uint64) int64

CountOwnedSites counts sites owned by the user.

func CreateApiKey

func CreateApiKey(ctx context.Context, key, name string, uid uint64)

func CreateSite

func CreateSite(ctx context.Context, usr *User, domain string, public bool) bool

func Database

func Database(cfg *config.Options) string

func DeleteGoal

func DeleteGoal(ctx context.Context, gid, domain string) bool
func DeleteSharedLink(ctx context.Context, shared *SharedLink)

func DeleteSite

func DeleteSite(ctx context.Context, site *Site)

func EnableWeeklyReport

func EnableWeeklyReport(ctx context.Context, site *Site, usr *User)

func Exists

func Exists(ctx context.Context, where func(db *gorm.DB) *gorm.DB) bool

func Get

func Get(ctx context.Context) *gorm.DB

func GetRole

func GetRole(ctx context.Context) string

func GoalName

func GoalName(g *Goal) string

func HashAPIKey

func HashAPIKey(ctx context.Context, key string) string

func LOG

func LOG(ctx context.Context, err error, msg string, f ...func(*zerolog.Event) *zerolog.Event)

func NewUser

func NewUser(u *User, r *http.Request) (validation map[string]string, err error)

func Open

func Open(path string) (*gorm.DB, error)

func PasswordMatch

func PasswordMatch(u *User, pwd string) bool

func PreloadSite

func PreloadSite(ctx context.Context, u *Site, preload ...string)

func PreloadUser

func PreloadUser(ctx context.Context, u *User, preload ...string)

func ProcessAPIKey

func ProcessAPIKey(ctx context.Context, key string) (hash, prefix string)

func QuerySitesToCache

func QuerySitesToCache(ctx context.Context, fn func(*CachedSite)) (count float64)

func Role

func Role(ctx context.Context, uid, sid uint64) (role string)

func SafeDomain

func SafeDomain(s *Site) string

func Set

func Set(ctx context.Context, dbs *gorm.DB) context.Context

func SetPassword

func SetPassword(ctx context.Context, pwd string) (err string)

func SetRole

func SetRole(ctx context.Context, role string) context.Context

func SetSite

func SetSite(ctx context.Context, site *Site) context.Context

func SetUser

func SetUser(ctx context.Context, usr *User) context.Context

func SharedLinkURL

func SharedLinkURL(base string, site *Site, link *SharedLink) string

func SiteHasGoals

func SiteHasGoals(ctx context.Context, domain string) bool

func UpdateAPIKeyUse

func UpdateAPIKeyUse(ctx context.Context, aid uint64)
func UpdateSharedLink(ctx context.Context, shared *SharedLink, name, password string)

func UpdateSiteStartDate

func UpdateSiteStartDate(ctx context.Context, sid uint64, start time.Time)

func UserIsMember

func UserIsMember(ctx context.Context, uid, sid uint64) bool

func ValidateGoals

func ValidateGoals(event, path string) bool

func ValidateSiteDomain

func ValidateSiteDomain(ctx context.Context, domain string) (good, bad string)

Types

type APIKey

type APIKey = schema.APIKey

func APIKeyByID

func APIKeyByID(ctx context.Context, aid uint64) (a *APIKey)

func VerifyAPIKey

func VerifyAPIKey(ctx context.Context, key string) *APIKey

type CachedSite

type CachedSite struct {
	ID              uint64
	Domain          string
	StatsStartDate  time.Time
	IngestRateLimit sql.NullFloat64
	UserID          uint64
}

type CheckStatEmail

type CheckStatEmail = schema.CheckStatEmail

type CreateSiteEmail

type CreateSiteEmail = schema.CreateSiteEmail

type EmailVerificationCode

type EmailVerificationCode = schema.EmailVerificationCode

type FeedbackEmail

type FeedbackEmail = schema.FeedbackEmail

type Goal

type Goal = schema.Goal

func CreateGoal

func CreateGoal(ctx context.Context, domain, event, path string) *Goal

func GoalByEvent

func GoalByEvent(ctx context.Context, domain, event string) *Goal

func GoalByPage

func GoalByPage(ctx context.Context, domain, page string) *Goal

func Goals

func Goals(ctx context.Context, domain string) (o []*Goal)

type IntroEmail

type IntroEmail = schema.IntroEmail

type Invitation

type Invitation = schema.Invitation

type MonthlyReport

type MonthlyReport = schema.MonthlyReport

type SentMonthlyReport

type SentMonthlyReport = schema.SentMonthlyReport

type SentRenewalNotification

type SentRenewalNotification = schema.SentRenewalNotification

type SentWeeklyReport

type SentWeeklyReport = schema.SentWeeklyReport
type SharedLink = schema.SharedLink
func CreateSharedLink(ctx context.Context, sid uint64, name, password string) *SharedLink
func GetSharedLink(ctx context.Context, sid uint64, name string) *SharedLink

func GetSharedLinkWithSlug

func GetSharedLinkWithSlug(ctx context.Context, sid uint64, slug string) *SharedLink

type Site

type Site = schema.Site

func GetSite

func GetSite(ctx context.Context) *Site

func SiteByDomain

func SiteByDomain(ctx context.Context, domain string) *Site

func SiteFor

func SiteFor(ctx context.Context, uid uint64, domain string, roles ...string) *Site

type SiteMembership

type SiteMembership = schema.SiteMembership

type SiteOverView

type SiteOverView struct {
	Site *Site
}

type SpikeNotification

type SpikeNotification = schema.SpikeNotification

type Subscription

type Subscription = schema.Subscription

type User

type User = schema.User

func GetUser

func GetUser(ctx context.Context) *User

func SiteOwner

func SiteOwner(ctx context.Context, sid uint64) *User

func UserByEmail

func UserByEmail(ctx context.Context, email string) *User

func UserByID

func UserByID(ctx context.Context, uid uint64) (u *User)

func UserByUID

func UserByUID(ctx context.Context, uid uint64) (u *User)

type WeeklyReport

type WeeklyReport = schema.WeeklyReport

Jump to

Keyboard shortcuts

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