model

package
v0.0.0-...-5365f31 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package model contains all data structures used by the application.

Index

Constants

View Source
const (
	EntryStatusUnread       = "unread"
	EntryStatusRead         = "read"
	EntryStatusRemoved      = "removed"
	DefaultSortingOrder     = "published_at"
	DefaultSortingDirection = "asc"
)

Entry statuses

Variables

This section is empty.

Functions

func OppositeDirection

func OppositeDirection(direction string) string

OppositeDirection returns the opposite sorting direction.

func Themes

func Themes() map[string]string

Themes returns the list of available themes.

func ValidateDirection

func ValidateDirection(direction string) error

ValidateDirection makes sure the sorting direction is valid.

func ValidateEntryOrder

func ValidateEntryOrder(order string) error

ValidateEntryOrder makes sure the sorting order is valid.

func ValidateEntryStatus

func ValidateEntryStatus(status string) error

ValidateEntryStatus makes sure the entry status is valid.

func ValidateRange

func ValidateRange(offset, limit int) error

ValidateRange makes sure the offset/limit values are valid.

func ValidateTheme

func ValidateTheme(theme string) error

ValidateTheme validates theme value.

Types

type Categories

type Categories []*Category

Categories represents a list of categories.

type Category

type Category struct {
	ID        int64  `json:"id,omitempty"`
	Title     string `json:"title,omitempty"`
	UserID    int64  `json:"user_id,omitempty"`
	FeedCount int    `json:"nb_feeds,omitempty"`
}

Category represents a category in the system.

func (*Category) String

func (c *Category) String() string

func (Category) ValidateCategoryCreation

func (c Category) ValidateCategoryCreation() error

ValidateCategoryCreation validates a category during the creation.

func (Category) ValidateCategoryModification

func (c Category) ValidateCategoryModification() error

ValidateCategoryModification validates a category during the modification.

type Enclosure

type Enclosure struct {
	ID       int64  `json:"id"`
	UserID   int64  `json:"user_id"`
	EntryID  int64  `json:"entry_id"`
	URL      string `json:"url"`
	MimeType string `json:"mime_type"`
	Size     int64  `json:"size"`
}

Enclosure represents an attachment.

type EnclosureList

type EnclosureList []*Enclosure

EnclosureList represents a list of attachments.

type Entries

type Entries []*Entry

Entries represents a list of entries.

type Entry

type Entry struct {
	ID          int64         `json:"id"`
	UserID      int64         `json:"user_id"`
	FeedID      int64         `json:"feed_id"`
	Status      string        `json:"status"`
	Hash        string        `json:"hash"`
	Title       string        `json:"title"`
	URL         string        `json:"url"`
	CommentsURL string        `json:"comments_url"`
	Date        time.Time     `json:"published_at"`
	Content     string        `json:"content"`
	Author      string        `json:"author"`
	Starred     bool          `json:"starred"`
	Enclosures  EnclosureList `json:"enclosures,omitempty"`
	Feed        *Feed         `json:"feed,omitempty"`
	Category    *Category     `json:"category,omitempty"`
}

Entry represents a feed item in the system.

type Feed

type Feed struct {
	ID                 int64     `json:"id"`
	UserID             int64     `json:"user_id"`
	FeedURL            string    `json:"feed_url"`
	SiteURL            string    `json:"site_url"`
	Title              string    `json:"title"`
	CheckedAt          time.Time `json:"checked_at"`
	EtagHeader         string    `json:"etag_header"`
	LastModifiedHeader string    `json:"last_modified_header"`
	ParsingErrorMsg    string    `json:"parsing_error_message"`
	ParsingErrorCount  int       `json:"parsing_error_count"`
	ScraperRules       string    `json:"scraper_rules"`
	RewriteRules       string    `json:"rewrite_rules"`
	Crawler            bool      `json:"crawler"`
	Username           string    `json:"username"`
	Password           string    `json:"password"`
	Category           *Category `json:"category,omitempty"`
	Entries            Entries   `json:"entries,omitempty"`
	Icon               *FeedIcon `json:"icon"`
}

Feed represents a feed in the database.

func (*Feed) String

func (f *Feed) String() string

type FeedIcon

type FeedIcon struct {
	FeedID int64 `json:"feed_id"`
	IconID int64 `json:"icon_id"`
}

FeedIcon is a jonction table between feeds and icons

type Feeds

type Feeds []*Feed

Feeds is a list of feed

type Icon

type Icon struct {
	ID       int64  `json:"id"`
	Hash     string `json:"hash"`
	MimeType string `json:"mime_type"`
	Content  []byte `json:"content"`
}

Icon represents a website icon (favicon)

func (*Icon) DataURL

func (i *Icon) DataURL() string

DataURL returns the data URL of the icon.

type Icons

type Icons []*Icon

Icons represents a list of icon.

type Integration

type Integration struct {
	UserID               int64
	PinboardEnabled      bool
	PinboardToken        string
	PinboardTags         string
	PinboardMarkAsUnread bool
	InstapaperEnabled    bool
	InstapaperUsername   string
	InstapaperPassword   string
	FeverEnabled         bool
	FeverUsername        string
	FeverPassword        string
	FeverToken           string
	WallabagEnabled      bool
	WallabagURL          string
	WallabagClientID     string
	WallabagClientSecret string
	WallabagUsername     string
	WallabagPassword     string
	NunuxKeeperEnabled   bool
	NunuxKeeperURL       string
	NunuxKeeperAPIKey    string
	PocketEnabled        bool
	PocketAccessToken    string
	PocketConsumerKey    string
}

Integration represents user integration settings.

type Job

type Job struct {
	UserID int64
	FeedID int64
}

Job represents a payload sent to the processing queue.

type JobList

type JobList []Job

JobList represents a list of jobs.

type Session

type Session struct {
	ID   string
	Data *SessionData
}

Session represents a session in the system.

func (*Session) String

func (s *Session) String() string

type SessionData

type SessionData struct {
	CSRF               string `json:"csrf"`
	OAuth2State        string `json:"oauth2_state"`
	FlashMessage       string `json:"flash_message"`
	FlashErrorMessage  string `json:"flash_error_message"`
	Language           string `json:"language"`
	PocketRequestToken string `json:"pocket_request_token"`
}

SessionData represents the data attached to the session.

func (*SessionData) Scan

func (s *SessionData) Scan(src interface{}) error

Scan converts raw JSON data.

func (SessionData) String

func (s SessionData) String() string

func (SessionData) Value

func (s SessionData) Value() (driver.Value, error)

Value converts the session data to JSON.

type User

type User struct {
	ID             int64             `json:"id"`
	Username       string            `json:"username"`
	Password       string            `json:"password,omitempty"`
	IsAdmin        bool              `json:"is_admin"`
	Theme          string            `json:"theme"`
	Language       string            `json:"language"`
	Timezone       string            `json:"timezone"`
	EntryDirection string            `json:"entry_sorting_direction"`
	LastLoginAt    *time.Time        `json:"last_login_at,omitempty"`
	Extra          map[string]string `json:"extra"`
}

User represents a user in the system.

func NewUser

func NewUser() *User

NewUser returns a new User.

func (*User) UseTimezone

func (u *User) UseTimezone(tz string)

UseTimezone converts last login date to the given timezone.

func (User) ValidatePassword

func (u User) ValidatePassword() error

ValidatePassword validates user password requirements.

func (User) ValidateUserCreation

func (u User) ValidateUserCreation() error

ValidateUserCreation validates new user.

func (User) ValidateUserLogin

func (u User) ValidateUserLogin() error

ValidateUserLogin validates user credential requirements.

func (User) ValidateUserModification

func (u User) ValidateUserModification() error

ValidateUserModification validates user modification payload.

type UserSession

type UserSession struct {
	ID        int64
	UserID    int64
	Token     string
	CreatedAt time.Time
	UserAgent string
	IP        string
}

UserSession represents a user session in the system.

func (*UserSession) String

func (u *UserSession) String() string

func (*UserSession) UseTimezone

func (u *UserSession) UseTimezone(tz string)

UseTimezone converts creation date to the given timezone.

type UserSessions

type UserSessions []*UserSession

UserSessions represents a list of sessions.

func (UserSessions) UseTimezone

func (u UserSessions) UseTimezone(tz string)

UseTimezone converts creation date of all sessions to the given timezone.

type Users

type Users []*User

Users represents a list of users.

func (Users) UseTimezone

func (u Users) UseTimezone(tz string)

UseTimezone converts last login timestamp of all users to the given timezone.

Jump to

Keyboard shortcuts

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