Optimized userinfo endpoint

This commit is contained in:
2024-02-01 15:08:40 +08:00
parent cfc1115b2f
commit e2b609cf43
8 changed files with 170 additions and 30 deletions

View File

@ -19,20 +19,21 @@ const (
type Account struct {
BaseModel
Name string `json:"name" gorm:"uniqueIndex"`
Nick string `json:"nick"`
Avatar string `json:"avatar"`
State AccountState `json:"state"`
Profile AccountProfile `json:"profile"`
Sessions []AuthSession `json:"sessions"`
Challenges []AuthChallenge `json:"challenges"`
Factors []AuthFactor `json:"factors"`
Contacts []AccountContact `json:"contacts"`
Events []ActionEvent `json:"events"`
MagicTokens []MagicToken `json:"-" gorm:"foreignKey:AssignTo"`
ThirdClients []ThirdClient `json:"clients"`
ConfirmedAt *time.Time `json:"confirmed_at"`
Permissions datatypes.JSONType[[]string] `json:"permissions"`
Name string `json:"name" gorm:"uniqueIndex"`
Nick string `json:"nick"`
Avatar string `json:"avatar"`
State AccountState `json:"state"`
Profile AccountProfile `json:"profile"`
Sessions []AuthSession `json:"sessions"`
Challenges []AuthChallenge `json:"challenges"`
Factors []AuthFactor `json:"factors"`
Contacts []AccountContact `json:"contacts"`
Events []ActionEvent `json:"events"`
MagicTokens []MagicToken `json:"-" gorm:"foreignKey:AssignTo"`
ThirdClients []ThirdClient `json:"clients"`
Notifications []Notification `json:"notifications" gorm:"foreignKey:RecipientID"`
ConfirmedAt *time.Time `json:"confirmed_at"`
Permissions datatypes.JSONType[[]string] `json:"permissions"`
}
func (v Account) GetPrimaryEmail() AccountContact {

View File

@ -0,0 +1,13 @@
package models
import "time"
type Notification struct {
BaseModel
Subject string `json:"subject"`
Content string `json:"content"`
IsImportant bool `json:"is_important"`
ReadAt *time.Time `json:"read_at"`
RecipientID uint `json:"recipient_id"`
}