From b0db12490c75fa5c9780017d9eb1f8da48651c31 Mon Sep 17 00:00:00 2001 From: mstar Date: Tue, 8 Apr 2025 16:31:47 +0200 Subject: [PATCH] Fix optional types and access func --- storage-new/models/Note.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/storage-new/models/Note.go b/storage-new/models/Note.go index f8c0907..efc725f 100644 --- a/storage-new/models/Note.go +++ b/storage-new/models/Note.go @@ -1,6 +1,7 @@ package models import ( + "database/sql" "time" "gorm.io/gorm" @@ -21,14 +22,25 @@ type Note struct { // Raw content of the note. So without additional formatting applied // Might already have formatting applied beforehand from the origin server RawContent string - ContentWarning *string // Content warnings of the note, if it contains any - RepliesTo *string // Url of the message this replies to - Quotes *string // url of the message this note quotes + 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) - OriginServer string // Url of the origin server. Also the primary key for those + 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) +}