db

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Feed

type Feed struct {
	ID            int64
	URL           string
	Title         string
	LastFetchedAt time.Time
	ETag          string
	LastModified  string
	CacheUntil    time.Time
	GridPosition  int
}

type Post

type Post struct {
	ID          int64
	Title       string
	Link        string
	PublishedAt time.Time
	Content     string
	Seen        bool
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(dbPath string) (*Store, error)

func (*Store) AddFeed

func (store *Store) AddFeed(url string) (int64, error)

func (*Store) AddFeedForUser

func (store *Store) AddFeedForUser(userId int64, url string) (int64, error)

AddFeedForUser adds a feed for a specific user, handling duplicates gracefully

func (*Store) AddPost

func (store *Store) AddPost(feedId int64, guid, title, link string, publishedAt time.Time, content string) error

AddPost adds a post to the database but makes sure that the contents of the post are sanitized using the UGC policy of bluemonday

func (*Store) DeleteFeed

func (store *Store) DeleteFeed(feedId string) error

func (*Store) GetAllFeeds

func (store *Store) GetAllFeeds() ([]Feed, error)

func (*Store) GetFeedByURL

func (store *Store) GetFeedByURL(url string) (*Feed, error)

func (*Store) GetFeedPosts

func (store *Store) GetFeedPosts(feedId int64, userId int64, limit int) ([]Post, error)

GetFeedPosts gets the posts for a given feed and user, and returns them in descending order of published_at

func (*Store) GetOrCreateUser

func (store *Store) GetOrCreateUser(oidcSubject, oidcIssuer string) (int64, error)

func (*Store) GetPost

func (store *Store) GetPost(postID int64) (*Post, error)

GetPost retrieves a single post by its ID

func (*Store) GetUserFeeds

func (store *Store) GetUserFeeds(userId int64) ([]Feed, error)

func (*Store) GetUserPostsPerFeed

func (store *Store) GetUserPostsPerFeed(userId int64) (int, error)

GetUserPostsPerFeed gets the number of posts per feed for a user

func (*Store) InitAndVerifyDb

func (store *Store) InitAndVerifyDb(dbPath string) error

func (*Store) MarkAllFeedPostsAsSeen

func (store *Store) MarkAllFeedPostsAsSeen(userId int64, feedId string) error

func (*Store) MarkPostAsSeen

func (store *Store) MarkPostAsSeen(userId int64, postId string) error

MarkPostAsSeen marks a post as seen for a given user

func (*Store) SetUserPostsPerFeed

func (store *Store) SetUserPostsPerFeed(userId int64, postsPerFeed int) error

SetUserPostsPerFeed sets the number of posts per feed for a user

func (*Store) UpdateFeedCacheInfo

func (store *Store) UpdateFeedCacheInfo(feedId int64, etag, lastModified string, cacheUntil time.Time) error

func (*Store) UpdateFeedLastFetched

func (store *Store) UpdateFeedLastFetched(feedId int64, timestamp time.Time) error

func (*Store) UpdateFeedTitle

func (store *Store) UpdateFeedTitle(feedId int64, title string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL