From e282f124c76748ea46a710f50b05d3330c94e3b3 Mon Sep 17 00:00:00 2001 From: mStar Date: Sat, 29 Mar 2025 17:51:42 +0100 Subject: [PATCH] Fix some storage definitions --- storage-new/models/TokenLoginProcess.go | 4 +++- storage-new/models/User.go | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/storage-new/models/TokenLoginProcess.go b/storage-new/models/TokenLoginProcess.go index ad96975..9bb67e7 100644 --- a/storage-new/models/TokenLoginProcess.go +++ b/storage-new/models/TokenLoginProcess.go @@ -4,9 +4,11 @@ import "time" // A token used during the login process // Each user may only have at most one login process active at the same time +// Technically, that could be used to permanently block someone from logging in +// by starting a new login process every time the target has just started one type LoginProcessToken struct { User User - UserId string + UserId string `gorm:"unique"` Token string `gorm:"primarykey;type:uuid;default:gen_random_uuid()"` ExpiresAt time.Time } diff --git a/storage-new/models/User.go b/storage-new/models/User.go index 94ee0c8..409c28a 100644 --- a/storage-new/models/User.go +++ b/storage-new/models/User.go @@ -1,6 +1,7 @@ package models import ( + "database/sql" "time" "gorm.io/gorm" @@ -50,17 +51,17 @@ type User struct { Icon MediaMetadata IconId string // ID of a media file used as icon Background *MediaMetadata - BackgroundId *string // ID of a media file used as background image + BackgroundId sql.NullString // ID of a media file used as background image Banner *MediaMetadata - BannerId *string // ID of a media file used as banner - Indexable bool // Whether this account can be found by crawlers - PublicKey []byte // The public key of the account + BannerId sql.NullString // ID of a media file used as banner + Indexable bool // Whether this account can be found by crawlers + PublicKey []byte // The public key of the account // Whether this account restricts following // If true, the owner must approve of a follow request first RestrictedFollow bool - Location *string - Birthday *time.Time + Location sql.NullString + Birthday sql.NullTime // Whether the account got verified and is allowed to be active // For local accounts being active means being allowed to login and perform interactions