Documentation
¶
Index ¶
- func AddFeed(ctx context.Context, feed *models.Feed) error
- func AddItems(ctx context.Context, items models.Items) (map[string]models.Items, error)
- func AddSubscriptions(ctx context.Context, subscriptions ...*models.Subscription) error
- func BuildItemQueries(user *models.User, view models.View, subscriptions models.Subscriptions) []query.Option
- func BuildSearchResultsQuery(ctx context.Context, user *models.User, request *models.SearchRequest, ...) (query.Option, error)
- func BulkImportFeeds(ctx context.Context, requests ...models.FeedSubscriptionRequest) []models.FeedSubscriptionResult
- func CheckUserLimits(ctx context.Context) error
- func CountItems(ctx context.Context, query query.Option) (int64, error)
- func CreateSearchSubscriptions(ctx context.Context, requests ...*models.SearchSubscriptionRequest) error
- func DeleteUser(ctx context.Context, user *models.User) error
- func ElasticsearchToAPIError(err error) error
- func ExtractFavicon(ctx context.Context, rawURL string) (string, error)
- func ExtractMainImage(ctx context.Context, rawURL string) (string, error)
- func FetchFeed(ctx context.Context, feedURL string, options ...FetchOption) (*models.Feed, error)
- func FilterArticles(ctx context.Context, request *models.ListRequest) (models.Articles, models.Pagination, error)
- func FindOrCreateFeed(ctx context.Context, feedURL string) (*models.Feed, bool, error)
- func FindSimilarArticles(ctx context.Context, count int, itemIDs ...models.ItemID) (models.Articles, error)
- func GenerateArticles(ctx context.Context, items models.Items) (models.Articles, error)
- func GenerateOPML(ctx context.Context, feedIDs ...models.FeedID) ([]byte, error)
- func GetAllSubscriptions(ctx context.Context) (models.Subscriptions, error)
- func GetArticleRemoteContent(ctx context.Context, article *models.Article) error
- func GetArticles(ctx context.Context, itemIDs ...models.ItemID) (models.Articles, error)
- func GetCategoriesForSubscriptions(ctx context.Context, subscriptionIDs ...models.SubscriptionID) (models.CategoryCounts, error)
- func GetEmailSubscription(ctx context.Context, user *models.User, from *mail.Address) (*models.Subscription, error)
- func GetFeed(ctx context.Context, id models.FeedID) (*models.Feed, error)
- func GetFeedLatestItems(ctx context.Context, count int, feedIDs []models.FeedID, ...) (map[models.FeedID]models.Items, error)
- func GetFeeds(ctx context.Context, ids ...models.FeedID) (models.Feeds, error)
- func GetItems(ctx context.Context, ids ...models.ItemID) (models.Items, error)
- func GetLatestItems(ctx context.Context, view models.View, subscriptions models.Subscriptions) *sync.Map
- func GetSubscription(ctx context.Context, id models.SubscriptionID) (*models.Subscription, error)
- func GetSubscriptionSuggestions(ctx context.Context, text string, count int, ...) (models.Subscriptions, error)
- func GetSubscriptionsByID(ctx context.Context, ids ...models.SubscriptionID) (models.Subscriptions, error)
- func GetTopCategoriesForItems(ctx context.Context, itemsQuery query.Option) (models.CategoryCounts, error)
- func GetUser(ctx context.Context, id models.UserID) (*models.User, error)
- func GetUserByEmail(ctx context.Context, email string) (*models.User, error)
- func GetUserByExternalID(ctx context.Context, externalID string) (*models.User, error)
- func GetUserBySubscriptionEmail(ctx context.Context, emails ...string) (*models.User, error)
- func GetUserBySubscriptionID(ctx context.Context, id string) (*models.User, error)
- func ListFiltersFromCtx(ctx context.Context) models.ListFilters
- func ListFiltersToCtx(ctx context.Context, filters models.ListFilters) context.Context
- func MarkSubscriptions(ctx context.Context, mark models.Mark, ...) error
- func NewEmailItem(email models.Email, subscription *models.Subscription) *models.Item
- func NewFeed(url string, id models.FeedID, source *feeds.Feed) *models.Feed
- func NewFeedItem(source *feeds.Item, feed *models.Feed) *models.Item
- func NewFeedSortCombinations(sort *models.Sort) []estypes.SortCombinations
- func NewFeedSortOptions(sort *models.Sort) []estypes.SortCombinationsVariant
- func NewItemSortCombinations(sort *models.Sort) []estypes.SortCombinations
- func NewItemSortOptions(sort *models.Sort) []estypes.SortCombinationsVariant
- func RemoveSubscriptions(ctx context.Context, ids ...models.SubscriptionID) error
- func SearchItems(ctx context.Context, query query.Option, count int, sort *models.Sort, ...) (models.Items, models.Pagination, error)
- func SuggestFeeds(ctx context.Context, text string) (*models.FeedSuggestionsResults, error)
- func SuggestGoogleNewsFeeds(ctx context.Context, text string) (*models.FeedSuggestionsResults, error)
- func SuggestYoutubeFeeds(ctx context.Context, text string) (*models.FeedSuggestionsResults, error)
- func SyncUser(ctx context.Context, localUser *models.User)
- func UpdateFavoriteSubscription(ctx context.Context, id models.SubscriptionID, favorite bool) error
- func UpdateFeed(ctx context.Context, id models.FeedID, updates map[string]any) error
- func UpdateFeedDetails(ctx context.Context, oldData, newData *models.Feed, lastFetched time.Time) error
- func UpdateSubscriptionDynamicInfo(ctx context.Context, subscriptions models.Subscriptions) error
- func UpdateSubscriptions(ctx context.Context, subscriptions ...*models.Subscription) (map[models.SubscriptionID]*bulk.OperationResponse, error)
- func UpdateUser(ctx context.Context, user *models.User, updates map[string]any) error
- type FeedSorting
- type FetchOption
- type FetchOptions
- type ItemSorting
- type SubscriptionSorting
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSubscriptions ¶
func AddSubscriptions(ctx context.Context, subscriptions ...*models.Subscription) error
AddSubscriptions adds the given subscriptions to a user.
func BuildItemQueries ¶
func BuildItemQueries( user *models.User, view models.View, subscriptions models.Subscriptions, ) []query.Option
BuildItemQueries generates a slices of queries for the given subscriptions, based on the given filters.
func BuildSearchResultsQuery ¶ added in v0.128.0
func BuildSearchResultsQuery( ctx context.Context, user *models.User, request *models.SearchRequest, clause query.BoolOption, ) (query.Option, error)
BuildSearchResultsQuery generates a query that can be used to fetch appropriate results for a given SearchRequest criteria.
func BulkImportFeeds ¶
func BulkImportFeeds(ctx context.Context, requests ...models.FeedSubscriptionRequest) []models.FeedSubscriptionResult
BulkImportFeeds handles processing any number of NewFeedSubscriptionRequest requests.
func CheckUserLimits ¶ added in v0.151.0
func CountItems ¶ added in v0.131.2
CountItems returns a count of items that match the given query.
func CreateSearchSubscriptions ¶
func CreateSearchSubscriptions(ctx context.Context, requests ...*models.SearchSubscriptionRequest) error
CreateSearchSubscriptions will create new SearchSubscriptions for the user from the given requests.
func DeleteUser ¶ added in v0.143.0
DeleteUser deletes the user and the user's subscription objects from Elasticsearch.
func ElasticsearchToAPIError ¶ added in v0.132.2
ElasticsearchToAPIError will extract and wrap a types.ElasticsearchError from the given error, in an APIError containing its pertinent information. If the given error does not contain types.ElasticsearchError, the given error is wrapped in a generic APIError is created.
func ExtractFavicon ¶ added in v0.147.1
ExtractFavicon will attempt to extract a URL to what is likely the favicon of a page.
func ExtractMainImage ¶ added in v0.147.1
ExtractMainImage will attempt to extract a URL to what is likely the "main" image of a page (i.e., typically used on article/post pages).
func FilterArticles ¶ added in v0.128.0
func FilterArticles( ctx context.Context, request *models.ListRequest, ) (models.Articles, models.Pagination, error)
FilterArticles returns Articles filtered by the given filters and paginated by the given pagination.
func FindOrCreateFeed ¶ added in v0.147.0
FindOrCreateFeed will either generate a new feed or return the existing feed for the given URL. If the feed is new, the boolean return value will be true.
func FindSimilarArticles ¶ added in v0.128.0
func FindSimilarArticles(ctx context.Context, count int, itemIDs ...models.ItemID) (models.Articles, error)
FindSimilarArticles performs a "more like this" search to find other Articles that are similar to the Items with the given IDs.
func GenerateArticles ¶ added in v0.128.0
GenerateArticles takes a slice of items and creates articles from them, grabbing the necessary data from the user object.
func GenerateOPML ¶ added in v0.152.0
GenerateOPML generates an OPML file of the feeds listed by the given IDs.
func GetAllSubscriptions ¶ added in v0.128.0
func GetAllSubscriptions( ctx context.Context, ) (models.Subscriptions, error)
GetAllSubscriptions returns all subscriptions for the given user.
func GetArticleRemoteContent ¶ added in v0.147.0
GetArticleRemoteContent attempts to fetch remote content for an article. It will check if the remote content has already been fetched and cached in GCS and use that content. Otherwise, it uses the Zyte API to fetch the remote content and then cache it for reuse.
func GetArticles ¶ added in v0.128.0
GetArticles generates Article objects from the Items with the given IDs.
func GetCategoriesForSubscriptions ¶ added in v0.128.0
func GetCategoriesForSubscriptions( ctx context.Context, subscriptionIDs ...models.SubscriptionID, ) (models.CategoryCounts, error)
func GetEmailSubscription ¶
func GetEmailSubscription(ctx context.Context, user *models.User, from *mail.Address) (*models.Subscription, error)
GetEmailSubscription retrieves an EmailSubscription for the given user ID and email sender.
func GetFeedLatestItems ¶ added in v0.128.0
func GetFeedLatestItems( ctx context.Context, count int, feedIDs []models.FeedID, extraQuery query.Option, ) (map[models.FeedID]models.Items, error)
GetFeedLatestItems fetches the most recent count items for each given feed. An optional query clause can be specified that will be added to the bool filter clause of the query to apply additional filtering to the items.
func GetFeeds ¶ added in v0.132.0
GetFeeds retrieves the Feeds matching the given FeedIDs. It will fetch any cached versions before fetching from Elasticsearch (and then caching those).
func GetLatestItems ¶ added in v0.144.0
func GetSubscription ¶ added in v0.128.0
func GetSubscription( ctx context.Context, id models.SubscriptionID, ) (*models.Subscription, error)
GetSubscription returns the subscription that matches the given ID for the given user.
func GetSubscriptionSuggestions ¶ added in v0.128.0
func GetSubscriptionSuggestions( ctx context.Context, text string, count int, ignoredSubscriptions []models.SubscriptionID, ) (models.Subscriptions, error)
GetSubscriptionSuggestions returns subscriptions that match the given text. A set of ids can be optionally passed to ignore those subscriptions.
func GetSubscriptionsByID ¶ added in v0.131.2
func GetSubscriptionsByID( ctx context.Context, ids ...models.SubscriptionID, ) (models.Subscriptions, error)
GetSubscriptionsByID returns all subscriptions that match the given SubscriptionIDs.
func GetTopCategoriesForItems ¶ added in v0.132.2
func GetUserByEmail ¶
GetUserByEmail will retrieve a user by their email.
func GetUserByExternalID ¶
GetUserByExternalID will search for and return a user that matches the given external ID, if exists.
func GetUserBySubscriptionEmail ¶
GetUserBySubscriptionEmail will retrieve a user from their Foragd newsletter subscription email.
func GetUserBySubscriptionID ¶ added in v0.143.0
GetUserBySubscriptionID will retrieve a user from their payment subscription ID.
func ListFiltersFromCtx ¶
func ListFiltersFromCtx(ctx context.Context) models.ListFilters
ListFiltersFromCtx retrieves list filters from the context. If none are found, new list filters are returned.
func ListFiltersToCtx ¶
ListFiltersToCtx stores list filters in the context.
func MarkSubscriptions ¶ added in v0.127.1
func MarkSubscriptions( ctx context.Context, mark models.Mark, subscriptionIDs ...models.SubscriptionID, ) error
MarkSubscriptions will mark as appropriate all the given subscriptions. Marking a subscription includes updating the subscription data in the user object and clearing any individual item states for a subscription.
func NewEmailItem ¶ added in v0.147.1
NewEmailItem generates a new Item from an email.
func NewFeed ¶ added in v0.147.1
NewFeed converts a feed source from the go-syndication library into a models.Feed object.
func NewFeedItem ¶ added in v0.147.1
NewFeedItem generates an Item from the underlying feed data.
func NewFeedSortCombinations ¶ added in v0.160.0
func NewFeedSortCombinations(sort *models.Sort) []estypes.SortCombinations
func NewFeedSortOptions ¶ added in v0.160.0
func NewFeedSortOptions(sort *models.Sort) []estypes.SortCombinationsVariant
func NewItemSortCombinations ¶ added in v0.132.2
func NewItemSortCombinations(sort *models.Sort) []estypes.SortCombinations
func NewItemSortOptions ¶ added in v0.132.2
func NewItemSortOptions(sort *models.Sort) []estypes.SortCombinationsVariant
func RemoveSubscriptions ¶
func RemoveSubscriptions(ctx context.Context, ids ...models.SubscriptionID) error
RemoveSubscriptions removes subscriptions with the given ID from a user.
func SearchItems ¶ added in v0.131.2
func SearchItems( ctx context.Context, query query.Option, count int, sort *models.Sort, pagination *models.Pagination, ) (models.Items, models.Pagination, error)
SearchItems will search the items index for items matching the given query. Count, sort and pagination values are optional.
func SuggestFeeds ¶ added in v0.133.0
SuggestFeeds returns a feeds and their latest articles that match the given text. It will search first for existing feeds in Elasticsearch. If the given text is a URL, it will fallback to searching the website for a feed.
func SuggestGoogleNewsFeeds ¶ added in v0.154.0
func SuggestGoogleNewsFeeds(ctx context.Context, text string) (*models.FeedSuggestionsResults, error)
SuggestGoogleNewsFeeds will return a google news RSS feed for the given search query.
func SuggestYoutubeFeeds ¶ added in v0.133.0
SuggestYoutubeFeeds will return a list of youtube feeds that match the given text.
func SyncUser ¶ added in v0.142.3
SyncUser tries to sync relevant user data from the auth backend to the local data.
func UpdateFavoriteSubscription ¶ added in v0.127.1
UpdateFavoriteSubscription changes the favorite status of a subscription by updating the user object to flag the subscription as appropriate.
func UpdateFeed ¶ added in v0.128.0
UpdateFeed applies the given updates to a Feed. Any cached version of the feed is invalidated.
func UpdateFeedDetails ¶ added in v0.142.3
func UpdateFeedDetails(ctx context.Context, oldData, newData *models.Feed, lastFetched time.Time) error
UpdateFeedDetails takes a copy of a feed that has been recently fetched/refreshed and checks/updates various fields. If there are updates, these are then saved.
func UpdateSubscriptionDynamicInfo ¶ added in v0.142.1
func UpdateSubscriptionDynamicInfo(ctx context.Context, subscriptions models.Subscriptions) error
UpdateSubscriptionDynamicInfo adds dynamically generated information (e.g., unread count, stats, etc.) to subscriptions. At the least, all subscriptions will have an unread count and last updated info generated. Other stats will also be generated if the user has set the display option ShowSubscriptionStats in their account settings.
func UpdateSubscriptions ¶ added in v0.127.1
func UpdateSubscriptions( ctx context.Context, subscriptions ...*models.Subscription, ) (map[models.SubscriptionID]*bulk.OperationResponse, error)
UpdateSubscriptions will bulk update the given subscriptions in Elasticsearch.
Types ¶
type FeedSorting ¶ added in v0.160.0
type FeedSorting struct {
Updated string `json:"updated"`
Published string `json:"published"`
FeedID string `json:"feed_id"`
}
FeedSorting contains the sort options for sorting item search results.
func (*FeedSorting) SortCombinationsCaster ¶ added in v0.160.0
func (s *FeedSorting) SortCombinationsCaster() *estypes.SortCombinations
SortCombinationsCaster is required to allow FeedSorting to be used as Elasticsearch sort values.
type FetchOption ¶ added in v0.148.1
type FetchOption func(*FetchOptions)
FetchOption is a functional option that controls some aspect of how a feed will be fetched.
func FetchWithFeedID ¶ added in v0.147.0
func FetchWithFeedID(id models.FeedID) FetchOption
FetchWithFeedID assigns the given FeedID to the feed object.
func FetchWithProxy ¶ added in v0.147.0
func FetchWithProxy(value bool) FetchOption
FetchWithProxy option will ensure the fetch feed request is proxied.
type FetchOptions ¶ added in v0.147.0
FetchOptions defines options that manipulate how a feed will be fetched from a remote URL.
type ItemSorting ¶ added in v0.132.2
type ItemSorting struct {
Published string `json:"published"`
Updated string `json:"updated"`
ItemID string `json:"item_id"`
}
ItemSorting contains the sort options for sorting item search results.
func (*ItemSorting) SortCombinationsCaster ¶ added in v0.132.2
func (s *ItemSorting) SortCombinationsCaster() *estypes.SortCombinations
SortCombinationsCaster is required to allow ItemSorting to be used as Elasticsearch sort values.
type SubscriptionSorting ¶ added in v0.128.0
type SubscriptionSorting struct {
MarkedReadAt string `json:"marked_read_at"`
SubscriptionID string `json:"subscription_id"`
}
SubscriptionSorting contains the sort options for sorting subscription results.
func (*SubscriptionSorting) SortCombinationsCaster ¶ added in v0.128.0
func (s *SubscriptionSorting) SortCombinationsCaster() *types.SortCombinations
SortCombinationsCaster is required to allow FeedSorting to be used as Elasticsearch sort values.