♻️ Move realm system to Passport

This commit is contained in:
2024-05-04 22:22:58 +08:00
parent 1181b1e5ce
commit f78a1447d5
20 changed files with 344 additions and 428 deletions

View File

@ -2,26 +2,24 @@ package models
import "time"
// Account profiles basically fetched from Hydrogen.Identity
// Account profiles basically fetched from Hydrogen.Passport
// But cache at here for better usage
// At the same time this model can make relations between local models
type Account struct {
BaseModel
Name string `json:"name"`
Nick string `json:"nick"`
Avatar string `json:"avatar"`
Banner string `json:"banner"`
Description string `json:"description"`
EmailAddress string `json:"email_address"`
PowerLevel int `json:"power_level"`
Moments []Moment `json:"moments" gorm:"foreignKey:AuthorID"`
Articles []Article `json:"articles" gorm:"foreignKey:AuthorID"`
Attachments []Attachment `json:"attachments" gorm:"foreignKey:AuthorID"`
Reactions []Reaction `json:"reactions"`
RealmIdentities []RealmMember `json:"identities"`
Realms []Realm `json:"realms"`
ExternalID uint `json:"external_id"`
Name string `json:"name"`
Nick string `json:"nick"`
Avatar string `json:"avatar"`
Banner string `json:"banner"`
Description string `json:"description"`
EmailAddress string `json:"email_address"`
PowerLevel int `json:"power_level"`
Moments []Moment `json:"moments" gorm:"foreignKey:AuthorID"`
Articles []Article `json:"articles" gorm:"foreignKey:AuthorID"`
Attachments []Attachment `json:"attachments" gorm:"foreignKey:AuthorID"`
Reactions []Reaction `json:"reactions"`
ExternalID uint `json:"external_id"`
}
type AccountMembership struct {

View File

@ -1,30 +1,16 @@
package models
type RealmType = int
const (
RealmTypePublic = RealmType(iota)
RealmTypeRestricted
RealmTypePrivate
)
// Realm profiles basically fetched from Hydrogen.Passport
// But cache at here for better usage and database relations
type Realm struct {
BaseModel
Name string `json:"name"`
Description string `json:"description"`
Articles []Article `json:"article"`
Moments []Moment `json:"moments"`
Members []RealmMember `json:"members"`
RealmType RealmType `json:"realm_type"`
AccountID uint `json:"account_id"`
}
type RealmMember struct {
BaseModel
RealmID uint `json:"realm_id"`
AccountID uint `json:"account_id"`
Realm Realm `json:"realm"`
Account Account `json:"account"`
Alias string `json:"alias"`
Name string `json:"name"`
Description string `json:"description"`
Articles []Article `json:"article"`
Moments []Moment `json:"moments"`
IsPublic bool `json:"is_public"`
IsCommunity bool `json:"is_community"`
ExternalID uint `json:"external_id"`
}