models

package
v0.0.0-...-35f9580 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PasswordAuthFactor = AuthFactorType(iota)
	EmailPasswordFactor
)
View Source
const (
	FriendshipPending = FriendshipStatus(iota)
	FriendshipActive
	FriendshipBlocked
)
View Source
const (
	ConfirmMagicToken = MagicTokenType(iota)
	RegistrationMagicToken
)
View Source
const (
	EmailAccountContact = AccountContactType(iota)
)
View Source
const (
	NotifySubscriberFirebase = "firebase"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	BaseModel

	Name        string     `json:"name" gorm:"uniqueIndex"`
	Nick        string     `json:"nick"`
	Description string     `json:"description"`
	Avatar      string     `json:"avatar"`
	Banner      string     `json:"banner"`
	ConfirmedAt *time.Time `json:"confirmed_at"`
	PowerLevel  int        `json:"power_level"`

	Profile         AccountProfile   `json:"profile"`
	PersonalPage    AccountPage      `json:"personal_page"`
	Contacts        []AccountContact `json:"contacts"`
	RealmIdentities []RealmMember    `json:"realm_identities"`

	Tickets []AuthTicket `json:"tickets"`
	Factors []AuthFactor `json:"factors"`

	Events      []ActionEvent `json:"events"`
	MagicTokens []MagicToken  `json:"-" gorm:"foreignKey:AssignTo"`

	ThirdClients []ThirdClient `json:"clients"`

	Notifications     []Notification           `json:"notifications" gorm:"foreignKey:RecipientID"`
	NotifySubscribers []NotificationSubscriber `json:"notify_subscribers"`

	Friendships        []AccountFriendship `json:"friendships" gorm:"foreignKey:AccountID"`
	RelatedFriendships []AccountFriendship `json:"related_friendships" gorm:"foreignKey:RelatedID"`
}

func (Account) GetAvatarPath

func (v Account) GetAvatarPath() string

func (Account) GetBannerPath

func (v Account) GetBannerPath() string

func (Account) GetPrimaryEmail

func (v Account) GetPrimaryEmail() AccountContact

type AccountContact

type AccountContact struct {
	BaseModel

	Type       int8       `json:"type"`
	Content    string     `json:"content" gorm:"uniqueIndex"`
	IsPublic   bool       `json:"is_public"`
	IsPrimary  bool       `json:"is_primary"`
	VerifiedAt *time.Time `json:"verified_at"`
	AccountID  uint       `json:"account_id"`
}

type AccountContactType

type AccountContactType = int8

type AccountFriendship

type AccountFriendship struct {
	BaseModel

	AccountID uint             `json:"account_id"`
	RelatedID uint             `json:"related_id"`
	BlockedBy *uint            `json:"blocked_by"`
	Account   Account          `json:"account"`
	Related   Account          `json:"related"`
	Status    FriendshipStatus `json:"status"`
}

type AccountPage

type AccountPage struct {
	BaseModel

	Content   string                                `json:"content"`
	Script    string                                `json:"script"`
	Style     string                                `json:"style"`
	Links     datatypes.JSONSlice[AccountPageLinks] `json:"links"`
	AccountID uint                                  `json:"account_id"`
}
type AccountPageLinks struct {
	Label string `json:"label"`
	Url   string `json:"url"`
}

type AccountProfile

type AccountProfile struct {
	BaseModel

	FirstName  string     `json:"first_name"`
	LastName   string     `json:"last_name"`
	Experience uint64     `json:"experience"`
	Birthday   *time.Time `json:"birthday"`
	AccountID  uint       `json:"account_id"`
}

type ActionEvent

type ActionEvent struct {
	BaseModel

	Type      string `json:"type"`
	Target    string `json:"target"`
	Location  string `json:"location"`
	IpAddress string `json:"ip_address"`
	UserAgent string `json:"user_agent"`
	AccountID uint   `json:"account_id"`
}

type AuthContext

type AuthContext struct {
	Ticket    AuthTicket `json:"ticket"`
	Account   Account    `json:"account"`
	ExpiredAt time.Time  `json:"expired_at"`
}

type AuthFactor

type AuthFactor struct {
	BaseModel

	Type      int8    `json:"type"`
	Secret    string  `json:"-"`
	Config    JSONMap `json:"config"`
	AccountID uint    `json:"account_id"`
}

type AuthFactorType

type AuthFactorType = int8

type AuthTicket

type AuthTicket struct {
	BaseModel

	Location            string                      `json:"location"`
	IpAddress           string                      `json:"ip_address"`
	UserAgent           string                      `json:"user_agent"`
	RequireMFA          bool                        `json:"require_mfa"`
	RequireAuthenticate bool                        `json:"require_authenticate"`
	Claims              datatypes.JSONSlice[string] `json:"claims"`
	Audiences           datatypes.JSONSlice[string] `json:"audiences"`
	GrantToken          *string                     `json:"grant_token"`
	AccessToken         *string                     `json:"access_token"`
	RefreshToken        *string                     `json:"refresh_token"`
	ExpiredAt           *time.Time                  `json:"expired_at"`
	AvailableAt         *time.Time                  `json:"available_at"`
	LastGrantAt         *time.Time                  `json:"last_grant_at"`
	ClientID            *uint                       `json:"client_id"`
	AccountID           uint                        `json:"account_id"`
}

func (AuthTicket) IsAvailable

func (v AuthTicket) IsAvailable() error

type BaseModel

type BaseModel struct {
	ID        uint           `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

type FriendshipStatus

type FriendshipStatus = int8

type JSONMap

type JSONMap = datatypes.JSONType[map[string]any]

type MagicToken

type MagicToken struct {
	BaseModel

	Code      string     `json:"code"`
	Type      int8       `json:"type"`
	AssignTo  *uint      `json:"assign_to"`
	ExpiredAt *time.Time `json:"expired_at"`
}

type MagicTokenType

type MagicTokenType = int8

type Notification

type Notification struct {
	BaseModel

	Subject     string                                `json:"subject"`
	Content     string                                `json:"content"`
	Links       datatypes.JSONSlice[NotificationLink] `json:"links"`
	IsImportant bool                                  `json:"is_important"`
	IsRealtime  bool                                  `json:"is_realtime" gorm:"-"`
	ReadAt      *time.Time                            `json:"read_at"`
	SenderID    *uint                                 `json:"sender_id"`
	RecipientID uint                                  `json:"recipient_id"`
}
type NotificationLink struct {
	Label string `json:"label"`
	Url   string `json:"url"`
}

NotificationLink Used to embed into notify and render actions

type NotificationSubscriber

type NotificationSubscriber struct {
	BaseModel

	UserAgent string `json:"user_agent"`
	Provider  string `json:"provider"`
	DeviceID  string `json:"device_id" gorm:"uniqueIndex"`
	AccountID uint   `json:"account_id"`
}

type Realm

type Realm struct {
	BaseModel

	Alias       string        `json:"alias" gorm:"uniqueIndex"`
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Members     []RealmMember `json:"members"`
	IsPublic    bool          `json:"is_public"`
	IsCommunity bool          `json:"is_community"`
	AccountID   uint          `json:"account_id"`
}

type RealmMember

type RealmMember struct {
	BaseModel

	RealmID    uint    `json:"realm_id"`
	AccountID  uint    `json:"account_id"`
	Realm      Realm   `json:"realm"`
	Account    Account `json:"account"`
	PowerLevel int     `json:"power_level"`
}

type ThirdClient

type ThirdClient struct {
	BaseModel

	Alias         string                      `json:"alias" gorm:"uniqueIndex"`
	Name          string                      `json:"name"`
	Description   string                      `json:"description"`
	Secret        string                      `json:"secret"`
	Urls          datatypes.JSONSlice[string] `json:"urls"`
	Callbacks     datatypes.JSONSlice[string] `json:"callbacks"`
	Sessions      []AuthTicket                `json:"tickets" gorm:"foreignKey:ClientID"`
	Notifications []Notification              `json:"notifications" gorm:"foreignKey:SenderID"`
	IsDraft       bool                        `json:"is_draft"`
	AccountID     *uint                       `json:"account_id"`
}

Jump to

Keyboard shortcuts

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