Update new storage types and regenerate
This commit is contained in:
parent
0932f19f71
commit
41e432b56e
28 changed files with 6561 additions and 23 deletions
|
@ -11,6 +11,8 @@ var AllTypes = []any{
|
|||
&Reaction{},
|
||||
&RemoteServer{},
|
||||
&Role{},
|
||||
&AccessToken{},
|
||||
&LoginProcessToken{},
|
||||
&User{},
|
||||
&UserAuthMethod{},
|
||||
&UserToBeing{},
|
||||
|
@ -18,5 +20,6 @@ var AllTypes = []any{
|
|||
&UserToUserRelation{},
|
||||
&UserRemoteLinks{},
|
||||
&UserToTag{},
|
||||
&UserToPronoun{},
|
||||
&UserToRole{},
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
// Media is, at least for Linstrom, always stored on a separate server,
|
||||
// be that the remote server it originated from or an s3 bucket
|
||||
type MediaMetadata struct {
|
||||
ID string `gorm:"primarykey"` // The unique ID of this media file
|
||||
ID string `gorm:"primarykey;type:uuid;default:gen_random_uuid()"` // The unique ID of this media file
|
||||
CreatedAt time.Time // When this entry was created
|
||||
UpdatedAt time.Time // When this entry was last updated
|
||||
// When this entry was deleted (for soft deletions)
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
// - Pings: models.NoteToPing
|
||||
// - Tags: models.NoteTag
|
||||
type Note struct {
|
||||
ID string `gorm:"primarykey"` // Make ID a string (uuid) for other implementations
|
||||
ID string `gorm:"primarykey;type:uuid;default:gen_random_uuid()"` // Make ID a string (uuid) for other implementations
|
||||
CreatedAt time.Time // When this entry was created
|
||||
UpdatedAt time.Time // When this entry was last updated
|
||||
// When this entry was deleted (for soft deletions)
|
||||
|
|
22
storage-new/models/TokenAccess.go
Normal file
22
storage-new/models/TokenAccess.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gen"
|
||||
)
|
||||
|
||||
type AccessToken struct {
|
||||
User User
|
||||
UserId string
|
||||
Token string `gorm:"primarykey;type:uuid;default:gen_random_uuid()"`
|
||||
Name string // Token name will be empty if autogenerated with sucessful login
|
||||
// Every token expires, even if set to "not expire". If set to "not expire", it just expires
|
||||
// at a point in the future this server should never reach
|
||||
ExpiresAt time.Time `gorm:"default:TIMESTAMP WITH TIME ZONE '9999-12-30 23:59:59+00'"`
|
||||
}
|
||||
|
||||
type IAccessToken interface {
|
||||
// INSERT INTO @@table (user_id, token, name, {{if expiresAt != nil}}, )
|
||||
NewToken(user *User, name string, expiresAt *time.Time) (gen.T, error)
|
||||
}
|
12
storage-new/models/TokenLoginProcess.go
Normal file
12
storage-new/models/TokenLoginProcess.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// A token used during the login process
|
||||
// Each user may only have at most one login process active at the same time
|
||||
type LoginProcessToken struct {
|
||||
User User
|
||||
UserId string
|
||||
Token string `gorm:"primarykey;type:uuid;default:gen_random_uuid()"`
|
||||
ExpiresAt time.Time
|
||||
}
|
|
@ -30,7 +30,6 @@ type User struct {
|
|||
// identifier for users and other servers, especially when changing the username
|
||||
// (username != display name) might be a future feature
|
||||
// Same also applies for other types that use a UUID as primary key
|
||||
// TODO: Copy the default value and gorm type to those other types as well
|
||||
ID string `gorm:"primarykey;type:uuid;default:gen_random_uuid()"`
|
||||
// Username of the user (eg "max" if the full username is @max@example.com)
|
||||
// Assume unchangable (once set by a user) to be kind to other implementations
|
||||
|
@ -63,9 +62,22 @@ type User struct {
|
|||
Location *string
|
||||
Birthday *time.Time
|
||||
|
||||
// --- And internal account stuff ---
|
||||
// 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
|
||||
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
|
||||
// saved space is worth
|
||||
PasskeyId []byte
|
||||
|
||||
// ---- "Remote" linked values
|
||||
InfoFields []UserInfoField
|
||||
BeingTypes []UserToBeing
|
||||
Tags []UserToTag
|
||||
Relations []UserToUserRelation
|
||||
Pronouns []UserToPronoun
|
||||
Roles []UserToRole
|
||||
RemoteInfo *UserRemoteLinks
|
||||
AuthMethods []UserAuthMethod
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ package models
|
|||
// For a password, this would be a hash of that password,
|
||||
// totp would be the seed,
|
||||
// and passkey would be the webauthn.Credential, marshalled into json
|
||||
//
|
||||
// Password hashes may only exist at most once per user, the rest 0-m
|
||||
type UserAuthMethod struct {
|
||||
User User
|
||||
UserId string
|
||||
|
|
7
storage-new/models/UserToPronoun.go
Normal file
7
storage-new/models/UserToPronoun.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
package models
|
||||
|
||||
type UserToPronoun struct {
|
||||
User User
|
||||
UserId string
|
||||
Pronoung string
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue