Documentation
¶
Index ¶
- func AddFeed(ctx context.Context, feed *models.Feed) error
- func AddItems(ctx context.Context, items ...*models.Item) 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 CountItems(ctx context.Context, query query.Option) (int64, error)
- func CreateSearchSubscriptions(ctx context.Context, requests ...*models.SearchSubscriptionRequest) error
- func ElasticsearchToAPIError(err error) error
- func FilterArticles(ctx context.Context, request *models.ListRequest) (models.Articles, models.Pagination, 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 GetAllSubscriptions(ctx context.Context, user *models.User) (models.Subscriptions, 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 GetGroupSubscriptionLatestItems(ctx context.Context, count int, subscriptions models.Subscriptions, ...) (map[models.SubscriptionID]models.Items, error)
- func GetItems(ctx context.Context, ids ...models.ItemID) (models.Items, error)
- func GetSearchSubscriptionLatestItems(ctx context.Context, count int, subscriptions models.Subscriptions) (map[models.SubscriptionID]models.Items, error)
- func GetSubscription(ctx context.Context, user *models.User, id models.SubscriptionID) (*models.Subscription, error)
- func GetSubscriptionLatestItems(ctx context.Context, count int, subscriptions models.Subscriptions, ...) (map[models.FeedID]models.Items, error)
- func GetSubscriptionSuggestions(ctx context.Context, text string, count int, ...) (models.Subscriptions, error)
- func GetSubscriptionsByFeedID(ctx context.Context, ids ...models.FeedID) (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 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 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 SuggestYoutubeFeeds(ctx context.Context, text string) (*models.FeedSuggestionsResults, error)
- func UpdateFavoriteSubscription(ctx context.Context, user *models.User, id models.SubscriptionID, ...) error
- func UpdateFeed(ctx context.Context, id models.FeedID, updates map[string]any) 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 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 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 ElasticsearchToAPIError ¶ added in v0.132.2
ElasticsearchToAPIError will extract and wrap a types.ElasticsearchError from the given error, in a 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 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 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 GetAllSubscriptions ¶ added in v0.128.0
GetAllSubscriptions returns all subscriptions for the given user.
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 GetGroupSubscriptionLatestItems ¶ added in v0.134.0
func GetGroupSubscriptionLatestItems( ctx context.Context, count int, subscriptions models.Subscriptions, view models.View, ) (map[models.SubscriptionID]models.Items, error)
GetGroupSubscriptionLatestItems will return a map of latest items per subscription for the given group subscriptions.
func GetSearchSubscriptionLatestItems ¶ added in v0.134.0
func GetSearchSubscriptionLatestItems( ctx context.Context, count int, subscriptions models.Subscriptions, ) (map[models.SubscriptionID]models.Items, error)
GetSearchSubscriptionLatestItems will return a map of latest items per subscription for the given search subscriptions.
func GetSubscription ¶ added in v0.128.0
func GetSubscription( ctx context.Context, user *models.User, id models.SubscriptionID, ) (*models.Subscription, error)
GetSubscription returns the subscription that matches the given ID for the given user.
func GetSubscriptionLatestItems ¶ added in v0.135.0
func GetSubscriptionLatestItems( ctx context.Context, count int, subscriptions models.Subscriptions, view models.View, ) (map[models.FeedID]models.Items, error)
GetSubscriptionLatestItems fetches the latest items for subscriptions. This is a wrapper around GetFeedLatestItems that adds an extra filter clause to the search to return items that match the view status (i.e., read/unread).
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 GetSubscriptionsByFeedID ¶ added in v0.128.0
func GetSubscriptionsByFeedID( ctx context.Context, ids ...models.FeedID, ) (models.Subscriptions, error)
GetSubscriptionsByFeedID returns all subscriptions that match the given FeedIDs.
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 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 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 SuggestYoutubeFeeds ¶ added in v0.133.0
SuggestYoutubeFeeds will return a list of youtube feeds that match the given text.
func UpdateFavoriteSubscription ¶ added in v0.127.1
func UpdateFavoriteSubscription(ctx context.Context, user *models.User, id models.SubscriptionID, favorite bool) error
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 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 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.