This commit is contained in:
parent
08f6de0bd7
commit
5e93ecee73
12 changed files with 241 additions and 109 deletions
|
@ -32,13 +32,13 @@ func newUserRemoteLinks(db *gorm.DB, opts ...gen.DOOption) userRemoteLinks {
|
|||
_userRemoteLinks.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_userRemoteLinks.UserId = field.NewString(tableName, "user_id")
|
||||
_userRemoteLinks.ApLink = field.NewString(tableName, "ap_link")
|
||||
_userRemoteLinks.ViewLink = field.NewString(tableName, "view_link")
|
||||
_userRemoteLinks.FollowersLink = field.NewString(tableName, "followers_link")
|
||||
_userRemoteLinks.FollowingLink = field.NewString(tableName, "following_link")
|
||||
_userRemoteLinks.ViewLink = field.NewField(tableName, "view_link")
|
||||
_userRemoteLinks.FollowersLink = field.NewField(tableName, "followers_link")
|
||||
_userRemoteLinks.FollowingLink = field.NewField(tableName, "following_link")
|
||||
_userRemoteLinks.InboxLink = field.NewString(tableName, "inbox_link")
|
||||
_userRemoteLinks.OutboxLink = field.NewString(tableName, "outbox_link")
|
||||
_userRemoteLinks.FeaturedLink = field.NewString(tableName, "featured_link")
|
||||
_userRemoteLinks.FeaturedTagsLink = field.NewString(tableName, "featured_tags_link")
|
||||
_userRemoteLinks.OutboxLink = field.NewField(tableName, "outbox_link")
|
||||
_userRemoteLinks.FeaturedLink = field.NewField(tableName, "featured_link")
|
||||
_userRemoteLinks.FeaturedTagsLink = field.NewField(tableName, "featured_tags_link")
|
||||
_userRemoteLinks.User = userRemoteLinksBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
|
@ -227,13 +227,13 @@ type userRemoteLinks struct {
|
|||
DeletedAt field.Field
|
||||
UserId field.String
|
||||
ApLink field.String
|
||||
ViewLink field.String
|
||||
FollowersLink field.String
|
||||
FollowingLink field.String
|
||||
ViewLink field.Field
|
||||
FollowersLink field.Field
|
||||
FollowingLink field.Field
|
||||
InboxLink field.String
|
||||
OutboxLink field.String
|
||||
FeaturedLink field.String
|
||||
FeaturedTagsLink field.String
|
||||
OutboxLink field.Field
|
||||
FeaturedLink field.Field
|
||||
FeaturedTagsLink field.Field
|
||||
User userRemoteLinksBelongsToUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
|
@ -257,13 +257,13 @@ func (u *userRemoteLinks) updateTableName(table string) *userRemoteLinks {
|
|||
u.DeletedAt = field.NewField(table, "deleted_at")
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.ApLink = field.NewString(table, "ap_link")
|
||||
u.ViewLink = field.NewString(table, "view_link")
|
||||
u.FollowersLink = field.NewString(table, "followers_link")
|
||||
u.FollowingLink = field.NewString(table, "following_link")
|
||||
u.ViewLink = field.NewField(table, "view_link")
|
||||
u.FollowersLink = field.NewField(table, "followers_link")
|
||||
u.FollowingLink = field.NewField(table, "following_link")
|
||||
u.InboxLink = field.NewString(table, "inbox_link")
|
||||
u.OutboxLink = field.NewString(table, "outbox_link")
|
||||
u.FeaturedLink = field.NewString(table, "featured_link")
|
||||
u.FeaturedTagsLink = field.NewString(table, "featured_tags_link")
|
||||
u.OutboxLink = field.NewField(table, "outbox_link")
|
||||
u.FeaturedLink = field.NewField(table, "featured_link")
|
||||
u.FeaturedTagsLink = field.NewField(table, "featured_tags_link")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ func newUserToBeing(db *gorm.DB, opts ...gen.DOOption) userToBeing {
|
|||
_userToBeing.ALL = field.NewAsterisk(tableName)
|
||||
_userToBeing.ID = field.NewUint64(tableName, "id")
|
||||
_userToBeing.UserId = field.NewString(tableName, "user_id")
|
||||
_userToBeing.Being = field.NewField(tableName, "being")
|
||||
_userToBeing.Being = field.NewString(tableName, "being")
|
||||
_userToBeing.User = userToBeingBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
|
@ -213,7 +213,7 @@ type userToBeing struct {
|
|||
ALL field.Asterisk
|
||||
ID field.Uint64
|
||||
UserId field.String
|
||||
Being field.Field
|
||||
Being field.String
|
||||
User userToBeingBelongsToUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
|
@ -233,7 +233,7 @@ func (u *userToBeing) updateTableName(table string) *userToBeing {
|
|||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewUint64(table, "id")
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.Being = field.NewField(table, "being")
|
||||
u.Being = field.NewString(table, "being")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
|
|
|
@ -43,13 +43,14 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
|||
_user.PublicKeyRsa = field.NewBytes(tableName, "public_key_rsa")
|
||||
_user.PublicKeyEd = field.NewBytes(tableName, "public_key_ed")
|
||||
_user.RestrictedFollow = field.NewBool(tableName, "restricted_follow")
|
||||
_user.Location = field.NewField(tableName, "location")
|
||||
_user.Birthday = field.NewField(tableName, "birthday")
|
||||
_user.Location = field.NewField(tableName, "location")
|
||||
_user.Verified = field.NewBool(tableName, "verified")
|
||||
_user.PasskeyId = field.NewBytes(tableName, "passkey_id")
|
||||
_user.FinishedRegistration = field.NewBool(tableName, "finished_registration")
|
||||
_user.PrivateKeyRsa = field.NewBytes(tableName, "private_key_rsa")
|
||||
_user.PrivateKeyEd = field.NewBytes(tableName, "private_key_ed")
|
||||
_user.RemoteInfoId = field.NewField(tableName, "remote_info_id")
|
||||
_user.RemoteInfo = userHasOneRemoteInfo{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
|
@ -383,13 +384,14 @@ type user struct {
|
|||
PublicKeyRsa field.Bytes
|
||||
PublicKeyEd field.Bytes
|
||||
RestrictedFollow field.Bool
|
||||
Location field.Field
|
||||
Birthday field.Field
|
||||
Location field.Field
|
||||
Verified field.Bool
|
||||
PasskeyId field.Bytes
|
||||
FinishedRegistration field.Bool
|
||||
PrivateKeyRsa field.Bytes
|
||||
PrivateKeyEd field.Bytes
|
||||
RemoteInfoId field.Field
|
||||
RemoteInfo userHasOneRemoteInfo
|
||||
|
||||
InfoFields userHasManyInfoFields
|
||||
|
@ -445,13 +447,14 @@ func (u *user) updateTableName(table string) *user {
|
|||
u.PublicKeyRsa = field.NewBytes(table, "public_key_rsa")
|
||||
u.PublicKeyEd = field.NewBytes(table, "public_key_ed")
|
||||
u.RestrictedFollow = field.NewBool(table, "restricted_follow")
|
||||
u.Location = field.NewField(table, "location")
|
||||
u.Birthday = field.NewField(table, "birthday")
|
||||
u.Location = field.NewField(table, "location")
|
||||
u.Verified = field.NewBool(table, "verified")
|
||||
u.PasskeyId = field.NewBytes(table, "passkey_id")
|
||||
u.FinishedRegistration = field.NewBool(table, "finished_registration")
|
||||
u.PrivateKeyRsa = field.NewBytes(table, "private_key_rsa")
|
||||
u.PrivateKeyEd = field.NewBytes(table, "private_key_ed")
|
||||
u.RemoteInfoId = field.NewField(table, "remote_info_id")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
|
@ -468,7 +471,7 @@ func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|||
}
|
||||
|
||||
func (u *user) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 35)
|
||||
u.fieldMap = make(map[string]field.Expr, 36)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["username"] = u.Username
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
|
@ -485,13 +488,14 @@ func (u *user) fillFieldMap() {
|
|||
u.fieldMap["public_key_rsa"] = u.PublicKeyRsa
|
||||
u.fieldMap["public_key_ed"] = u.PublicKeyEd
|
||||
u.fieldMap["restricted_follow"] = u.RestrictedFollow
|
||||
u.fieldMap["location"] = u.Location
|
||||
u.fieldMap["birthday"] = u.Birthday
|
||||
u.fieldMap["location"] = u.Location
|
||||
u.fieldMap["verified"] = u.Verified
|
||||
u.fieldMap["passkey_id"] = u.PasskeyId
|
||||
u.fieldMap["finished_registration"] = u.FinishedRegistration
|
||||
u.fieldMap["private_key_rsa"] = u.PrivateKeyRsa
|
||||
u.fieldMap["private_key_ed"] = u.PrivateKeyEd
|
||||
u.fieldMap["remote_info_id"] = u.RemoteInfoId
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -55,12 +55,14 @@ type User struct {
|
|||
// If true, the owner must approve of a follow request first
|
||||
RestrictedFollow bool
|
||||
|
||||
// Technically should be a timestamp, but can't trust other implementations
|
||||
// to enforce this in a consistent format
|
||||
Birthday sql.NullString
|
||||
Location sql.NullString
|
||||
Birthday sql.NullTime
|
||||
|
||||
// Whether the account got verified and is allowed to be active
|
||||
// For local accounts being active means being allowed to login and perform interactions
|
||||
// For remote users, if an account is not verified, any interactions it sends are discarded
|
||||
// No impact on remote accounts
|
||||
Verified bool
|
||||
// 64 byte unique id for passkeys, because UUIDs are 128 bytes and passkey spec says 64 bytes max
|
||||
// In theory, could also slash Id in half, but that would be a lot more calculations than the
|
||||
|
@ -71,14 +73,15 @@ type User struct {
|
|||
PrivateKeyEd []byte
|
||||
|
||||
// ---- "Remote" linked values
|
||||
InfoFields []UserInfoField
|
||||
BeingTypes []UserToBeing
|
||||
Tags []UserToTag
|
||||
Relations []UserToUserRelation
|
||||
Pronouns []UserToPronoun
|
||||
Roles []UserToRole
|
||||
RemoteInfo *UserRemoteLinks
|
||||
AuthMethods []UserAuthMethod
|
||||
InfoFields []UserInfoField
|
||||
BeingTypes []UserToBeing
|
||||
Tags []UserToTag
|
||||
Relations []UserToUserRelation
|
||||
Pronouns []UserToPronoun
|
||||
Roles []UserToRole
|
||||
RemoteInfo *UserRemoteLinks
|
||||
RemoteInfoId sql.NullInt64
|
||||
AuthMethods []UserAuthMethod
|
||||
}
|
||||
|
||||
type IUser interface {
|
||||
|
|
|
@ -21,7 +21,7 @@ const (
|
|||
var AllBeings = []BeingType{BEING_HUMAN, BEING_CAT, BEING_FOX, BEING_DOG, BEING_ROBOT, BEING_DOLL}
|
||||
|
||||
func (ct *BeingType) Scan(value any) error {
|
||||
*ct = BeingType(value.([]byte))
|
||||
*ct = BeingType(value.(string))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -8,5 +8,5 @@ type UserToBeing struct {
|
|||
ID uint64 `gorm:"primarykey"`
|
||||
User User
|
||||
UserId string
|
||||
Being BeingType `gorm:"type:being_type"`
|
||||
Being string
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package models
|
||||
|
||||
import "gorm.io/gorm"
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// UserRemoteLinks contains cached links for remote users
|
||||
type UserRemoteLinks struct {
|
||||
|
@ -13,11 +17,11 @@ type UserRemoteLinks struct {
|
|||
// Just about every link here is optional to accomodate for servers with only minimal accounts
|
||||
// Minimal being handle, ap link and inbox
|
||||
ApLink string
|
||||
ViewLink *string
|
||||
FollowersLink *string
|
||||
FollowingLink *string
|
||||
ViewLink sql.NullString
|
||||
FollowersLink sql.NullString
|
||||
FollowingLink sql.NullString
|
||||
InboxLink string
|
||||
OutboxLink *string
|
||||
FeaturedLink *string
|
||||
FeaturedTagsLink *string
|
||||
OutboxLink sql.NullString
|
||||
FeaturedLink sql.NullString
|
||||
FeaturedTagsLink sql.NullString
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue