service

package
v0.129.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFeed added in v0.128.0

func AddFeed(ctx context.Context, feed *models.Feed) error

AddFeed adds the given feed.

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 CreateSearchSubscriptions

func CreateSearchSubscriptions(ctx context.Context, requests ...*models.SearchSubscriptionRequest) error

CreateSearchSubscriptions will create new SearchSubscriptions for the user from the given requests.

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 FilterSubscriptions added in v0.128.0

func FilterSubscriptions(
	ctx context.Context,
	user *models.User,
	filters *models.ListFilters,
	pagination models.Pagination,
) (models.Subscriptions, models.Pagination, error)

FilterSubscriptions returns subscriptions 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

func GenerateArticles(ctx context.Context, items models.Items) (models.Articles, error)

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

func GetAllSubscriptions(
	ctx context.Context,
	user *models.User,
) (models.Subscriptions, error)

GetAllSubscriptions returns all subscriptions for the given user.

func GetArticles added in v0.128.0

func GetArticles(ctx context.Context, itemIDs ...models.ItemID) (models.Articles, error)

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 GetFeedByID added in v0.128.0

func GetFeedByID(ctx context.Context, id models.FeedID) (*models.Feed, error)

GetFeedByID fetches the given Feed by its id.

func GetFeedLatestItems added in v0.128.0

func GetFeedLatestItems(ctx context.Context, count int, feeds models.Feeds) (map[models.FeedID]models.Items, error)

GetFeedLatestItems fetches the most recent count items for each given feed.

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 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 GetUser

func GetUser(ctx context.Context, id models.UserID) (*models.User, error)

GetUser retrieves the user doc with the given id.

func GetUserByEmail

func GetUserByEmail(ctx context.Context, email string) (*models.User, error)

GetUserByEmail will retrieve a user by their email.

func GetUserByExternalID

func GetUserByExternalID(ctx context.Context, externalID string) (*models.User, error)

GetUserByExternalID will search for and return a user that matches the given external ID, if exists.

func GetUserBySubscriptionEmail

func GetUserBySubscriptionEmail(ctx context.Context, emails ...string) (*models.User, error)

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

func ListFiltersToCtx(ctx context.Context, filters models.ListFilters) context.Context

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 RemoveSubscriptions

func RemoveSubscriptions(ctx context.Context, ids ...models.SubscriptionID) error

RemoveSubscriptions removes subscriptions with the given ID from a user.

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

func UpdateFeed(ctx context.Context, id models.FeedID, updates map[string]any) error

UpdateFeed applies the given updates to a Feed.

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.

func UpdateUser

func UpdateUser(ctx context.Context, user *models.User, updates map[string]any) error

UpdateUser will apply the given updates to the user.

Types

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.

Jump to

Keyboard shortcuts

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