Add attempts for default data
This commit is contained in:
parent
c25f27e82e
commit
910717cf01
4 changed files with 56 additions and 3 deletions
|
@ -31,3 +31,20 @@ type MediaMetadata struct {
|
||||||
// Whether the media is to be blurred by default
|
// Whether the media is to be blurred by default
|
||||||
Blurred bool
|
Blurred bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Implement special handling for the linstrom URI type
|
||||||
|
// Linstrom URIs indicate resource either generated on the fly, like identicons,
|
||||||
|
// or embedded data, such as the default duck
|
||||||
|
// For external users, transform them into normal http URIs with a "special" path
|
||||||
|
const DefaultDuckLocationName = "linstrom://default-media"
|
||||||
|
|
||||||
|
var DefaultDuckMedia = MediaMetadata{
|
||||||
|
ID: "3b562a45-36b7-4c42-a944-3672f319ff7b",
|
||||||
|
OwnedById: "", // FIXME: Add default user ID here
|
||||||
|
Remote: false,
|
||||||
|
Location: DefaultDuckLocationName,
|
||||||
|
Type: "image/webp",
|
||||||
|
Name: "default-duck.webp",
|
||||||
|
AltText: "a greyscale image of a pidgeon on some smooth surface, likely a liquid. It is captioned with the text \"Duck\"",
|
||||||
|
Blurred: false,
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package models
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
|
"git.mstar.dev/mstar/linstrom/config"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,3 +18,17 @@ type RemoteServer struct {
|
||||||
IconId sql.NullString // ID of a media file
|
IconId sql.NullString // ID of a media file
|
||||||
IsSelf bool // Whether this server is yours truly
|
IsSelf bool // Whether this server is yours truly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BuildDefaultServer() *RemoteServer {
|
||||||
|
return &RemoteServer{
|
||||||
|
Model: gorm.Model{
|
||||||
|
ID: 1,
|
||||||
|
},
|
||||||
|
ServerType: ServerSoftwareLinstrom,
|
||||||
|
Domain: config.GlobalConfig.General.GetFullDomain(),
|
||||||
|
Name: config.GlobalConfig.Self.ServerDisplayName,
|
||||||
|
Icon: &DefaultDuckMedia,
|
||||||
|
IconId: sql.NullString{String: DefaultDuckMedia.ID, Valid: true},
|
||||||
|
IsSelf: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ var ServerActorRole = Role{
|
||||||
CanSendAnnouncements: other.IntoPointer(true),
|
CanSendAnnouncements: other.IntoPointer(true),
|
||||||
}
|
}
|
||||||
|
|
||||||
var allDefaultRoles = []*Role{
|
var AllDefaultRoles = []*Role{
|
||||||
&DefaultUserRole,
|
&DefaultUserRole,
|
||||||
&FullAdminRole,
|
&FullAdminRole,
|
||||||
&AccountFreezeRole,
|
&AccountFreezeRole,
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
|
"git.mstar.dev/mstar/linstrom/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A user describes an account for creating content and events.
|
// A user describes an account for creating content and events.
|
||||||
|
@ -36,7 +38,7 @@ type User struct {
|
||||||
// Soft delete means that this entry still exists in the db, but gorm won't include it anymore unless specifically told to
|
// Soft delete means that this entry still exists in the db, but gorm won't include it anymore unless specifically told to
|
||||||
// If not null, this entry is marked as deleted
|
// If not null, this entry is marked as deleted
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
// Server RemoteServer // `gorm:"foreignKey:ServerId;references:ID"` // The server this user is from
|
Server RemoteServer
|
||||||
ServerId uint // Id of the server this user is from, needed for including RemoteServer
|
ServerId uint // Id of the server this user is from, needed for including RemoteServer
|
||||||
DisplayName string // The display name of the user. Can be different from the handle
|
DisplayName string // The display name of the user. Can be different from the handle
|
||||||
Description string // The description of a user account
|
Description string // The description of a user account
|
||||||
|
@ -76,3 +78,22 @@ type User struct {
|
||||||
RemoteInfo *UserRemoteLinks
|
RemoteInfo *UserRemoteLinks
|
||||||
AuthMethods []UserAuthMethod
|
AuthMethods []UserAuthMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BuildLinstromUser() *User {
|
||||||
|
server := BuildDefaultServer()
|
||||||
|
return &User{
|
||||||
|
ID: "e3f4bb33-6d39-4349-b13e-f5c6fde56141",
|
||||||
|
Username: "linstrom",
|
||||||
|
Server: *server,
|
||||||
|
ServerId: server.ID,
|
||||||
|
DisplayName: config.GlobalConfig.Self.ServerActorDisplayName,
|
||||||
|
Description: "The default linstrom server user",
|
||||||
|
IsBot: true,
|
||||||
|
Icon: DefaultDuckMedia,
|
||||||
|
IconId: DefaultDuckMedia.ID,
|
||||||
|
Background: nil,
|
||||||
|
BackgroundId: sql.NullString{Valid: false},
|
||||||
|
Banner: nil,
|
||||||
|
BannerId: sql.NullString{Valid: false},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue