core

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSubscriptionExist    = errors.New("already subscribed")
	ErrSubscriptionNotExist = errors.New("subscription not exist")
	ErrSourceNotExist       = errors.New("source not exist")
	ErrContentNotExist      = errors.New("content not exist")
)

Functions

This section is empty.

Types

type Core

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

func NewCore

func NewCore(
	userStorage storage.User,
	contentStorage storage.Content,
	sourceStorage storage.Source,
	subscriptionStorage storage.Subscription,
	parser *feed.FeedParser,
	httpClient *client.HttpClient,
) *Core

func NewCoreFormConfig

func NewCoreFormConfig() *Core

func (*Core) AddSourceContents

func (c *Core) AddSourceContents(
	ctx context.Context, source *model.Source, items []*gofeed.Item,
) ([]*model.Content, error)

func (*Core) AddSubscription

func (c *Core) AddSubscription(ctx context.Context, userID int64, sourceID uint) error

AddSubscription adds a subscription

func (*Core) ClearSourceErrorCount

func (c *Core) ClearSourceErrorCount(ctx context.Context, sourceID uint) error

ClearSourceErrorCount clears the error count of a source

func (*Core) ContentHashIDExist

func (c *Core) ContentHashIDExist(
	ctx context.Context, hashID string,
) (bool, error)

func (*Core) CreateSource

func (c *Core) CreateSource(ctx context.Context, sourceURL string) (*model.Source, error)

CreateSource creates a new source

func (*Core) DisableSourceUpdate

func (c *Core) DisableSourceUpdate(ctx context.Context, sourceID uint) error

DisableSourceUpdate disables source update for a source

func (*Core) EnableSourceUpdate

func (c *Core) EnableSourceUpdate(ctx context.Context, sourceID uint) error

EnableSourceUpdate enables source update for a source

func (*Core) FeedParser

func (c *Core) FeedParser() *feed.FeedParser

func (*Core) GetSource

func (c *Core) GetSource(ctx context.Context, id uint) (*model.Source, error)

GetSource gets a subscribed source

func (*Core) GetSourceAllSubscriptions

func (c *Core) GetSourceAllSubscriptions(
	ctx context.Context, sourceID uint,
) ([]*model.Subscribe, error)

func (*Core) GetSourceByURL

func (c *Core) GetSourceByURL(ctx context.Context, sourceURL string) (*model.Source, error)

GetSourceByURL gets a subscribed source by URL

func (*Core) GetSources

func (c *Core) GetSources(ctx context.Context) ([]*model.Source, error)

GetSources gets all subscribed sources

func (*Core) GetSubscription

func (c *Core) GetSubscription(ctx context.Context, userID int64, sourceID uint) (*model.Subscribe, error)

GetSubscription gets a subscription

func (*Core) GetUserSubscribedSources

func (c *Core) GetUserSubscribedSources(ctx context.Context, userID int64) ([]*model.Source, error)

GetUserSubscribedSources gets the subscribed sources of a user

func (*Core) HttpClient

func (c *Core) HttpClient() *client.HttpClient

func (*Core) Init

func (c *Core) Init() error

func (*Core) SetSubscriptionInterval

func (c *Core) SetSubscriptionInterval(ctx context.Context, userID int64, sourceID uint, interval int) error

SetSubscriptionInterval sets the update interval of a subscription

func (*Core) SetSubscriptionTag

func (c *Core) SetSubscriptionTag(ctx context.Context, userID int64, sourceID uint, tags []string) error

SetSubscriptionTag sets the tags of a subscription

func (*Core) SourceErrorCountIncr

func (c *Core) SourceErrorCountIncr(ctx context.Context, sourceID uint) error

SourceErrorCountIncr increments the error count of a source

func (*Core) ToggleSourceUpdateStatus

func (c *Core) ToggleSourceUpdateStatus(ctx context.Context, sourceID uint) error

func (*Core) ToggleSubscriptionNotice

func (c *Core) ToggleSubscriptionNotice(ctx context.Context, userID int64, sourceID uint) error

func (*Core) ToggleSubscriptionTelegraph

func (c *Core) ToggleSubscriptionTelegraph(ctx context.Context, userID int64, sourceID uint) error

func (*Core) Unsubscribe

func (c *Core) Unsubscribe(ctx context.Context, userID int64, sourceID uint) error

Unsubscribe unsubscribes a user from a source

func (*Core) UnsubscribeAllSource

func (c *Core) UnsubscribeAllSource(ctx context.Context, userID int64) error

UnsubscribeAllSource unsubscribes a user from all sources

Jump to

Keyboard shortcuts

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