package models

import (
	"database/sql"

	"gorm.io/gorm"
)

// A feed is the initial entry point for inbound Activitypub events.
// However, its primary and only user-facing use case is to be a collection
// of inbound messages, nothing else.
//
// Feeds are split into two groups, default and non-default.
// Default feeds are feeds automatically created for each user, where their normal
// timeline lives in. Additionally, they also relay inbound non-note events,
// such as likes/reactions, boosts or follow requests, to their owner.
// Default feeds also act using their owner's username (others would ge a follow request from
// `username@host`).
//
// Non-default feeds, in comparison, are explicitly created by users and can be shared
// between them. Thus, they also only accept note events, dropping everything else.
// They also are explicitly labeled as such when issuing follow requests (ex `somename-feed@host`)
type Feed struct {
	gorm.Model
	// The name of the feed. Will be equal to the owner username if a default feed
	Name      string
	Owner     User   // The owner of the feed
	OwnerId   string // Id of the owner
	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
}
