models

package
v0.0.0-...-ef20829 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PasswordAuthFactor = AuthFactorType(iota)
	EmailPasswordFactor
	TimeOtpFactor
	InAppNotifyFactor
)
View Source
const (
	NotifySubscriberFirebase = "firebase"
	NotifySubscriberAPNs     = "apple"
)
View Source
const (
	PunishmentTypeStrike = iota
	PunishmentTypeLimited
	PunishmentTypeDisabled
)
View Source
const (
	RealmPopularityMemberFactor = 5
	RealmPopularityPostFactor   = 10
	RealmPopularityChatFactor   = 2
)
View Source
const (
	RelationshipPending = RelationshipStatus(iota)
	RelationshipFriend
	RelationshipBlocked
	RelationshipWaiting
)
View Source
const (
	ReportStatusPending   = "pending"
	ReportStatusReviewing = "reviewing"
	ReportStatusConfirmed = "confirmed"
	ReportStatusRejected  = "rejected"
	ReportStatusProcessed = "processed"
)
View Source
const (
	AttitudeNeutral = StatusAttitude(iota)
	AttitudePositive
	AttitudeNegative
)
View Source
const (
	ConfirmMagicToken = MagicTokenType(iota)
	RegistrationMagicToken
	ResetPasswordMagicToken
	DeleteAccountMagicToken
)
View Source
const (
	EmailAccountContact = AccountContactType(iota)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AbuseReport

type AbuseReport struct {
	BaseModel

	Resource  string  `json:"resource"`
	Reason    string  `json:"reason"`
	Status    string  `json:"status"`
	AccountID uint    `json:"account_id"`
	Account   Account `json:"account"`
}

type Account

type Account struct {
	BaseModel

	Name        string            `json:"name" gorm:"uniqueIndex"`
	Nick        string            `json:"nick"`
	Avatar      *string           `json:"avatar"`
	Banner      *string           `json:"banner"`
	ConfirmedAt *time.Time        `json:"confirmed_at"`
	SuspendedAt *time.Time        `json:"suspended_at"`
	PermNodes   datatypes.JSONMap `json:"perm_nodes"`
	Language    string            `json:"language"`

	AutomatedBy *Account `json:"automated_by" gorm:"foreignKey:AutomatedID"`
	AutomatedID *uint    `json:"automated_id"`

	AffiliatedTo *Realm `json:"affiliated_to" gorm:"foreignKey:AffiliatedID"`
	AffiliatedID *uint  `json:"affiliated_id"`

	Profile  AccountProfile   `json:"profile,omitempty"`
	Contacts []AccountContact `json:"contacts,omitempty"`
	Badges   []Badge          `json:"badges,omitempty"`

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

	Relations []AccountRelationship `json:"relations,omitempty" gorm:"foreignKey:AccountID"`

	Punishments []Punishment `json:"punishments,omitempty"`

	// Keep this for backward compability
	Description string `json:"description" gorm:"-"`
}

func (Account) EncodeToUserInfo

func (v Account) EncodeToUserInfo() *proto.UserInfo

func (Account) GetAvatar

func (v Account) GetAvatar() *string

func (Account) GetBanner

func (v Account) GetBanner() *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 AccountGroup

type AccountGroup struct {
	BaseModel

	Name      string            `json:"name"`
	PermNodes datatypes.JSONMap `json:"perm_nodes"`
}

type AccountGroupMember

type AccountGroupMember struct {
	BaseModel

	Account   Account      `json:"account"`
	Group     AccountGroup `json:"group"`
	AccountID uint         `json:"account_id"`
	GroupID   uint         `json:"group_id"`
}

type AccountPage

type AccountPage struct {
	BaseModel

	Content   string `json:"content"`
	AccountID uint   `json:"account_id"`
}

type AccountProfile

type AccountProfile struct {
	BaseModel

	FirstName   string            `json:"first_name"`
	LastName    string            `json:"last_name"`
	Description string            `json:"description"`
	TimeZone    string            `json:"time_zone"`
	Location    string            `json:"location"`
	Pronouns    string            `json:"pronouns"`
	Gender      string            `json:"gender"`
	Links       datatypes.JSONMap `json:"links"`
	Experience  uint64            `json:"experience"`
	LastSeenAt  *time.Time        `json:"last_seen_at"`
	Birthday    *time.Time        `json:"birthday"`
	AccountID   uint              `json:"account_id"`
}

type AccountRelationship

type AccountRelationship struct {
	BaseModel

	AccountID uint               `json:"account_id"`
	RelatedID uint               `json:"related_id"`
	Account   Account            `json:"account"`
	Related   Account            `json:"related"`
	Status    RelationshipStatus `json:"status"`
	PermNodes datatypes.JSONMap  `json:"perm_nodes"`
}

type ActionEvent

type ActionEvent struct {
	BaseModel

	Type        string            `json:"type"`
	Metadata    datatypes.JSONMap `json:"metadata"`
	Location    *string           `json:"location"`
	CoordinateX *float64          `json:"coordinate_x"`
	CoordinateY *float64          `json:"coordinate_y"`
	IpAddress   string            `json:"ip_address"`
	UserAgent   string            `json:"user_agent"`

	Account   Account `json:"account"`
	AccountID uint    `json:"account_id"`
}

type ApiKey

type ApiKey struct {
	BaseModel

	Name        string     `json:"name"`
	Description string     `json:"description"`
	Lifecycle   *int64     `json:"lifecycle"`
	Ticket      AuthTicket `json:"ticket" gorm:"TicketID"`
	TicketID    uint       `json:"ticket_id"`
	Account     Account    `json:"account"`
	AccountID   uint       `json:"account_id"`
}

type AuditRecord

type AuditRecord struct {
	BaseModel

	Action      string            `json:"action"`
	Metadata    datatypes.JSONMap `json:"metadata"`
	Location    *string           `json:"location"`
	CoordinateX *float64          `json:"coordinate_x"`
	CoordinateY *float64          `json:"coordinate_y"`
	UserAgent   string            `json:"user_agent"`
	IpAddress   string            `json:"ip_address"`
	AccountID   uint              `json:"account_id"`
}

type AuthConfig

type AuthConfig struct {
	AlwaysRisky      bool `json:"always_risky"`
	MaximumAuthSteps int  `json:"maximum_auth_steps" validate:"required,min=1,max=99"`
}

type AuthContext

type AuthContext struct {
	Ticket  AuthTicket `json:"ticket"`
	Account Account    `json:"account"`
}

type AuthFactor

type AuthFactor struct {
	BaseModel

	Type   int8              `json:"type"`
	Secret string            `json:"-"`
	Config datatypes.JSONMap `json:"config"`

	Account   Account `json:"account"`
	AccountID uint    `json:"account_id"`
}

type AuthFactorType

type AuthFactorType = int8

type AuthTicket

type AuthTicket struct {
	BaseModel

	Location     *string                     `json:"location"`
	CoordinateX  *float64                    `json:"coordinate_x"`
	CoordinateY  *float64                    `json:"coordinate_y"`
	IpAddress    string                      `json:"ip_address"`
	UserAgent    string                      `json:"user_agent"`
	StepRemain   int                         `json:"step_remain"`
	Claims       datatypes.JSONSlice[string] `json:"claims"`
	Audiences    datatypes.JSONSlice[string] `json:"audiences"`
	FactorTrail  datatypes.JSONSlice[int]    `json:"factor_trail"`
	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"`
	Nonce        *string                     `json:"nonce"`
	ClientID     *uint                       `json:"client_id"`

	Account   Account `json:"account"`
	AccountID uint    `json:"account_id"`
}

func (AuthTicket) IsAvailable

func (v AuthTicket) IsAvailable() error

func (AuthTicket) IsCanBeAvailble

func (v AuthTicket) IsCanBeAvailble() error

type Badge

type Badge struct {
	BaseModel

	Type      string            `json:"type"`
	Metadata  datatypes.JSONMap `json:"metadata"`
	IsActive  bool              `json:"is_active"`
	AccountID uint              `json:"account_id"`
}

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 CheckInRecord

type CheckInRecord struct {
	BaseModel

	ResultTier       int     `json:"result_tier"`
	ResultExperience int     `json:"result_experience"`
	ResultCoin       float64 `json:"result_coin"`
	CurrentStreak    int     `json:"current_streak"`

	// The result modifiers are some random tips that will show up in the client;
	// This field is to use to make sure the tips will be the same when the client is reloaded.
	// For now, this modifier slice will contain four random numbers from 0 to 1024.
	// Client should mod this modifier by the length of total available tips.
	ResultModifiers datatypes.JSONSlice[int] `json:"result_modifiers"`

	Account   Account `json:"account"`
	AccountID uint    `json:"account_id"`
}

type JSONMap

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

type MagicToken

type MagicToken struct {
	BaseModel

	Code           string     `json:"code"`
	Type           int8       `json:"type"`
	AccountID      *uint      `json:"account_id"`
	ExpiredAt      *time.Time `json:"expired_at"`
	LastNotifiedAt *time.Time `json:"last_notified_at"`
}

type MagicTokenType

type MagicTokenType = int8

type Notification

type Notification struct {
	BaseModel

	Topic    string            `json:"topic"`
	Title    string            `json:"title"`
	Subtitle string            `json:"subtitle"`
	Body     string            `json:"body"`
	Metadata datatypes.JSONMap `json:"metadata"`
	Priority int               `json:"priority"`
	SenderID *uint             `json:"sender_id"`

	Account   Account `json:"account"`
	AccountID uint    `json:"account_id"`

	ReadAt *time.Time `json:"read_at"`
}

func NewNotificationFromPushkit

func NewNotificationFromPushkit(pk pushkit.Notification) Notification

func (Notification) EncodeToPushkit

func (v Notification) EncodeToPushkit() pushkit.Notification

type NotificationSubscriber

type NotificationSubscriber struct {
	BaseModel

	UserAgent   string `json:"user_agent"`
	Provider    string `json:"provider"`
	DeviceID    string `json:"device_id" gorm:"uniqueIndex"`
	DeviceToken string `json:"device_token"`

	Account   Account `json:"account"`
	AccountID uint    `json:"account_id"`
}

type PreferenceAuth

type PreferenceAuth struct {
	BaseModel

	Config    datatypes.JSONType[AuthConfig] `json:"config"`
	AccountID uint                           `json:"account_id"`
	Account   Account                        `json:"account"`
}

type PreferenceNotification

type PreferenceNotification struct {
	BaseModel

	Config    datatypes.JSONMap `json:"config"`
	AccountID uint              `json:"account_id"`
	Account   Account           `json:"account"`
}

type Program

type Program struct {
	BaseModel

	Name           string                           `json:"name"`
	Description    string                           `json:"description"`
	Alias          string                           `json:"alias" gorm:"uniqueIndex"`
	ExpRequirement int64                            `json:"exp_requirement"`
	Price          datatypes.JSONType[ProgramPrice] `json:"price"`
	Badge          datatypes.JSONType[ProgramBadge] `json:"badge"`
	Group          datatypes.JSONType[ProgramGroup] `json:"group"`
	Appearance     datatypes.JSONMap                `json:"appearance"`
}

type ProgramBadge

type ProgramBadge struct {
	Type     string         `json:"type"`
	Metadata map[string]any `json:"metadata"`
}

type ProgramGroup

type ProgramGroup struct {
	ID uint `json:"id"`
}

type ProgramMember

type ProgramMember struct {
	BaseModel

	LastPaid  *time.Time `json:"last_paid"`
	Account   Account    `json:"account"`
	AccountID uint       `json:"account_id"`
	Program   Program    `json:"program"`
	ProgramID uint       `json:"program_id"`
}

type ProgramPrice

type ProgramPrice struct {
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount"`
}

type Punishment

type Punishment struct {
	BaseModel

	Reason      string            `json:"reason"`
	Type        int               `json:"type"`
	PermNodes   datatypes.JSONMap `json:"perm_nodes"`
	ExpiredAt   *time.Time        `json:"expired_at"`
	Account     Account           `json:"account"`
	AccountID   uint              `json:"account_id"`
	Moderator   *Account          `json:"moderator"`
	ModeratorID *uint             `json:"moderator_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"`
	Avatar       *string           `json:"avatar"`
	Banner       *string           `json:"banner"`
	Popularity   int               `json:"popularity"`
	AccessPolicy datatypes.JSONMap `json:"access_policy"`
	IsPublic     bool              `json:"is_public"`
	IsCommunity  bool              `json:"is_community"`
	AccountID    uint              `json:"account_id"`
}

func NewRealmFromProto

func NewRealmFromProto(proto *proto.RealmInfo) Realm

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"`
}

func NewRealmMemberFromProto

func NewRealmMemberFromProto(proto *proto.RealmMemberInfo) RealmMember

type RelationshipStatus

type RelationshipStatus = int8

type Status

type Status struct {
	BaseModel

	Type        string         `json:"type"`
	Label       string         `json:"label"`
	Attitude    StatusAttitude `json:"attitude"`
	IsNoDisturb bool           `json:"is_no_disturb"`
	IsInvisible bool           `json:"is_invisible"`
	ClearAt     *time.Time     `json:"clear_at"`
	AccountID   uint           `json:"account_id"`
}

type StatusAttitude

type StatusAttitude = uint8

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"`
	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