All checks were successful
/ docker (push) Successful in 3m58s
Other software might use different IDs that aren't UUIDs, so shouldn't lock own IDs into UUID either
46 lines
2.1 KiB
Go
46 lines
2.1 KiB
Go
package models
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// A note describes some user generated text content.
|
|
type Note struct {
|
|
ID string `gorm:"primarykey;default:gen_random_uuid()"` // 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 User // The user that created this note
|
|
CreatorId string // Id of the creator user
|
|
Remote bool // Whether the note is originally a remote one and just "cached"
|
|
// Raw content of the note. So without additional formatting applied
|
|
// Might already have formatting applied beforehand from the origin server
|
|
RawContent string
|
|
ContentWarning sql.NullString // Content warnings of the note, if it contains any
|
|
RepliesTo sql.NullString // Url of the message this replies to
|
|
Quotes sql.NullString // url of the message this note quotes
|
|
AccessLevel NoteAccessLevel // Where to send this message to (public, home, followers, dm)
|
|
Origin RemoteServer
|
|
OriginId uint
|
|
|
|
AttachmentRelations []NoteToAttachment `gorm:"foreignKey:NoteId"` // Attachments added on to this note
|
|
EmoteRelations []NoteToEmote `gorm:"foreignKey:NoteId"` // Emotes used in this note
|
|
PingRelations []NoteToPing `gorm:"foreignKey:NoteId"` // Pings/mentions this note performs
|
|
Tags []NoteTag `gorm:"foreignKey:NoteId"` // Tags this note contains
|
|
}
|
|
|
|
type INote interface {
|
|
// Get all notes by a user, paged, that are a specific access level.
|
|
// Ordered by age, descending (newest first)
|
|
//
|
|
// SELECT * FROM @@table
|
|
// WHERE creator_id = @userId AND access_level = @accessLevel
|
|
// ORDER BY created_at DESC LIMIT 50 OFFSET @pageNr * 50
|
|
GetNotesPaged(userId string, pageNr uint, accessLevel uint8) ([]Note, error)
|
|
}
|