Add attempts for default data

This commit is contained in:
Melody Becker 2025-04-05 12:22:00 +02:00
parent c25f27e82e
commit 910717cf01
Signed by: mstar
SSH key fingerprint: SHA256:vkXfS9FG2pVNVfvDrzd1VW9n8VJzqqdKQGljxxX8uK8
4 changed files with 56 additions and 3 deletions

View file

@ -5,6 +5,8 @@ import (
"time"
"gorm.io/gorm"
"git.mstar.dev/mstar/linstrom/config"
)
// A user describes an account for creating content and events.
@ -35,8 +37,8 @@ type User struct {
// When this entry was deleted (for soft deletions)
// 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
DeletedAt gorm.DeletedAt `gorm:"index"`
// Server RemoteServer // `gorm:"foreignKey:ServerId;references:ID"` // The server this user is from
DeletedAt gorm.DeletedAt `gorm:"index"`
Server 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
Description string // The description of a user account
@ -76,3 +78,22 @@ type User struct {
RemoteInfo *UserRemoteLinks
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},
}
}