This commit is contained in:
parent
8d4ba2ecae
commit
67b507f4bd
25 changed files with 74 additions and 27 deletions
|
@ -45,12 +45,12 @@ func migrateTypes(db *gorm.DB) error {
|
|||
&models.Role{},
|
||||
&models.User{},
|
||||
&models.UserAuthMethod{},
|
||||
&models.UserBeings{},
|
||||
&models.UserToBeing{},
|
||||
&models.UserInfoField{},
|
||||
&models.UserRelation{},
|
||||
&models.UserToUserRelation{},
|
||||
&models.UserRemoteLinks{},
|
||||
&models.UserRole{},
|
||||
&models.UserTag{},
|
||||
&models.UserToRole{},
|
||||
&models.UserToTag{},
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -2,11 +2,15 @@ package models
|
|||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
// An emote is effectively an assignment of a name and server
|
||||
type Emote struct {
|
||||
gorm.Model
|
||||
// Metadata MediaMetadata // `gorm:"foreignKey:MetadataId"`
|
||||
// Media used for this emote
|
||||
Metadata MediaMetadata // `gorm:"foreignKey:MetadataId"`
|
||||
MetadataId string
|
||||
// Name of the emote. Also the text for using it in a message (ex. :bob:)
|
||||
Name string
|
||||
// Server RemoteServer // `gorm:"foreignKey:ServerId;references:ID"`
|
||||
// Server the emote is from
|
||||
Server RemoteServer // `gorm:"foreignKey:ServerId;references:ID"`
|
||||
ServerId uint
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ import (
|
|||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Metadata for describing some media
|
||||
// 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
|
||||
CreatedAt time.Time // When this entry was created
|
||||
|
|
|
@ -6,7 +6,10 @@ import (
|
|||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Data defined in extra structs:
|
||||
// User created content, containing some message, maybe attachments,
|
||||
// tags, pings or other extra things
|
||||
//
|
||||
// Data defined in extra structs (links are included at the bottom):
|
||||
// - Attachments: models.NoteToAttachment
|
||||
// - Emotes: models.NoteToEmote
|
||||
// - Pings: models.NoteToPing
|
||||
|
|
|
@ -2,6 +2,7 @@ package models
|
|||
|
||||
import "database/sql/driver"
|
||||
|
||||
// The access level required to view a note
|
||||
type NoteAccessLevel uint8
|
||||
|
||||
const (
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package models
|
||||
|
||||
// A binding of one note to one media attachment
|
||||
type NoteToAttachment struct {
|
||||
Note Note
|
||||
NoteId string
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package models
|
||||
|
||||
// A binding of one note to one emote
|
||||
type NoteToEmote struct {
|
||||
Note Note
|
||||
NoteId string
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package models
|
||||
|
||||
// A binding of one note to one mentioned account
|
||||
type NoteToPing struct {
|
||||
Note Note
|
||||
NoteId string
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package models
|
||||
|
||||
// A binding of one note to one string (hash)tag
|
||||
type NoteTag struct {
|
||||
Note Note
|
||||
NoteId string
|
||||
|
|
|
@ -2,6 +2,7 @@ package models
|
|||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
// A binding of one note to one account reacting to it with one emote
|
||||
type Reaction struct {
|
||||
gorm.Model
|
||||
Note Note
|
||||
|
|
|
@ -2,6 +2,8 @@ package models
|
|||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
// RemoteServer describes an ActivityPub server
|
||||
// This includes self too
|
||||
type RemoteServer struct {
|
||||
gorm.Model
|
||||
ServerType ServerSoftwareType // What software the server is running. Useful for formatting
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"database/sql/driver"
|
||||
)
|
||||
|
||||
// The software a server is running
|
||||
type ServerSoftwareType string
|
||||
|
||||
const (
|
||||
|
|
|
@ -6,6 +6,9 @@ import (
|
|||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// A user describes an account for creating content.
|
||||
// This may be controlled by either a human or some external script
|
||||
//
|
||||
// Data stored in external types:
|
||||
// - Custom info fields
|
||||
// - Being types
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package models
|
||||
|
||||
// One authentication method linked to one account.
|
||||
// Contains the method and whatever the token may be
|
||||
// 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
|
||||
type UserAuthMethod struct {
|
||||
User User
|
||||
UserId string
|
||||
|
|
|
@ -2,6 +2,7 @@ package models
|
|||
|
||||
import "database/sql/driver"
|
||||
|
||||
// Authentication methods available
|
||||
type AuthenticationMethodType string
|
||||
|
||||
const (
|
||||
|
|
|
@ -4,6 +4,9 @@ import (
|
|||
"database/sql/driver"
|
||||
)
|
||||
|
||||
// The type of being an account identifies as
|
||||
// This is distinctly separate from the account being as being controlled by script
|
||||
// or other automated method
|
||||
type BeingType string
|
||||
|
||||
const (
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package models
|
||||
|
||||
type UserBeings struct {
|
||||
// Defines an account to be a being of the set type
|
||||
// Multiple are possible for combination
|
||||
type UserToBeing struct {
|
||||
User User
|
||||
UserId string
|
||||
Being BeingType `gorm:"type:being_type"`
|
||||
|
|
|
@ -6,6 +6,10 @@ import (
|
|||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// One key-value field attached to an account
|
||||
// If the value is an uri, the server may attempt to verify ownership
|
||||
// over that uri by checking the content for a `rel="me"` anchor
|
||||
// linking back to the account the field is attached to
|
||||
type UserInfoField struct {
|
||||
gorm.Model // Can actually just embed this as is here as those are not something directly exposed :3
|
||||
Name string
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package models
|
||||
|
||||
type UserRelation struct {
|
||||
User User
|
||||
UserId string
|
||||
TargetUser User
|
||||
TargetUserId string
|
||||
Relation RelationType `gorm:"type:relation_type"`
|
||||
}
|
|
@ -2,6 +2,7 @@ package models
|
|||
|
||||
import "database/sql/driver"
|
||||
|
||||
// How one account relates to another
|
||||
type RelationType string
|
||||
|
||||
const (
|
||||
|
|
|
@ -2,6 +2,7 @@ package models
|
|||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
// "Cached" extra data for accounts, in case they are remote
|
||||
type UserRemoteLinks struct {
|
||||
// ---- Section: gorm
|
||||
// Sets this struct up as a value that an Account may have
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package models
|
||||
|
||||
type UserRole struct {
|
||||
User User
|
||||
UserId string
|
||||
Role Role
|
||||
RoleId uint
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package models
|
||||
|
||||
type UserTag struct {
|
||||
// A (hash)tag appearing on an account's profile description
|
||||
// Accounts may have multiple tags, but each tag may only be stored once at most
|
||||
type UserToTag struct {
|
||||
User User
|
||||
UserId string
|
||||
Tag string
|
||||
|
|
11
storage-new/models/UserToRole.go
Normal file
11
storage-new/models/UserToRole.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package models
|
||||
|
||||
// A link of one account to one role
|
||||
// There may be multiple of these links per user and per role
|
||||
// But a role may only be linked at most once to the same user
|
||||
type UserToRole struct {
|
||||
User User
|
||||
UserId string
|
||||
Role Role
|
||||
RoleId uint
|
||||
}
|
12
storage-new/models/UserToUserRelation.go
Normal file
12
storage-new/models/UserToUserRelation.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
package models
|
||||
|
||||
// A relation between two accounts
|
||||
// There may be multiple relations from an account X to an account Y,
|
||||
// each describing a different aspect
|
||||
type UserToUserRelation struct {
|
||||
User User
|
||||
UserId string
|
||||
TargetUser User
|
||||
TargetUserId string
|
||||
Relation RelationType `gorm:"type:relation_type"`
|
||||
}
|
Loading…
Reference in a new issue