rss

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const WordBoundary = `(?i)\b$WORD$\b`

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultFormatter added in v0.5.0

type DefaultFormatter struct {
}

func (DefaultFormatter) Format added in v0.5.0

func (d DefaultFormatter) Format(notification Notification) string

type Feed

type Feed struct {
	Id            uint64
	Name          string
	Url           string
	LastPublished time.Time
}

Feed is the allowed and available web feeds that users can subscribe to.

type Formatter

type Formatter interface {
	Format(Notification) string
}

type InMemRepository

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

func NewInMemRepo

func NewInMemRepo() *InMemRepository

func (*InMemRepository) AddFeed

func (r *InMemRepository) AddFeed(feed *Feed) error

func (*InMemRepository) AddSub

func (r *InMemRepository) AddSub(s *Subscription) error

func (*InMemRepository) FeedByName

func (r *InMemRepository) FeedByName(name string) (*Feed, error)

func (*InMemRepository) Feeds added in v0.5.0

func (r *InMemRepository) Feeds() ([]*Feed, error)

func (*InMemRepository) ForceError added in v0.5.0

func (r *InMemRepository) ForceError(err error, delay int)

ForceError sets an error to be returned on the next called method. Used for forcing errors in testing.

func (*InMemRepository) RemoveSub added in v0.5.0

func (r *InMemRepository) RemoveSub(subscription *Subscription) error

func (*InMemRepository) Subs added in v0.5.0

func (r *InMemRepository) Subs(search SubSearchOpt) ([]*Subscription, error)

func (*InMemRepository) UpdateSub

func (r *InMemRepository) UpdateSub(s *Subscription) error

type Item

type Item struct {
	Title       string
	Description string
	Content     string
	Link        string
	Links       []string
	GUID        string
	Custom      map[string]string
}

func (*Item) DescTruncated added in v0.5.0

func (i *Item) DescTruncated() string

func (*Item) HasKeywords

func (i *Item) HasKeywords(keywords []string) bool

type MinimalFormatter added in v0.5.0

type MinimalFormatter struct {
}

func (MinimalFormatter) Format added in v0.5.0

func (m MinimalFormatter) Format(n Notification) string

type Notification

type Notification struct {
	Feed    Feed
	Item    Item
	Channel string
	Users   []string
}

func (Notification) String

func (n Notification) String() string

type NullParser added in v0.5.0

type NullParser struct {
	Parsed *ParsedFeed
}

func (*NullParser) ParseURL added in v0.5.0

func (p *NullParser) ParseURL(url string) (*ParsedFeed, error)

type ParsedFeed

type ParsedFeed struct {
	Title       string
	Description string
	Link        string
	Updated     string
	Published   string
	Items       []*Item
	Custom      map[string]string
}

func (*ParsedFeed) HasKeywords

func (feed *ParsedFeed) HasKeywords(keywords []string) bool

func (*ParsedFeed) ItemsWithKeywords

func (feed *ParsedFeed) ItemsWithKeywords(keywords []string) []*Item

type Parser

type Parser interface {
	ParseURL(string) (*ParsedFeed, error)
}

Parser downloads a Feed.Url and translates it to a ParsedFeed to be checked by a Subscription.

type Processor

type Processor struct {

	// Max notifications sent per channel per process.
	ChannelLimit int
	// contains filtered or unexported fields
}

func NewProcessor

func NewProcessor(repo Repository, parser Parser) *Processor

func (*Processor) Process added in v0.5.0

func (p *Processor) Process() ([]*Notification, error)

type Repository

type Repository interface {
	Feeds() ([]*Feed, error)
	AddFeed(*Feed) error
	FeedByName(name string) (*Feed, error)

	AddSub(*Subscription) error
	UpdateSub(*Subscription) error
	RemoveSub(*Subscription) error
	Subs(search SubSearchOpt) ([]*Subscription, error)
}

Repository TODO: AddFeed defined errors here for Repositories to use.

type SubSearchOpt added in v0.5.0

type SubSearchOpt struct {
	FeedId   uint64
	User     string
	FeedName string
	Channel  string
}

type Subscription

type Subscription struct {
	Id        uint64
	FeedId    uint64
	User      string
	Keywords  string
	Ignore    string
	Channel   string
	Feed      *Feed
	Seen      string          // Item.GUID comma separated
	SeenItems map[string]bool // [guid]bool
}

func (*Subscription) HasSeen

func (s *Subscription) HasSeen(item Item) bool

func (*Subscription) IgnoreSlice added in v0.5.0

func (s *Subscription) IgnoreSlice() []string

func (*Subscription) KeywordsSlice

func (s *Subscription) KeywordsSlice() []string

func (*Subscription) See

func (s *Subscription) See(item Item)

type Subscriptions

type Subscriptions interface {
	Add(*Subscription) error
	Update(*Subscription) error
	ByFeedId(id uint64) ([]*Subscription, error)
}

Directories

Path Synopsis
parsers

Jump to

Keyboard shortcuts

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