diff --git a/storage/mediaFile.go b/storage/mediaFile.go index 5ec406e..6edd1fa 100644 --- a/storage/mediaFile.go +++ b/storage/mediaFile.go @@ -7,9 +7,12 @@ import ( ) type MediaFile struct { - ID string `gorm:"primarykey"` - CreatedAt time.Time - UpdatedAt time.Time + ID string `gorm:"primarykey"` // The unique ID of this media file + CreatedAt time.Time // When this entry was created + UpdatedAt time.Time // When this entry was last updated + // 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"` Remote bool // whether the attachment is a remote one Link string // url if remote attachment, identifier if local diff --git a/storage/noteTargets.go b/storage/noteTargets.go index af0ed8f..50b8abf 100644 --- a/storage/noteTargets.go +++ b/storage/noteTargets.go @@ -5,19 +5,28 @@ import ( "errors" ) +// What feed a note is targeting (public, home, followers or dm) type NoteTarget uint8 const ( + // The note is intended for the public NOTE_TARGET_PUBLIC = NoteTarget(0) + // The note is intended only for the home screen + // not really any idea what the difference is compared to public + // Maybe home notes don't show up on the server feed but still for everyone's home feed if it reaches them via follow or boost NOTE_TARGET_HOME = NoteTarget(1 << iota) + // The note is intended only for followers NOTE_TARGET_FOLLOWERS + // The note is intended only for a DM to one or more targets NOTE_TARGET_DM ) +// Converts the NoteTarget value into a type the DB can use func (n *NoteTarget) Value() (driver.Value, error) { return n, nil } +// Converts the raw value from the DB into a NoteTarget func (n *NoteTarget) Scan(value any) error { vBig, ok := value.(int64) if !ok { diff --git a/storage/notes.go b/storage/notes.go index e8011eb..930ec7f 100644 --- a/storage/notes.go +++ b/storage/notes.go @@ -7,9 +7,12 @@ import ( ) type Note struct { - ID string `gorm:"primarykey"` // Make ID a string (uuid) for other implementations - CreatedAt time.Time - UpdatedAt time.Time + ID string `gorm:"primarykey"` // Make ID a string (uuid) for other implementations + CreatedAt time.Time // When this entry was created + UpdatedAt time.Time // When this entry was last updated + // 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"` Creator string // Full handle of the creator, eg: @max@example.com Remote bool // Whether the note is originally a remote one and just "cached" diff --git a/storage/remoteServerInfo.go b/storage/remoteServerInfo.go index ab2791b..395b97a 100644 --- a/storage/remoteServerInfo.go +++ b/storage/remoteServerInfo.go @@ -8,8 +8,11 @@ import ( type RemoteServer struct { ID string `gorm:"primarykey"` // ID is also server url - CreatedAt time.Time - UpdatedAt time.Time + CreatedAt time.Time // When this entry was created + UpdatedAt time.Time // When this entry was last updated + // 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"` ServerType RemoteServerType // What software the server is running. Useful for formatting Name string // What the server wants to be known as (usually same as url) diff --git a/storage/serverTypes.go b/storage/serverTypes.go index 5c5b1f2..111dd85 100644 --- a/storage/serverTypes.go +++ b/storage/serverTypes.go @@ -5,6 +5,7 @@ import ( "errors" ) +// What software a server is running // Mostly important for rendering type RemoteServerType string diff --git a/storage/user.go b/storage/user.go index 73348e0..fed4001 100644 --- a/storage/user.go +++ b/storage/user.go @@ -16,6 +16,9 @@ type User struct { Handle string // Handle is the full handle, eg @max@example.com CreatedAt time.Time // When this entry was created UpdatedAt time.Time // When this account was last updated. Will also be used for refreshing remote accounts + // 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"` Remote bool // Whether the account is a local or remote one Server string // The url of the server this account is from diff --git a/storage/userIdentType.go b/storage/userIdentType.go index 8d94d61..7ce7df5 100644 --- a/storage/userIdentType.go +++ b/storage/userIdentType.go @@ -5,6 +5,7 @@ import ( "errors" ) +// What kind of being a user identifies as type Being string const (