model

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RSSFeed = "rss"
)

Variables

View Source
var DB *gorm.DB

Functions

func AddFeedItem added in v0.6.0

func AddFeedItem(i *FeedItem) int64

func CreateAPFollower added in v0.4.0

func CreateAPFollower(uid uint, follower string) error

func CreateUser

func CreateUser(username, email string) error

func DeleteUserFeed added in v0.6.0

func DeleteUserFeed(f *UserFeed) error

func GenerateToken

func GenerateToken() string

func GetUnreadBookmarkCount added in v0.6.0

func GetUnreadBookmarkCount(uid uint) int64

func GetUnreadFeedItemCount added in v0.6.0

func GetUnreadFeedItemCount(uid uint) int64

func Init

func Init(c *config.Config) error

Types

type APFollower added in v0.4.0

type APFollower struct {
	CommonFields
	UserID   uint   `gorm:"uniqueIndex:apuidx" json:"uid"`
	Follower string `gorm:"uniqueIndex:apuidx" json:"follower"`
}

type Bookmark

type Bookmark struct {
	CommonFields
	URL          string      `json:"url"`
	Title        string      `json:"title"`
	Notes        string      `json:"notes"`
	Domain       string      `json:"domain"`
	Favicon      string      `json:"favicon"`
	Tags         []Tag       `gorm:"many2many:bookmark_tags;" json:"tags"`
	Snapshots    []Snapshot  `json:"snapshots"`
	CollectionID uint        `json:"-"`
	Collection   *Collection `json:"collection"`
	Public       bool        `json:"public"`
	Unread       bool        `json:"unread"`
	UserID       uint        `json:"user_id"`
	User         User        `json:"-"`
}

func GetOrCreateBookmark added in v0.4.0

func GetOrCreateBookmark(u *User, urlString, title, tags, notes, public, favicon, collection, unread string) (*Bookmark, bool, error)

TODO use Bookmark as parameter instead of strings

func GetUnreadBookmarkItems added in v0.6.0

func GetUnreadBookmarkItems(uid, limit uint) []*Bookmark

type Collection added in v0.5.0

type Collection struct {
	CommonFields
	Name      string `gorm:"uniqueIndex:cuid" json:"name"`
	UserID    uint   `gorm:"uniqueIndex:cuid" json:"user_id"`
	ParentID  uint
	Children  []*Collection `gorm:"foreignKey:parent_id"`
	User      User          `json:"-"`
	Bookmarks []Bookmark    `json:"bookmarks"`
}

func GetCollection added in v0.5.0

func GetCollection(uid uint, cid string) *Collection

func GetCollectionByName added in v0.5.0

func GetCollectionByName(uid uint, cname string) *Collection

func GetCollectionTree added in v0.5.0

func GetCollectionTree(uid uint) []*Collection

func GetCollections added in v0.5.0

func GetCollections(uid uint) []*Collection

type CommonFields added in v0.2.0

type CommonFields struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at"`
}

type Database added in v0.2.0

type Database struct {
	ID      uint `gorm:"primaryKey"`
	Version uint
}

type Feed added in v0.6.0

type Feed struct {
	CommonFields
	Name    string      `json:"name"`
	URL     string      `json:"gorm:"unique" url"`
	Type    string      `json:"type"`
	Favicon string      `json:"favicon"`
	Items   []*FeedItem `json:"items"`
	Users   []*User     `gorm:"many2many:user_feeds;" json:"-"`
}

func GetFeedByID added in v0.6.0

func GetFeedByID(id uint) (*Feed, error)

func GetFeedByURL added in v0.6.0

func GetFeedByURL(u string) (*Feed, error)

func GetFeeds added in v0.6.0

func GetFeeds() ([]*Feed, error)

type FeedItem added in v0.6.0

type FeedItem struct {
	CommonFields
	URL     string  `gorm:"uniqueIndex:feeditemuidx" json:"url"`
	Title   string  `json:"title"`
	Content string  `json:"content"`
	FeedID  uint    `gorm:"uniqueIndex:feeditemuidx" json:"feed_id"`
	Feed    *Feed   `json:"feed"`
	Users   []*User `gorm:"many2many:user_feed_items;" json:"-"`
}

type Resource added in v0.2.0

type Resource struct {
	CommonFields
	Key              string     `gorm:"unique" json:"key"`
	MimeType         string     `json:"mimeType"`
	OriginalFilename string     `json:"originalFilename"`
	Size             uint       `json:"size"`
	Snapshots        []Snapshot `gorm:"many2many:snapshot_resources;" json:"snapshots"`
}

func GetOrCreateResource added in v0.2.0

func GetOrCreateResource(key string, mimeType string, fname string, size uint) Resource

type Snapshot

type Snapshot struct {
	CommonFields
	Title      string     `json:"title"`
	Key        string     `json:"key"`
	Text       string     `json:"text"`
	BookmarkID uint       `json:"bookmark_id"`
	Bookmark   Bookmark   `json:"bookmark"`
	Size       uint       `json:"size"`
	Resources  []Resource `gorm:"many2many:snapshot_resources;" json:"resources"`
}

func GetSnapshotWithResources added in v0.5.0

func GetSnapshotWithResources(key string) (*Snapshot, error)

type Tag

type Tag struct {
	CommonFields
	Text      string     `gorm:"unique" json:"text"`
	Bookmarks []Bookmark `gorm:"many2many:bookmark_tags;" json:"bookmarks"`
}

func GetOrCreateTag added in v0.2.0

func GetOrCreateTag(tag string) Tag

type TagCount added in v0.4.0

type TagCount struct {
	Tag   string
	Count int64
}

func GetFrequentPublicTags added in v0.4.0

func GetFrequentPublicTags(count int) []*TagCount

type Token

type Token struct {
	CommonFields
	UserID uint   `json:"user_id"`
	Text   string `json:"text"`
}

func CreateAddonToken added in v0.6.0

func CreateAddonToken(uid uint) (*Token, error)

type UnreadFeedItem added in v0.6.0

type UnreadFeedItem struct {
	FeedItem
	FeedName       string
	Favicon        string
	UserFeedItemID uint
}

func GetUnreadFeedItems added in v0.6.0

func GetUnreadFeedItems(uid, limit uint) []*UnreadFeedItem

type User

type User struct {
	CommonFields
	Username         string      `gorm:"unique" json:"username"`
	Email            *string     `gorm:"unique" json:"email"`
	OAuthID          *string     `gorm:"unique" json:"-"`
	LoginToken       string      `json:"-"`
	SubmissionTokens []Token     `json:"-"`
	Bookmarks        []Bookmark  `json:"bookmarks"`
	Feeds            []*Feed     `gorm:"many2many:user_feeds;" json:"feeds"`
	FeedsItems       []*FeedItem `gorm:"many2many:user_feed_items;" json:"feed_items"`
}

func GetUser

func GetUser(name string) *User

func GetUserByLoginToken

func GetUserByLoginToken(tok string) *User

func GetUserByOAuthID added in v0.3.0

func GetUserByOAuthID(id string) *User

func GetUserBySubmissionToken

func GetUserBySubmissionToken(tok string) *User

type UserFeed added in v0.6.0

type UserFeed struct {
	CommonFields
	Name   string `json:"name"`
	Public bool   `json:"public"`
	FeedID uint   `json:"feed_id"`
	Feed   *Feed  `json:"feed"`
	UserID uint   `json:"user_id"`
	User   *User  `json:"-"`
}

func GetUserFeed added in v0.6.0

func GetUserFeed(uid uint, fid string) (*UserFeed, error)

type UserFeedItem added in v0.6.0

type UserFeedItem struct {
	CommonFields
	Unread     bool      `json:"unread"`
	FeedItemID uint      `gorm:"uniqueIndex:userfeeditemuidx" json:"feed_item_id"`
	FeedItem   *FeedItem `json:"feed_item"`
	UserID     uint      `gorm:"uniqueIndex:userfeeditemuidx" json:"user_id"`
	User       *User     `json:"-"`
}

type UserFeedSummary added in v0.6.0

type UserFeedSummary struct {
	UserFeed
	UnreadCount uint
}

func GetUserFeeds added in v0.6.0

func GetUserFeeds(uid uint) ([]*UserFeedSummary, error)

Jump to

Keyboard shortcuts

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