Add initial feed structure, fix passkey id usage

This commit is contained in:
Melody Becker 2025-04-02 13:44:33 +02:00
parent ef91558600
commit 420f6e46c0
Signed by: mstar
SSH key fingerprint: SHA256:9VAo09aaVNTWKzPW7Hq2LW+ox9OdwmTSHRoD4mlz1yI
6 changed files with 162 additions and 118 deletions

View file

@ -1,11 +1,14 @@
package models
// Just a list of all models stored in the database
var AllTypes = []any{
&Emote{},
&Feed{},
&MediaMetadata{},
&Note{},
&NoteToAttachment{},
&NoteToEmote{},
&NoteToFeed{},
&NoteToPing{},
&NoteTag{},
&Reaction{},

View file

@ -0,0 +1,32 @@
package models
import (
"database/sql"
"gorm.io/gorm"
)
// A feed is the initial entry point for all inbound Activitypub events.
// However, its primary and only user-facing use case is to be a collection
// of inbound messages, nothing else.
//
// Thus, the flow for inbound events is the following:
// If the event is a note:
//
// Add it to the receiving feed. If it's a reply and the feed is a default
// create a notification for the owner
//
// If it's an event:
//
// If the feed is not a default feed for a user, discard the event
// If it is the default feed for a user, create a notification for the owner
type Feed struct {
gorm.Model
Name string
Owner User
OwnerId string
IsDefault bool // Whether the feed is the default one for the user
// If a feed is the default one for a user, use that user's public key.
// Otherwise, use its own key
PublicKey sql.NullString
}

View file

@ -1,5 +0,0 @@
package models
// TODO: Struct for mapping a note to a user for their personal feed
// Storing timeline info in redis could also be an idea, but I kinda like
// everything being in one place

View file

@ -0,0 +1,29 @@
package models
import "time"
// TODO: Struct for mapping a note to a user for their personal feed
// Storing timeline info in redis could also be an idea, but I kinda like
// everything being in one place
// Data needed:
// - Which note
// - Who's feed
// - Which feed (once separate feeds are implemented)
// - Reason:
// - Boost
// - Follow person
// - Follow tag
//
// Also need to store the boosts a user has performed somewhere
// Maybe adjust Reaction? Though a separate table might be a better option
// Assigns a note to a feed
type NoteToFeed struct {
ID uint64 `gorm:"primarykey"`
CreatedAt time.Time
Note Note
NoteId string
// Feed Feed
// FeedId uint64
// Reason AppearanceReason
}

View file

@ -10,15 +10,8 @@ import (
// A user describes an account for creating content.
// This may be controlled by either a human or some external script
//
// Data stored in external types:
// - Custom info fields
// - Being types
// - Tags
// - Relations
// - Pronouns
// - Roles
// - AP remote links
// - Auth methods and tokens (hashed pw, totp key, passkey id)
// Data stored externally:
// - Feed connections (which note belongs in the feed of this user, for what reason)
type User struct {
// ID is a uuid for this account
//