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.Role{},
|
||||||
&models.User{},
|
&models.User{},
|
||||||
&models.UserAuthMethod{},
|
&models.UserAuthMethod{},
|
||||||
&models.UserBeings{},
|
&models.UserToBeing{},
|
||||||
&models.UserInfoField{},
|
&models.UserInfoField{},
|
||||||
&models.UserRelation{},
|
&models.UserToUserRelation{},
|
||||||
&models.UserRemoteLinks{},
|
&models.UserRemoteLinks{},
|
||||||
&models.UserRole{},
|
&models.UserToRole{},
|
||||||
&models.UserTag{},
|
&models.UserToTag{},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,15 @@ package models
|
||||||
|
|
||||||
import "gorm.io/gorm"
|
import "gorm.io/gorm"
|
||||||
|
|
||||||
|
// An emote is effectively an assignment of a name and server
|
||||||
type Emote struct {
|
type Emote struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
// Metadata MediaMetadata // `gorm:"foreignKey:MetadataId"`
|
// Media used for this emote
|
||||||
|
Metadata MediaMetadata // `gorm:"foreignKey:MetadataId"`
|
||||||
MetadataId string
|
MetadataId string
|
||||||
Name string
|
// Name of the emote. Also the text for using it in a message (ex. :bob:)
|
||||||
// Server RemoteServer // `gorm:"foreignKey:ServerId;references:ID"`
|
Name string
|
||||||
|
// Server the emote is from
|
||||||
|
Server RemoteServer // `gorm:"foreignKey:ServerId;references:ID"`
|
||||||
ServerId uint
|
ServerId uint
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@ import (
|
||||||
"gorm.io/gorm"
|
"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 {
|
type MediaMetadata struct {
|
||||||
ID string `gorm:"primarykey"` // The unique ID of this media file
|
ID string `gorm:"primarykey"` // The unique ID of this media file
|
||||||
CreatedAt time.Time // When this entry was created
|
CreatedAt time.Time // When this entry was created
|
||||||
|
|
|
@ -6,7 +6,10 @@ import (
|
||||||
"gorm.io/gorm"
|
"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
|
// - Attachments: models.NoteToAttachment
|
||||||
// - Emotes: models.NoteToEmote
|
// - Emotes: models.NoteToEmote
|
||||||
// - Pings: models.NoteToPing
|
// - Pings: models.NoteToPing
|
||||||
|
|
|
@ -2,6 +2,7 @@ package models
|
||||||
|
|
||||||
import "database/sql/driver"
|
import "database/sql/driver"
|
||||||
|
|
||||||
|
// The access level required to view a note
|
||||||
type NoteAccessLevel uint8
|
type NoteAccessLevel uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
|
// A binding of one note to one media attachment
|
||||||
type NoteToAttachment struct {
|
type NoteToAttachment struct {
|
||||||
Note Note
|
Note Note
|
||||||
NoteId string
|
NoteId string
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
|
// A binding of one note to one emote
|
||||||
type NoteToEmote struct {
|
type NoteToEmote struct {
|
||||||
Note Note
|
Note Note
|
||||||
NoteId string
|
NoteId string
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
|
// A binding of one note to one mentioned account
|
||||||
type NoteToPing struct {
|
type NoteToPing struct {
|
||||||
Note Note
|
Note Note
|
||||||
NoteId string
|
NoteId string
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
|
// A binding of one note to one string (hash)tag
|
||||||
type NoteTag struct {
|
type NoteTag struct {
|
||||||
Note Note
|
Note Note
|
||||||
NoteId string
|
NoteId string
|
||||||
|
|
|
@ -2,6 +2,7 @@ package models
|
||||||
|
|
||||||
import "gorm.io/gorm"
|
import "gorm.io/gorm"
|
||||||
|
|
||||||
|
// A binding of one note to one account reacting to it with one emote
|
||||||
type Reaction struct {
|
type Reaction struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Note Note
|
Note Note
|
||||||
|
|
|
@ -2,6 +2,8 @@ package models
|
||||||
|
|
||||||
import "gorm.io/gorm"
|
import "gorm.io/gorm"
|
||||||
|
|
||||||
|
// RemoteServer describes an ActivityPub server
|
||||||
|
// This includes self too
|
||||||
type RemoteServer struct {
|
type RemoteServer struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
ServerType ServerSoftwareType // What software the server is running. Useful for formatting
|
ServerType ServerSoftwareType // What software the server is running. Useful for formatting
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// The software a server is running
|
||||||
type ServerSoftwareType string
|
type ServerSoftwareType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -6,6 +6,9 @@ import (
|
||||||
"gorm.io/gorm"
|
"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:
|
// Data stored in external types:
|
||||||
// - Custom info fields
|
// - Custom info fields
|
||||||
// - Being types
|
// - Being types
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
package models
|
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 {
|
type UserAuthMethod struct {
|
||||||
User User
|
User User
|
||||||
UserId string
|
UserId string
|
||||||
|
|
|
@ -2,6 +2,7 @@ package models
|
||||||
|
|
||||||
import "database/sql/driver"
|
import "database/sql/driver"
|
||||||
|
|
||||||
|
// Authentication methods available
|
||||||
type AuthenticationMethodType string
|
type AuthenticationMethodType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -4,6 +4,9 @@ import (
|
||||||
"database/sql/driver"
|
"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
|
type BeingType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package models
|
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
|
User User
|
||||||
UserId string
|
UserId string
|
||||||
Being BeingType `gorm:"type:being_type"`
|
Being BeingType `gorm:"type:being_type"`
|
||||||
|
|
|
@ -6,6 +6,10 @@ import (
|
||||||
"gorm.io/gorm"
|
"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 {
|
type UserInfoField struct {
|
||||||
gorm.Model // Can actually just embed this as is here as those are not something directly exposed :3
|
gorm.Model // Can actually just embed this as is here as those are not something directly exposed :3
|
||||||
Name string
|
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"
|
import "database/sql/driver"
|
||||||
|
|
||||||
|
// How one account relates to another
|
||||||
type RelationType string
|
type RelationType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -2,6 +2,7 @@ package models
|
||||||
|
|
||||||
import "gorm.io/gorm"
|
import "gorm.io/gorm"
|
||||||
|
|
||||||
|
// "Cached" extra data for accounts, in case they are remote
|
||||||
type UserRemoteLinks struct {
|
type UserRemoteLinks struct {
|
||||||
// ---- Section: gorm
|
// ---- Section: gorm
|
||||||
// Sets this struct up as a value that an Account may have
|
// 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
|
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
|
User User
|
||||||
UserId string
|
UserId string
|
||||||
Tag 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