Documentation
¶
Overview ¶
Package models provides primitives to interact with the openapi HTTP API.
Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.6.0 DO NOT EDIT.
Package models provides primitives to interact with the openapi HTTP API.
Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.6.0 DO NOT EDIT.
Package models contains objects and fields representing common schema within the application.
Index ¶
- Constants
- Variables
- func AddFeed(ctx context.Context, feed *Feed) error
- func AddItems(ctx context.Context, items ...Item) error
- func AddSubscriptions(ctx context.Context, subscriptions ...*Subscription) error
- func ArticleFiltersQueryClause(source ItemSource) query.BoolOption
- func BuildItemQueries(user *User, view View, subscriptions Subscriptions) []query.Option
- func BuildItemsQuery(ctx context.Context, filters Filters, subscriptionIDs ...SubscriptionID) (query.Option, error)
- func BuildSearchResultsQuery(ctx context.Context, user *User, request *SearchRequest, ...) (query.Option, error)
- func CountItems(ctx context.Context, query query.Option) (int64, error)
- func CreateSearchSubscriptions(ctx context.Context, requests ...*SearchSubscriptionRequest) error
- func ElasticsearchToAPIError(err error) error
- func FilterArticles(ctx context.Context, request *ListRequest) (Articles, Pagination, error)
- func FilterMap[K comparable, V any](m map[K]V, fn func(K, V) bool) iter.Seq2[K, V]
- func FilterMapValues[K comparable, V any](s map[K]V, fn func(V) bool) iter.Seq[V]
- func FilterSlice[E any](s []E, fn func(E) bool) iter.Seq[E]
- func FilterSubscriptions(ctx context.Context, request *ListRequest) (Subscriptions, Pagination, error)
- func GetFeedLatestItems(ctx context.Context, count int, feeds Feeds) (map[FeedID]Items, error)
- func GetSubscriptionsByCategories(categories ...Category) subscriptionsRequestOption
- func GetSubscriptionsByFavorite(value bool) subscriptionsRequestOption
- func GetSubscriptionsByFeedIDs(ids ...FeedID) subscriptionsRequestOption
- func GetSubscriptionsByIDs(ids ...SubscriptionID) subscriptionsRequestOption
- func GetSubscriptionsDynamicInfo(value bool) subscriptionsRequestOption
- func HTTPStatus(err error) int
- func IgnoreSubscriptions(ids ...SubscriptionID) subscriptionsRequestOption
- func MarkSubscriptions(ctx context.Context, mark Mark, subscriptionIDs ...SubscriptionID) error
- func NewFeedSortCombinations(sort *Sort) []estypes.SortCombinations
- func NewFeedSortOptions(sort *Sort) []estypes.SortCombinationsVariant
- func NewItemSortCombinations(sort *Sort) []estypes.SortCombinations
- func NewItemSortOptions(sort *Sort) []estypes.SortCombinationsVariant
- func RemoveSubscriptions(ctx context.Context, ids ...SubscriptionID) error
- func SearchItems(ctx context.Context, query query.Option, count int, sort *Sort, ...) (Items, Pagination, error)
- func SearchResultsClause(search *SearchRequest) query.BoolOption
- func SearchSubscriptions(ctx context.Context, query query.Option, options ...searchSubscriptionsOption) (Subscriptions, Pagination, error)
- func SearchSuggestionsClause(search *SearchRequest) query.BoolOption
- func SliceToMap[K comparable, V any, S any](s []S, mapFn func(S) (K, V)) map[K]V
- func SubscriptionsToCtx(ctx context.Context, subscriptions Subscriptions) context.Context
- func UpdateFavoriteSubscription(ctx context.Context, id SubscriptionID, favorite bool) error
- func UpdateFeed(ctx context.Context, id FeedID, updates map[string]any) error
- func UpdateSubscriptions(ctx context.Context, subscriptions ...*Subscription) (map[SubscriptionID]*bulk.OperationResponse, error)
- func UpdateUser(ctx context.Context, userID UserID, updates map[string]any) error
- func UserToCtx(ctx context.Context, user *User) context.Context
- type APIError
- func (e *APIError) Error() string
- func (a APIError) Get(fieldName string) (value interface{}, found bool)
- func (e *APIError) GetUserMessage() *UserMessage
- func (e *APIError) HTTPStatus() int
- func (a APIError) MarshalJSON() ([]byte, error)
- func (a *APIError) Set(fieldName string, value interface{})
- func (a *APIError) UnmarshalJSON(b []byte) error
- func (e *APIError) Unwrap() error
- func (e *APIError) WriteLog(ctx context.Context)
- type AddCategoryToSubscriptionRequest
- type AddFeedSubscriptionRequest
- type AddFeedsetRequest
- type AddSubscriptionFeedSuggestions
- type AddSubscriptionResult
- type AddSubscriptionSearchFilterRequest
- type AddSubscriptionSuggestion
- type AddSubscriptionToGroupRequest
- type AddSubscriptionToSearchRequest
- type AddSubscriptionYoutubeSuggestions
- type Article
- func (a *Article) GetAuthors() []Author
- func (a *Article) GetCategories(num int) Categories
- func (a *Article) GetContent() string
- func (a *Article) GetDescription() string
- func (a *Article) GetFeedID() FeedID
- func (a *Article) GetFeedTitle() string
- func (a *Article) GetID() string
- func (a *Article) GetImage() *RemoteImage
- func (a *Article) GetLink() string
- func (a *Article) GetObjectType() ObjectType
- func (a *Article) GetSubscriptionID() SubscriptionID
- func (a *Article) GetTitle() string
- func (a *Article) GetUpdatedDate() time.Time
- func (a *Article) IsFavorite() bool
- func (a *Article) IsRemoteContent() bool
- func (a *Article) IsUnread() bool
- func (a *Article) Valid() error
- type ArticleArchive
- type ArticleArchiveExtensionType
- type ArticleArchive_ExtensionData
- func (t ArticleArchive_ExtensionData) AsItemExtensionYoutube() (ItemExtensionYoutube, error)
- func (t *ArticleArchive_ExtensionData) FromItemExtensionYoutube(v ItemExtensionYoutube) error
- func (t ArticleArchive_ExtensionData) MarshalJSON() ([]byte, error)
- func (t *ArticleArchive_ExtensionData) MergeItemExtensionYoutube(v ItemExtensionYoutube) error
- func (t *ArticleArchive_ExtensionData) UnmarshalJSON(b []byte) error
- type ArticleMetadata
- type ArticleSettings
- type ArticleState
- type Articles
- type Author
- type Categories
- type Category
- type CategoryCount
- type CategoryCounts
- func GetCategoriesForSubscriptions(ctx context.Context, subscriptionIDs ...SubscriptionID) (CategoryCounts, error)
- func GetCategoryCounts(subscriptions ...*Subscription) CategoryCounts
- func GetSubscriptionCategories(ctx context.Context, subscriptions Subscriptions) (CategoryCounts, error)
- func GetTopCategoriesForItems(ctx context.Context, itemsQuery query.Option) (CategoryCounts, error)
- type CategoryFilters
- type ChangePasswordRequest
- type Count
- type CreatedAt
- type DeletedAt
- type EditEmailSubscriptionRequest
- type EditUserRequest
- type ElementID
- type Email
- type EmailSenderID
- type EmailSubscription
- type ErrorOption
- type ExtractedMetadata
- type ExtractorErrorResponse
- type ExtractorResponse
- type ExtractorResponseFormat
- type FavoriteArticleRequest
- type FavoriteSubscriptionRequest
- type Feed
- func (f *Feed) GetAuthors() []string
- func (f *Feed) GetCategories() []string
- func (f *Feed) GetContributors() []string
- func (f *Feed) GetDescription() string
- func (f *Feed) GetID() FeedID
- func (f *Feed) GetImage() *RemoteImage
- func (f *Feed) GetItems() Items
- func (f *Feed) GetLanguage() string
- func (f *Feed) GetLink() URL
- func (f *Feed) GetRights() string
- func (f *Feed) GetSourceURLs() []URL
- func (f *Feed) GetTimestamp() time.Time
- func (f *Feed) GetTitle() string
- func (f *Feed) SetUpdateInterval(ctx context.Context) error
- type FeedID
- type FeedSorting
- type FeedStatus
- type FeedSubscription
- type FeedSubscriptionRequest
- type FeedSubscriptionResult
- type Feeds
- type FileDetails
- type FileIndex
- type FileUpload
- type Filters
- type GetSubscriptionOption
- type GetSubscriptionOptions
- type GetSubscriptionsSuggestionRequest
- type GroupSubscription
- type GroupSubscriptionRequest
- type GroupSubscriptionSuggestionRequest
- type HomeResponse
- type Item
- func (i *Item) GetAuthors() []Author
- func (i *Item) GetCategories() []string
- func (i *Item) GetContent() string
- func (i *Item) GetContributors() []Author
- func (i *Item) GetDescription() string
- func (i *Item) GetFeedID() FeedID
- func (i *Item) GetID() ItemID
- func (i *Item) GetImage() *RemoteImage
- func (i *Item) GetLanguage() string
- func (i *Item) GetLink() URL
- func (i *Item) GetRights() string
- func (i *Item) GetTimestamp() time.Time
- func (i *Item) GetTitle() string
- func (i *Item) HasContent() bool
- func (i *Item) IsNewer(since time.Time) bool
- func (i *Item) WasUpdated() bool
- type ItemExtensionType
- type ItemExtensionYoutube
- type ItemID
- type ItemSorting
- type ItemSource
- type Item_ExtensionData
- func (t Item_ExtensionData) AsItemExtensionYoutube() (ItemExtensionYoutube, error)
- func (t *Item_ExtensionData) FromItemExtensionYoutube(v ItemExtensionYoutube) error
- func (t Item_ExtensionData) MarshalJSON() ([]byte, error)
- func (t *Item_ExtensionData) MergeItemExtensionYoutube(v ItemExtensionYoutube) error
- func (t *Item_ExtensionData) UnmarshalJSON(b []byte) error
- type Items
- type JobState
- type LastFetched
- type ListArticlesResponse
- type ListFavoritesResponse
- type ListFilters
- func (f *ListFilters) GetCategories() Categories
- func (f *ListFilters) GetCount() int
- func (f *ListFilters) GetSort() Sort
- func (f *ListFilters) GetSubscriptions() []SubscriptionID
- func (f *ListFilters) GetView() View
- func (f *ListFilters) QueryParams() url.Values
- func (f *ListFilters) QueryString() string
- func (f *ListFilters) Sanitise() error
- func (f *ListFilters) Valid() error
- func (f *ListFilters) Values() map[string]any
- type ListRequest
- type ListSubscriptionCategoriesRequest
- type ListSubscriptionsResponse
- type Mark
- type MarkArticleRequest
- type MarkArticlesRequest
- type MarkObjectParams
- type MarkSubscriptionRequest
- type MarkSubscriptionsRequest
- type MarkdownFile
- type MarkdownFrontMatter
- type Nickname
- type OPMLFile
- type ObjectCommon
- type ObjectID
- type ObjectParams
- type ObjectType
- type Pagination
- type RemoteImage
- type RemoveSubscriptionRequest
- type ReportIssueRequest
- type ReportObjectIssueRequest
- type SearchRequest
- type SearchRequestPublishedWithin
- type SearchResults
- type SearchSubscription
- type SearchSubscriptionRequest
- type ShareArticleRequest
- type Sort
- type SourceType
- type State
- type StoredImage
- type Subscription
- func GetEmailSubscription(ctx context.Context, userID UserID, from *mail.Address) (*Subscription, error)
- func GetSubscription(ctx context.Context, id SubscriptionID, options ...subscriptionsRequestOption) (*Subscription, error)
- func GetSubscriptionByFeedID(ctx context.Context, id FeedID, options ...subscriptionsRequestOption) (*Subscription, error)
- func NewEmailSubscription(ctx context.Context, userID UserID, from *mail.Address) (*Subscription, error)
- func NewFeedSubscription(ctx context.Context, feed *Feed, customisation *SubscriptionCustomisation) (*Subscription, error)
- func NewGroupSubscription(ctx context.Context, request *GroupSubscriptionRequest) (*Subscription, error)
- func NewSearchSubscription(ctx context.Context, request *SearchSubscriptionRequest) (*Subscription, error)
- func (s *Subscription) GetArticleFilters() SubscriptionArticleFilters
- func (s *Subscription) GetCategories(maxCount int) Categories
- func (s *Subscription) GetFeedID() FeedID
- func (s *Subscription) GetID() SubscriptionID
- func (s *Subscription) GetImage() URL
- func (s *Subscription) GetItemState(itemID ItemID) *ArticleState
- func (s *Subscription) GetLink() string
- func (s *Subscription) GetMarkedReadAt() time.Time
- func (s *Subscription) GetReadItems() []ItemID
- func (s *Subscription) GetStats() *SubscriptionStats
- func (s *Subscription) GetSubscriptionType() SubscriptionType
- func (s *Subscription) GetTitle() string
- func (s *Subscription) GetUnreadItems() []ItemID
- func (s *Subscription) GetUpdatedDate() time.Time
- func (s *Subscription) IsFavorite() bool
- func (s *Subscription) Mark(user *User, mark Mark)
- func (s *Subscription) MarkItems(mark Mark, itemIDs ...ItemID)
- func (s *Subscription) MarkItemsRead(itemIDs ...ItemID)
- func (s *Subscription) MarkItemsUnread(itemIDs ...ItemID)
- func (s *Subscription) SetItemState(itemID ItemID, state *ArticleState)
- func (s *Subscription) Valid() error
- type SubscriptionArticleFilters
- type SubscriptionCustomisation
- type SubscriptionID
- type SubscriptionMetadata
- type SubscriptionMetadataType
- type SubscriptionSettings
- type SubscriptionSorting
- type SubscriptionStats
- type SubscriptionType
- type Subscriptions
- func GetSubscriptionSuggestions(ctx context.Context, text string, count int, ...) (Subscriptions, error)
- func GetSubscriptions(ctx context.Context, options ...subscriptionsRequestOption) (Subscriptions, error)
- func GetSubscriptionsForItems(ctx context.Context, items Items) (Subscriptions, error)
- func SubscriptionsFromCtx(ctx context.Context) Subscriptions
- func (s Subscriptions) FilterByCategories(categories ...Category) Subscriptions
- func (s Subscriptions) FilterByFavorites(value bool) Subscriptions
- func (s Subscriptions) FilterByType(t ...SubscriptionType) Subscriptions
- func (s Subscriptions) FilterByView(view View) Subscriptions
- func (s Subscriptions) GetByFeedID(id FeedID) *Subscription
- func (s Subscriptions) GetCategories() Categories
- func (s Subscriptions) GetFeedIDs() []FeedID
- func (s Subscriptions) GetIDs() []SubscriptionID
- func (s Subscriptions) Paginate(pagination Pagination, count int) (Subscriptions, Pagination)
- func (s Subscriptions) Sort(sort Sort) Subscriptions
- type Timestamp
- type URL
- type UpdatedAt
- type User
- func GetUser(ctx context.Context, id UserID) (*User, error)
- func GetUserByEmail(ctx context.Context, email string) (*User, error)
- func GetUserByExternalID(ctx context.Context, externalID string) (*User, error)
- func GetUserBySubscriptionEmail(ctx context.Context, emails ...string) (*User, error)
- func UserFromCtx(ctx context.Context) *User
- func (u *User) Active() bool
- func (u *User) AddSubscriptions(ctx context.Context, subscriptions ...*Subscription) error
- func (u *User) Cancelled() (bool, time.Time)
- func (u *User) GetAvatar() string
- func (u *User) GetEmail() string
- func (u *User) GetExternalID() UserID
- func (u *User) GetID() UserID
- func (u *User) GetMaxHistory() time.Time
- func (u *User) GetNickname() string
- func (u *User) GetSettings() *UserSettings
- func (u *User) GetSubscriptionPlan() string
- func (u *User) GetSubscriptions(ctx context.Context, options ...GetSubscriptionOption) (Subscriptions, error)
- func (u *User) GetUpdatesFrequency() time.Duration
- func (u *User) OnTrial() (bool, time.Time)
- func (u *User) Valid(_ context.Context) error
- type UserCustomisation
- type UserID
- type UserMessage
- type UserMessageStatus
- type UserMetadata
- type UserSession
- type UserSettings
- type UserSubscription
- type View
Constants ¶
const ( ParamObjectType = "object" ParamObjectID = "id" // ParamCategories is a list of category names, of any single object type (subscription or article). ParamCategories = "categories" // ParamCount is the number of results to show, where multiple results can be displayed. ParamCount = "count" // ParamPagination is the encoded pagination value, used to fetch the next set of results when paginating through a // list of objects. ParamPagination = "pagination" // ParamSort is the sort option to apply to a set of results. ParamSort = "sort" // ParamView is the view filter to apply to a set of results. ParamView = "view" // ParamMark is a mark to apply to either an object or set of objects in the request. ParamMark = "mark" // ParamFeedID identifies a single feed by its id. ParamFeedID = "feed_id" // ParamItemID identifies a single item by its id. ParamItemID = "item_id" // ParamSubscriptionID identifies a single subscription by its id. ParamSubscriptionID = "subscription_id" ParamSubscriptionName = "subscription_name" // ParamSubscriptions is a list of subscription ids. ParamSubscriptions = "subscriptions" ParamFullArticleContent = "show_full_content" ParamOnlyFavorites = "only_favorites" // ParamPlanID is the ID of the subscription plan the user has chosen. ParamPlanID = "plan_id" // ParamThumbnail is a thumbnail image uploaded by the user. ParamThumbnail = "thumbnail" )
const ( RouteHome = "/home" RouteSignup = "/signup" RouteCheckout = "/checkout" RouteCheckoutChoosePlan = "/checkout/choose-plan" RouteListSubscriptions = "/list/subscriptions" RouteListArticles = "/list/articles" RouteListFavorites = "/list/favorites" RouteUserAccountIssue = "/user/account-issue" RouteUserDeactivateAccount = "/user/deactivate" RouteUserCancelDeactivationAccount = "/user/deactivate/cancel" )
const ( ParamCustomisationCategories = "customisation.categories" ParamCustomisationNickname = "customisation.nickname" )
const ( // DefaultMaxHistory is a default maximum history value for when the user has not specified one. DefaultMaxHistory = 31 * 24 * time.Hour // DefaultUpdateInterval is the default interval on which to check for updates. DefaultUpdateInterval = 5 * time.Minute // MaxSubscriptions is the maxiumum number of subscriptions a user can have. MaxSubscriptions = 3000 )
const (
// DefaultPaginationSize is the default number of docs to fetch when paginating through results from elasticsearch.
DefaultPaginationSize = 5000
)
Variables ¶
var ( // ErrNotFound indicates the backend API returned no results. ErrNotFound = &APIError{ InternalError: errors.New("not found"), StatusCode: http.StatusNotFound, } // ErrInvalidAPIResult indicates that the backend API returned unexpected, invalid or an otherwise incorrect response. ErrInvalidAPIResult = &APIError{ InternalError: errors.New("invalid backend API result"), StatusCode: http.StatusInternalServerError, } // ErrInvalidParams indicates that invalid parameters were received or generated. ErrInvalidParams = &APIError{ InternalError: errors.New("invalid parameters"), StatusCode: http.StatusUnprocessableEntity, } )
var CommonCategoryFilters = []string{
"Post",
"Posts",
"News",
"Article",
"Articles",
"Links",
"Uncategorized",
"Featured",
"Headline",
"Home Feed",
}
CommonCategoryFilters is slice of categories that are so general or inclusive that they are ultimately useless for queries or aggregations.
Regular expressions are supported. See:
https://www.elastic.co/docs/reference/query-languages/query-dsl/regexp-syntax
var ErrCtxValueNotFound = &APIError{ InternalError: errors.New("context value not found"), StatusCode: http.StatusInternalServerError, }
var ErrFileTooLarge = errors.New("file is too large")
ErrFileTooLarge can be used to indicate a file upload had a size greater than a set limit.
var ErrInvalidDateTimeFormat = errors.New("datetime is invalid")
var ErrInvalidMimeType = errors.New("invalid mime type")
ErrInvalidMimeType indicates that the mime type is not valid.
var ErrNoFilters = &APIError{ InternalError: errors.New("no filters found"), StatusCode: http.StatusNotFound, }
var ErrUnknown = errors.New("an unknown error occurred")
var (
ErrUserAlreadyFavorited = errors.New("already a favorite")
)
var UnixEpoch = time.Unix(0, 0)
Functions ¶
func AddSubscriptions ¶
func AddSubscriptions(ctx context.Context, subscriptions ...*Subscription) error
AddSubscriptions adds the given subscriptions to a user.
func ArticleFiltersQueryClause ¶ added in v0.60.0
func ArticleFiltersQueryClause(source ItemSource) query.BoolOption
func BuildItemQueries ¶ added in v0.26.0
func BuildItemQueries( user *User, view View, subscriptions Subscriptions, ) []query.Option
BuildItemQueries generates a slices of queries for the given subscriptions, based on the given filters.
func BuildItemsQuery ¶
func BuildItemsQuery( ctx context.Context, filters Filters, subscriptionIDs ...SubscriptionID, ) (query.Option, error)
BuildItemsQuery generates a query to fetch the Items that match the given Filters from the given Subscriptions.
func BuildSearchResultsQuery ¶
func BuildSearchResultsQuery( ctx context.Context, user *User, request *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 CountItems ¶
CountItems returns a count of items that match the given query.
func CreateSearchSubscriptions ¶
func CreateSearchSubscriptions(ctx context.Context, requests ...*SearchSubscriptionRequest) error
CreateSearchSubscriptions will create new SearchSubscriptions for the user from the given requests.
func ElasticsearchToAPIError ¶ added in v0.51.0
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 ¶
func FilterArticles( ctx context.Context, request *ListRequest, ) (Articles, Pagination, error)
FilterArticles returns Articles filtered by the given filters and paginated by the given pagination.
func FilterMap ¶
func FilterMap[K comparable, V any](m map[K]V, fn func(K, V) bool) iter.Seq2[K, V]
FilterMap will filter a map by the given function.
func FilterMapValues ¶
func FilterMapValues[K comparable, V any](s map[K]V, fn func(V) bool) iter.Seq[V]
FilterMapValues will filter map values by the given function.
func FilterSlice ¶
FilterSlice will filter a slice returning an iter with elements that return true for the given filter function.
func FilterSubscriptions ¶
func FilterSubscriptions( ctx context.Context, request *ListRequest, ) (Subscriptions, Pagination, error)
FilterSubscriptions returns subscriptions filtered by the given filters and paginated by the given pagination. Dynamic information for subscriptions will also be added.
func GetFeedLatestItems ¶ added in v0.110.0
GetFeedLatestItems fetches the most recent count items for each given feed.
func GetSubscriptionsByCategories ¶
func GetSubscriptionsByCategories(categories ...Category) subscriptionsRequestOption
GetSubscriptionsByCategories option adds a filter to the query to get subscriptions by category.
func GetSubscriptionsByFavorite ¶
func GetSubscriptionsByFavorite(value bool) subscriptionsRequestOption
GetSubscriptionsByFavorite option adds a filter to the query to get favorite subscriptions only.
func GetSubscriptionsByFeedIDs ¶
func GetSubscriptionsByFeedIDs(ids ...FeedID) subscriptionsRequestOption
GetSubscriptionsByFeedIDs option adds a filter to the query to get subscriptions by their feed ids.
func GetSubscriptionsByIDs ¶
func GetSubscriptionsByIDs(ids ...SubscriptionID) subscriptionsRequestOption
GetSubscriptionsByIDs option adds a filter to the query to get subscriptions by their ids.
func GetSubscriptionsDynamicInfo ¶
func GetSubscriptionsDynamicInfo(value bool) subscriptionsRequestOption
GetSubscriptionsDynamicInfo option will fill in the dynamic info (i.e., stats) after fetching.
func HTTPStatus ¶
HTTPStatus returns the HTTP status included in err. If err is nil, this function returns 0. If err is non-nil, and does not include an HTTP status, a default value of net/http.StatusInternalServerError is returned.
func IgnoreSubscriptions ¶ added in v0.54.0
func IgnoreSubscriptions(ids ...SubscriptionID) subscriptionsRequestOption
func MarkSubscriptions ¶
func MarkSubscriptions( ctx context.Context, mark Mark, subscriptionIDs ...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 NewFeedSortCombinations ¶ added in v0.110.0
func NewFeedSortCombinations(sort *Sort) []estypes.SortCombinations
func NewFeedSortOptions ¶ added in v0.110.0
func NewFeedSortOptions(sort *Sort) []estypes.SortCombinationsVariant
func NewItemSortCombinations ¶ added in v0.98.0
func NewItemSortCombinations(sort *Sort) []estypes.SortCombinations
func NewItemSortOptions ¶ added in v0.98.0
func NewItemSortOptions(sort *Sort) []estypes.SortCombinationsVariant
func RemoveSubscriptions ¶
func RemoveSubscriptions(ctx context.Context, ids ...SubscriptionID) error
RemoveSubscriptions removes subscriptions with the given ID from a user.
func SearchItems ¶
func SearchItems( ctx context.Context, query query.Option, count int, sort *Sort, pagination *Pagination, ) (Items, Pagination, error)
SearchItems will search the items index for items matching the given query. Count, sort and pagination values are optional.
func SearchResultsClause ¶
func SearchResultsClause(search *SearchRequest) query.BoolOption
func SearchSubscriptions ¶
func SearchSubscriptions( ctx context.Context, query query.Option, options ...searchSubscriptionsOption, ) (Subscriptions, Pagination, error)
func SearchSuggestionsClause ¶
func SearchSuggestionsClause(search *SearchRequest) query.BoolOption
func SliceToMap ¶
func SliceToMap[K comparable, V any, S any](s []S, mapFn func(S) (K, V)) map[K]V
SliceToMap generates a map from slice content by mapping key-value pairs from the slice with the given map function.
func SubscriptionsToCtx ¶
func SubscriptionsToCtx(ctx context.Context, subscriptions Subscriptions) context.Context
SubscriptionsToCtx stores the slice of Subscriptions in the context. Useful for pre-fetching/generating subscriptions for later usage.
func UpdateFavoriteSubscription ¶
func UpdateFavoriteSubscription(ctx context.Context, id 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.25.0
UpdateFeed applies the given updates to a Feed.
func UpdateSubscriptions ¶
func UpdateSubscriptions( ctx context.Context, subscriptions ...*Subscription, ) (map[SubscriptionID]*bulk.OperationResponse, error)
UpdateSubscriptions will bulk update the given subscriptions in Elasticsearch.
func UpdateUser ¶
UpdateUser will apply the given updates to the user.
Types ¶
type APIError ¶
type APIError struct {
// InternalError is the low-level, internal error.
InternalError error `json:"internal_error,omitempty"`
// StatusCode is the status code associated with the error. Usually, this is a HTTP status code.
StatusCode int `json:"status_code"`
// UserMessage represents a message that can be displayed to the user as the result of an action.
UserMessage *UserMessage `json:"user_message,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
}
APIError represents an error returned from any API within the service/application.
func NewAPIError ¶ added in v0.120.0
func NewAPIError(status int, err error, options ...ErrorOption) *APIError
func (APIError) Get ¶ added in v0.83.0
Getter for additional properties for APIError. Returns the specified element and whether it was found
func (*APIError) GetUserMessage ¶
func (e *APIError) GetUserMessage() *UserMessage
GetUserMessage returns a UserMessage associated with the error. It will return an appropriate generic error message or warning where no message is already defined.
func (*APIError) HTTPStatus ¶
HTTPStatus returns the status code of the API error.
func (APIError) MarshalJSON ¶ added in v0.83.0
Override default JSON handling for APIError to handle AdditionalProperties
func (*APIError) UnmarshalJSON ¶ added in v0.83.0
Override default JSON handling for APIError to handle AdditionalProperties
type AddCategoryToSubscriptionRequest ¶ added in v0.82.4
type AddCategoryToSubscriptionRequest struct {
// Category represents a taxonomy applied to an object.
Category Category `form:"category" json:"category"`
// ExistingCategories is a list of categories already assigned to the subscription.
ExistingCategories []Category `form:"customisation.categories" json:"existing_categories,omitempty"`
}
AddCategoryToSubscriptionRequest is a request to add a new category to a subscription.
func (*AddCategoryToSubscriptionRequest) Sanitise ¶ added in v0.82.4
func (r *AddCategoryToSubscriptionRequest) Sanitise() error
func (*AddCategoryToSubscriptionRequest) Valid ¶ added in v0.82.4
func (r *AddCategoryToSubscriptionRequest) Valid() error
type AddFeedSubscriptionRequest ¶
type AddFeedSubscriptionRequest struct {
// URL is a URL.
URL URL `form:"url" json:"url" validate:"omitempty,url"`
// FeedID is the unique ID of a feed.
FeedID FeedID `form:"feed_id" json:"feed_id" validate:"required,startswith=feed_"`
}
AddFeedSubscriptionRequest contains request data for adding a new feed subscription.
func (*AddFeedSubscriptionRequest) Sanitise ¶
func (f *AddFeedSubscriptionRequest) Sanitise() error
func (*AddFeedSubscriptionRequest) Valid ¶
func (f *AddFeedSubscriptionRequest) Valid() error
type AddFeedsetRequest ¶
type AddFeedsetRequest struct {
Feedset []string `form:"feedset,unique" json:"feedset,omitempty"`
}
AddFeedsetRequest is a request from a user to add one or more feed sets as subscriptions.
func (*AddFeedsetRequest) Sanitise ¶
func (r *AddFeedsetRequest) Sanitise() error
Sanitise will sanitise the input values of the SubscriptionRequest.
func (*AddFeedsetRequest) Valid ¶
func (r *AddFeedsetRequest) Valid() error
Valid returns a boolean indicating whether the SubscriptionRequest is valid, and any validation errors if applicable.
type AddSubscriptionFeedSuggestions ¶ added in v0.110.0
type AddSubscriptionFeedSuggestions struct {
// Feeds is a slice of feeds.
Feeds Feeds `json:"feeds,omitempty"`
// LatestItems is a map of latest items for each suggested feed.
LatestItems map[FeedID]Items `json:"latest_items,omitempty"`
}
AddSubscriptionFeedSuggestions contains feed suggestions details.
type AddSubscriptionResult ¶
type AddSubscriptionResult struct {
Subscription *FeedSubscription
Message *UserMessage
}
AddSubscriptionResult represents the result of creating a new subscription.
type AddSubscriptionSearchFilterRequest ¶
type AddSubscriptionSearchFilterRequest struct {
// InputName is the name of the input in the form into which this filter should be added.
InputName string `form:"subscriptions-input-name" json:"input_name"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
// SubscriptionName is the nickname of the subscription.
SubscriptionName string `form:"subscription_name" json:"subscription_name"`
}
AddSubscriptionSearchFilterRequest contains the data for adding a new subscription filter to a search request.
func (*AddSubscriptionSearchFilterRequest) Sanitise ¶
func (r *AddSubscriptionSearchFilterRequest) Sanitise() error
Sanitise will sanitise the add subscription search filter request.
func (*AddSubscriptionSearchFilterRequest) Valid ¶
func (r *AddSubscriptionSearchFilterRequest) Valid() error
Valid returns a boolean indicating whether the add subscription search filter data is valid.
type AddSubscriptionSuggestion ¶ added in v0.110.0
type AddSubscriptionSuggestion struct {
// FeedSuggestions contains feed suggestions details.
FeedSuggestions *AddSubscriptionFeedSuggestions `json:"feed_suggestions,omitempty"`
// YoutubeSuggestions contains Youtube suggestion details.
YoutubeSuggestions *AddSubscriptionYoutubeSuggestions `json:"youtube_suggestions,omitempty"`
}
AddSubscriptionSuggestion contains data about suggestions for adding a new subscription.
type AddSubscriptionToGroupRequest ¶ added in v0.82.4
type AddSubscriptionToGroupRequest struct {
// ExistingSubscriptions is the existing subscriptions in the group.
ExistingSubscriptions map[SubscriptionID]string `form:"subscriptions" json:"existing_subscriptions,omitempty"`
// SuggestionText is the name of the new subscription to add.
SuggestionText string `form:"suggestion_text" json:"suggestion_text" validate:"required"`
// Suggestions is the subscription suggestions.
Suggestions map[SubscriptionID]string `form:"suggestions" json:"suggestions"`
}
AddSubscriptionToGroupRequest is a request to add a new subscription to a group subscription.
func (*AddSubscriptionToGroupRequest) Sanitise ¶ added in v0.82.4
func (r *AddSubscriptionToGroupRequest) Sanitise() error
func (*AddSubscriptionToGroupRequest) Valid ¶ added in v0.82.4
func (r *AddSubscriptionToGroupRequest) Valid() error
type AddSubscriptionToSearchRequest ¶ added in v0.82.4
type AddSubscriptionToSearchRequest struct {
// SelectedSubscription is the name of the subscription that was selected from the suggestions.
SelectedSubscription string `form:"subscription-suggestion-text" json:"selected_subscription"`
// SuggestedSubscriptions is a list of the subscription suggestions.
SuggestedSubscriptions map[SubscriptionID]string `form:"subscription_suggestions" json:"suggested_subscriptions,omitempty"`
}
AddSubscriptionToSearchRequest is a request to add a new subscription to a search subscription.
func (*AddSubscriptionToSearchRequest) Sanitise ¶ added in v0.82.4
func (r *AddSubscriptionToSearchRequest) Sanitise() error
func (*AddSubscriptionToSearchRequest) Valid ¶ added in v0.82.4
func (r *AddSubscriptionToSearchRequest) Valid() error
type AddSubscriptionYoutubeSuggestions ¶ added in v0.110.0
type AddSubscriptionYoutubeSuggestions struct {
Channels []string `json:"channels,omitempty"`
}
AddSubscriptionYoutubeSuggestions contains Youtube suggestion details.
type Article ¶
type Article struct {
// Content contains the full article content, when it has been fetched from the origin link.
Content *string `json:"content,omitempty"`
// Favorite indicates whether this subscription has been marked as a Favorite by the user.
Favorite bool `json:"-"`
// Item represents an individual item (e.g., an individual feed item).
Item Item `json:"item"`
// MarkArticleReadOnView indicates whether to automatically mark an article as read when viewed.
MarkArticleReadOnView bool `json:"mark_article_read_on_view"`
// ShowFullContent indicates whether the full article content should be fetched and displayed instead of any content from the feed item itself.
ShowFullContent bool `json:"show_full_content"`
// SourceType indicates what type of source the object came from.
SourceType SourceType `json:"source_type"`
// State tracks the state of an article.
State ArticleState `json:"state"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
}
Article defines model for Article.
func (*Article) GetAuthors ¶
GetAuthors returns a slice of authors (if any) of the article.
func (*Article) GetCategories ¶
func (a *Article) GetCategories(num int) Categories
GetCategories returns the categories of the article (if any).
func (*Article) GetContent ¶
GetContent returns the main content of the article. This will be either the full content fetched remotely (if requested), the "content" field of the item (if not empty), or the description (if any).
func (*Article) GetDescription ¶
GetDescription returns the description of the article.
func (*Article) GetFeedTitle ¶
GetFeedTitle returns the title of the feed the article belongs to.
func (*Article) GetImage ¶
func (a *Article) GetImage() *RemoteImage
GetImage returns the image associated with the article.
func (*Article) GetObjectType ¶
func (a *Article) GetObjectType() ObjectType
GetObjectType returns the type of the object, in this case, "article".
func (*Article) GetSubscriptionID ¶
func (a *Article) GetSubscriptionID() SubscriptionID
GetSubscriptionID returns the ID of the user subscription the article belongs to.
func (*Article) GetUpdatedDate ¶
GetUpdatedDate returns the timestamp when the article was last updated (or created if no updates).
func (*Article) IsFavorite ¶
IsFavorite returns a boolean indicating whether the article has been favorited.
func (*Article) IsRemoteContent ¶
IsRemoteContent returns a boolean indicating whether the full content of the article should be shown.
type ArticleArchive ¶
type ArticleArchive struct {
// Timestamp is when the document was created.
Timestamp Timestamp `json:"@timestamp" validate:"required"`
// Authors is a list of people (names, nicknames and/or emails) who "authored" the object content.
Authors []string `json:"authors,omitempty"`
// Categories is a list of categories that define a taxonomy for the feed or item.
Categories []Category `json:"categories,omitempty" validate:"omitempty,unique"`
// Content contains the item content.
Content *string `json:"content,omitempty"`
// Contributors is a list of people (names, nicknames and/or emails) who "contributed" the object content.
Contributors []string `json:"contributors,omitempty"`
Copyright *string `json:"copyright,omitempty"`
// Description is a short summary or description of the feed or item.
Description *string `json:"description,omitempty"`
// ExtensionData contains the embedded extension data.
ExtensionData *ArticleArchive_ExtensionData `json:"extension_data,omitempty"`
// ExtensionType is the type of extension for this item.
ExtensionType *ArticleArchiveExtensionType `json:"extension_type,omitempty"`
// FeedID is the unique ID of a feed.
FeedID FeedID `form:"feed_id" json:"feed_id" validate:"required,startswith=feed_"`
// FeedTitle is the title of the feed to which this item belongs.
FeedTitle string `json:"feed_title" validate:"required"`
// Image contains details about a remote image.
Image *RemoteImage `json:"image,omitempty"`
// ItemID is the unique ID of an item.
ItemID ItemID `form:"item_id" json:"item_id" validate:"required,startswith=item_"`
Language *string `json:"language,omitempty"`
// Published is the datetime at which the feed or item was published.
Published time.Time `json:"published"`
// SourceType indicates what type of source the object came from.
SourceType SourceType `json:"source_type"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
// Title is the title of the feed or item.
Title string `json:"title"`
// Updated is the datetime at which the feed or item was updated.
Updated *time.Time `json:"updated,omitempty"`
// URL is the URL to the webpage for the feed or item. For a feed, this is most likely the webpage the feed is sourced from. For an item, this is most likely the webpage containing the full item contents.
URL string `json:"url,omitempty" validate:"omitempty,url"`
// UserID is the unique ID of a user.
UserID UserID `form:"user_id" json:"user_id" validate:"required,startswith=user_"`
}
ArticleArchive defines model for ArticleArchive.
func NewArchivedArticle ¶
func NewArchivedArticle(userID UserID, subscriptionID SubscriptionID, item *Item) (*ArticleArchive, error)
NewArchivedArticle creates a new archived article for long-term storage.
type ArticleArchiveExtensionType ¶ added in v0.61.0
type ArticleArchiveExtensionType string
ArticleArchiveExtensionType is the type of extension for this item.
const (
ArticleArchiveExtensionTypeYoutube ArticleArchiveExtensionType = "youtube"
)
Defines values for ArticleArchiveExtensionType.
func (ArticleArchiveExtensionType) Valid ¶ added in v0.79.0
func (e ArticleArchiveExtensionType) Valid() bool
Valid indicates whether the value is a known member of the ArticleArchiveExtensionType enum.
type ArticleArchive_ExtensionData ¶ added in v0.61.0
type ArticleArchive_ExtensionData struct {
// contains filtered or unexported fields
}
ArticleArchive_ExtensionData contains the embedded extension data.
func (ArticleArchive_ExtensionData) AsItemExtensionYoutube ¶ added in v0.61.0
func (t ArticleArchive_ExtensionData) AsItemExtensionYoutube() (ItemExtensionYoutube, error)
AsItemExtensionYoutube returns the union data inside the ArticleArchive_ExtensionData as a ItemExtensionYoutube
func (*ArticleArchive_ExtensionData) FromItemExtensionYoutube ¶ added in v0.61.0
func (t *ArticleArchive_ExtensionData) FromItemExtensionYoutube(v ItemExtensionYoutube) error
FromItemExtensionYoutube overwrites any union data inside the ArticleArchive_ExtensionData as the provided ItemExtensionYoutube
func (ArticleArchive_ExtensionData) MarshalJSON ¶ added in v0.61.0
func (t ArticleArchive_ExtensionData) MarshalJSON() ([]byte, error)
func (*ArticleArchive_ExtensionData) MergeItemExtensionYoutube ¶ added in v0.61.0
func (t *ArticleArchive_ExtensionData) MergeItemExtensionYoutube(v ItemExtensionYoutube) error
MergeItemExtensionYoutube performs a merge with any union data inside the ArticleArchive_ExtensionData, using the provided ItemExtensionYoutube
func (*ArticleArchive_ExtensionData) UnmarshalJSON ¶ added in v0.61.0
func (t *ArticleArchive_ExtensionData) UnmarshalJSON(b []byte) error
type ArticleMetadata ¶
type ArticleMetadata struct {
// SourceType indicates what type of source the object came from.
SourceType SourceType `json:"source_type"`
// State tracks the state of an article.
State ArticleState `json:"state"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
}
ArticleMetadata contains the stored data that represents an article.
type ArticleSettings ¶
type ArticleSettings struct {
// MarkArticleReadOnView indicates whether to automatically mark an article as read when viewed.
MarkArticleReadOnView bool `json:"mark_article_read_on_view"`
// ShowFullContent indicates whether the full article content should be fetched and displayed instead of any content from the feed item itself.
ShowFullContent bool `json:"show_full_content"`
}
ArticleSettings contains settings related to the display of the article.
type ArticleState ¶
type ArticleState struct {
// Read indicates whether the object has been read (true) or is unread (false).
Read bool `json:"read"`
// UpdatedAt records when the object was last updated in the database.
UpdatedAt UpdatedAt `json:"updated_at,omitempty" validate:"omitnil"`
}
ArticleState tracks the state of an article.
func (*ArticleState) MarkRead ¶
func (s *ArticleState) MarkRead(markedAt time.Time)
MarkRead will set the article state to read.
func (*ArticleState) MarkUnread ¶
func (s *ArticleState) MarkUnread(markedAt time.Time)
MarkUnread will set the article state to unread.
type Articles ¶
type Articles []*Article
Articles is a slices of Article objects.
func FindSimilarArticles ¶
FindSimilarArticles performs a "more like this" search to find other Articles that are similar to the Items with the given IDs.
func GenerateArticles ¶
GenerateArticles takes a slice of items and creates articles from them, grabbing the necessary data from the user object.
func GetArticles ¶
GetArticles generates Article objects from the Items with the given IDs.
func (Articles) FilterByView ¶ added in v0.26.0
FilterByView returns a slice containing the subscription which match the given view state.
func (Articles) GetCategoryCounts ¶
func (a Articles) GetCategoryCounts() CategoryCounts
GetCategoryCounts returns a count of the occurrence of a Category across all the Articles in the slice.
func (Articles) GetFeedIDs ¶
GetFeedIDs retrieves the feed ids for all articles in the slice.
func (Articles) GetSubscriptionIDs ¶
func (a Articles) GetSubscriptionIDs() []SubscriptionID
GetSubscriptionIDs retrieves the subscription ids for all articles in the slice.
type Author ¶ added in v0.101.0
type Author struct {
// Email is an email address.
Email *string `json:"email,omitempty" validate:"omitempty,email"`
// Name is the name of the person. Can be any combination of first name and last name, in any order.
Name string `json:"name"`
// URL is a URL.
URL *URL `form:"url" json:"url" validate:"omitempty,url"`
}
Author represents a person who contributed to a feed or item.
type Categories ¶
type Categories []Category
Categories is a slice of categories.
func (Categories) HasCategory ¶
func (c Categories) HasCategory(category Category) bool
HasCategory is a convienience function to check if the given category is in the slice of categories.
type CategoryCount ¶
type CategoryCount struct {
// Category represents a taxonomy applied to an object.
Category Category `form:"category" json:"category"`
Count int `json:"count"`
}
CategoryCount holds a category and the count of its occurence. The count will be contextual. i.e., across subscriptions, items, etc.
type CategoryCounts ¶
type CategoryCounts []CategoryCount
CategoryCounts is a slice of Categories and their counts.
func GetCategoriesForSubscriptions ¶ added in v0.27.0
func GetCategoriesForSubscriptions(ctx context.Context, subscriptionIDs ...SubscriptionID) (CategoryCounts, error)
func GetCategoryCounts ¶
func GetCategoryCounts(subscriptions ...*Subscription) CategoryCounts
GetCategoryCounts returns a count of the occurrence of a Category across all the Subscriptions.
func GetSubscriptionCategories ¶ added in v0.27.0
func GetSubscriptionCategories(ctx context.Context, subscriptions Subscriptions) (CategoryCounts, error)
GetSubscriptionCategories retrieves a map of categories from user subscriptions by count.
func GetTopCategoriesForItems ¶ added in v0.27.0
func (CategoryCounts) GetCategories ¶ added in v0.55.0
func (c CategoryCounts) GetCategories() []Category
func (CategoryCounts) Limit ¶ added in v0.55.0
func (c CategoryCounts) Limit(count int) CategoryCounts
Limit returns the n top Categories from the list of CategoryCounts.
func (CategoryCounts) Sort ¶
func (c CategoryCounts) Sort()
Sort will sort the list of CategoryCounts by the count values.
type CategoryFilters ¶ added in v0.27.0
type CategoryFilters struct {
Categories CategoryCounts `json:"categories"`
// Filters contains filters for altering the display of objects.
Filters ListFilters `json:"filters" validate:"required"`
Path string `json:"path"`
}
CategoryFilters contains categories that can be used for filtering.
type ChangePasswordRequest ¶
type ChangePasswordRequest struct {
// ConfirmNewPassword is the new password (again), used for confirmation.
ConfirmNewPassword *string `form:"confirm_new_password" json:"confirm_new_password,omitempty" validate:"required"`
// NewPassword is the new password.
NewPassword string `form:"new_password" json:"new_password" validate:"required,eqfield=ConfirmNewPassword"`
}
ChangePasswordRequest contains details for changing a user password.
func (*ChangePasswordRequest) Sanitise ¶
func (r *ChangePasswordRequest) Sanitise() error
Sanitise will sanitise the user input for a ChangePasswordRequest.
func (*ChangePasswordRequest) Valid ¶
func (r *ChangePasswordRequest) Valid() error
Valid returns a boolean indicating whether the ChangePasswordRequest contains valid data.
type EditEmailSubscriptionRequest ¶ added in v0.26.0
type EditEmailSubscriptionRequest struct {
Customisation *SubscriptionCustomisation `form:"customisation" json:"customisation,omitempty"`
Settings *SubscriptionSettings `form:"settings" json:"settings,omitempty"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
// SuggestedCategories is a list of suggested categories for the subscription.
SuggestedCategories []Category `form:"-" json:"-"`
}
EditEmailSubscriptionRequest represents a request to create an email subscription.
func (*EditEmailSubscriptionRequest) Sanitise ¶ added in v0.26.0
func (r *EditEmailSubscriptionRequest) Sanitise() error
Sanitise will sanitise the input values of the SubscriptionRequest.
func (*EditEmailSubscriptionRequest) Valid ¶ added in v0.26.0
func (r *EditEmailSubscriptionRequest) Valid() error
Valid returns a boolean indicating whether the SubscriptionRequest is valid, and any validation errors if applicable.
type EditUserRequest ¶
type EditUserRequest = UserCustomisation
EditUserRequest contains account fields that a user can customize.
func (*EditUserRequest) Sanitise ¶
func (s *EditUserRequest) Sanitise() error
Sanitise will sanitise the user input for a SubscriptionCustomisation.
func (*EditUserRequest) Valid ¶
func (s *EditUserRequest) Valid() error
Valid returns a boolean indicating if the Subscription contains valid data (true). If it contains invalid data (false) a non-nil error is also returned which contains validation issues.
type ElementID ¶ added in v0.35.0
type ElementID string
ID represents an id attribute in a HTML element.
type EmailSenderID ¶ added in v0.25.0
type EmailSenderID = string
EmailSenderID is an email address that sends emails.
type EmailSubscription ¶ added in v0.25.0
type EmailSubscription struct {
// ArticleFilters holds filters to apply to the articles within a subscription.
ArticleFilters *SubscriptionArticleFilters `form:"article_filters" json:"article_filters"`
// ArticleStates contains the states of items marked explicitly as read/unread/saved by the user.
ArticleStates map[ItemID]ArticleState `json:"article_states" validate:"required"`
// EmailSenderID is an email address that sends emails.
EmailSenderID EmailSenderID `form:"email_sender_id" json:"email_sender_id" validate:"required,email"`
// FeedID is the unique ID of a feed.
FeedID FeedID `form:"feed_id" json:"feed_id" validate:"required,startswith=feed_"`
}
EmailSubscription is a subscription to an email newsletter source.
func (*EmailSubscription) Valid ¶ added in v0.25.0
func (s *EmailSubscription) Valid() error
Valid returns a non-nil error if the EmailSubscription contains invalid data.
type ErrorOption ¶ added in v0.120.0
type ErrorOption func(*APIError)
func WithUserErrorDescription ¶ added in v0.120.0
func WithUserErrorDescription(msg string) ErrorOption
func WithUserErrorSummary ¶ added in v0.120.0
func WithUserErrorSummary(msg string) ErrorOption
type ExtractedMetadata ¶ added in v0.108.0
type ExtractedMetadata struct {
// Author is an author attributed to the page/link.
Author *string `json:"author,omitempty"`
// Categories is a list of categories associated with the page/link.
Categories []string `json:"categories,omitempty"`
// Date is a datestamp associated with the page/link published/updated time.
Date *string `json:"date,omitempty"`
// Description is a summary of the content of the page/link.
Description *string `json:"description,omitempty"`
// Sitename is the site name.
Sitename *string `json:"sitename,omitempty"`
// Tags is a list of tags associated with the page/link.
Tags []string `json:"tags,omitempty"`
// Title is the title of the page/link
Title *string `json:"title,omitempty"`
}
ExtractedMetadata contains key information about the link/site that was extracted.
type ExtractorErrorResponse ¶ added in v0.108.0
type ExtractorErrorResponse struct {
// Detail is the summary/reason for the error.
Detail string `json:"detail"`
}
ExtractorErrorResponse represents the response from the extractor when an error occurred.
type ExtractorResponse ¶ added in v0.108.0
type ExtractorResponse struct {
// Content is the extracted data.
Content *string `json:"content,omitempty"`
// ExtractedAt is a timestamp of when the content was extracted
ExtractedAt *int `json:"extracted_at,omitempty"`
// Format is the output format of the content field.
Format *ExtractorResponseFormat `json:"format,omitempty" validate:"omitempty,oneof=markdown txt html xml json"`
// Metadata contains key information about the link/site that was extracted.
Metadata *ExtractedMetadata `json:"metadata,omitempty"`
// URL is a URL.
URL URL `form:"url" json:"url" validate:"omitempty,url"`
}
ExtractorResponse represents the response from the extractor component.
type ExtractorResponseFormat ¶ added in v0.108.0
type ExtractorResponseFormat string
ExtractorResponseFormat is the output format of the content field.
const ( ExtractorResponseFormatHtml ExtractorResponseFormat = "html" ExtractorResponseFormatJson ExtractorResponseFormat = "json" ExtractorResponseFormatMarkdown ExtractorResponseFormat = "markdown" ExtractorResponseFormatTxt ExtractorResponseFormat = "txt" ExtractorResponseFormatXml ExtractorResponseFormat = "xml" )
Defines values for ExtractorResponseFormat.
func (ExtractorResponseFormat) Valid ¶ added in v0.108.0
func (e ExtractorResponseFormat) Valid() bool
Valid indicates whether the value is a known member of the ExtractorResponseFormat enum.
type FavoriteArticleRequest ¶ added in v0.31.0
type FavoriteArticleRequest struct {
// ItemID is the unique ID of an item.
ItemID ItemID `form:"item_id" json:"item_id" validate:"required,startswith=item_"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
}
FavoriteArticleRequest contains parameters for favoriting an article.
func (*FavoriteArticleRequest) Sanitise ¶ added in v0.31.0
func (r *FavoriteArticleRequest) Sanitise() error
func (*FavoriteArticleRequest) Valid ¶ added in v0.31.0
func (r *FavoriteArticleRequest) Valid() error
type FavoriteSubscriptionRequest ¶ added in v0.31.0
type FavoriteSubscriptionRequest struct {
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
}
FavoriteSubscriptionRequest contains parameters for favoriting a subscription.
func (*FavoriteSubscriptionRequest) Sanitise ¶ added in v0.31.0
func (s *FavoriteSubscriptionRequest) Sanitise() error
Sanitise will sanitise the FavoriteSubscriptionsRequest, ensuring it contains valid field values.
func (*FavoriteSubscriptionRequest) Valid ¶ added in v0.31.0
func (s *FavoriteSubscriptionRequest) Valid() error
Valid checks that the FavoriteSubscriptionsRequest contains valid data.
type Feed ¶
type Feed struct {
// Authors is a list of people (names, nicknames and/or emails) who "authored" the object content.
Authors []string `json:"authors,omitempty"`
// Categories is a list of categories that define a taxonomy for the feed or item.
Categories []Category `json:"categories,omitempty" validate:"omitempty,unique"`
// Contributors is a list of people (names, nicknames and/or emails) who "contributed" the object content.
Contributors []string `json:"contributors,omitempty"`
Copyright *string `json:"copyright,omitempty"`
// CreatedAt records when the object was created in the database.
CreatedAt CreatedAt `json:"created_at" validate:"required"`
// Description is a short summary or description of the feed or item.
Description *string `json:"description,omitempty"`
// FeedID is the unique ID of a feed.
FeedID FeedID `form:"feed_id" json:"feed_id" validate:"required,startswith=feed_"`
// Image contains details about a remote image.
Image *RemoteImage `json:"image,omitempty"`
// Items contains the list of items in the feed.
Items []Item `json:"-"`
Language *string `json:"language,omitempty"`
// LastFetched indicates when an object was last fetched.
LastFetched LastFetched `json:"last_fetched,omitempty"`
// Published is the datetime at which the feed or item was published.
Published time.Time `json:"published"`
// SourceType indicates what type of source the object came from.
SourceType SourceType `json:"source_type"`
// SourceURLs is a list of URLs that point to the feed source. These might be either the website corresponding to the feed or the
SourceURLs []URL `json:"source_urls" validate:"required,dive,url"`
// Title is the title of the feed or item.
Title string `json:"title"`
// UpdateInterval indicates how often the feed is updated. Where a feed does not supply an actual update interval, this value will be derived from the median update interval between published items.
UpdateInterval int64 `json:"update_interval"`
// Updated is the datetime at which the feed or item was updated.
Updated *time.Time `json:"updated,omitempty"`
// URL is the URL to the webpage for the feed or item. For a feed, this is most likely the webpage the feed is sourced from. For an item, this is most likely the webpage containing the full item contents.
URL string `json:"url,omitempty" validate:"omitempty,url"`
}
Feed defines model for Feed.
func FindOrCreateFeed ¶ added in v0.82.4
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 GetFeedByID ¶ added in v0.25.0
GetFeedByID fetches the given Feed by its id.
func NewFeedFromURL ¶
NewFeedFromURL generates a new Feed object from the given URL. If there is a problem generating the object, a non-nil error is returned.
func (*Feed) GetAuthors ¶
GetAuthors returns the feed authors, if any.
func (*Feed) GetCategories ¶
GetCategories returns the slice of categories assigned to the feed, if any.
func (*Feed) GetContributors ¶
GetContributors returns the feed contributors, if any.
func (*Feed) GetDescription ¶
GetDescription returns the feed description, if any.
func (*Feed) GetImage ¶
func (f *Feed) GetImage() *RemoteImage
GetImage returns an image object that can visually represent the feed.
func (*Feed) GetLanguage ¶
GetLanguage returns the language tag of the feed, if any.
func (*Feed) GetLink ¶
GetLink returns the URL of the website that publishes and/or is the owner the feed.
func (*Feed) GetSourceURLs ¶
GetSourceURLs returns all discovered source URLs of the feed (i.e., URLs that point to the feed itself).
func (*Feed) GetTimestamp ¶
GetTimestamp returns a timestamp indicating when the feed was last updated. This will be either, the updated timestamp in the feed, or, the published timestamp in the feed, or the last fetched timestamp, whichever is found and is a valid value, in that order.
func (*Feed) SetUpdateInterval ¶ added in v0.24.0
SetUpdateInterval will set the update interval of the feed. It fetches the feed details from the source and determines a reasonable update interval. In the case of errors, a default interval will be set.
type FeedSorting ¶
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 ¶
func (s *FeedSorting) SortCombinationsCaster() *estypes.SortCombinations
SortCombinationsCaster is required to allow FeedSorting to be used as Elasticsearch sort values.
type FeedStatus ¶ added in v0.46.0
type FeedStatus struct {
// FeedID is the unique ID of a feed.
FeedID FeedID `form:"feed_id" json:"feed_id" validate:"required,startswith=feed_"`
// Items is a list of IDs of items that were added.
Items []ItemID `json:"items,omitempty"`
// StatusCode is the HTTP status code returned when fetching.
StatusCode int `json:"status_code"`
// StatusMessage is a message associated with the status code.
StatusMessage *string `json:"status_message,omitempty"`
// Timestamp is when the document was created.
Timestamp Timestamp `json:"@timestamp" validate:"required"`
// URL is a URL.
URL URL `form:"url" json:"url" validate:"omitempty,url"`
}
FeedStatus represents the status of fetching the feed.
func (*FeedStatus) GetID ¶ added in v0.46.0
func (s *FeedStatus) GetID() string
GetID retrieves (generates) a unique ID for a FeedStatus object.
type FeedSubscription ¶
type FeedSubscription struct {
// ArticleFilters holds filters to apply to the articles within a subscription.
ArticleFilters *SubscriptionArticleFilters `form:"article_filters" json:"article_filters"`
// ArticleStates contains the states of items marked explicitly as read/unread/saved by the user.
ArticleStates map[ItemID]ArticleState `json:"article_states" validate:"required"`
// FeedID is the unique ID of a feed.
FeedID FeedID `form:"feed_id" json:"feed_id" validate:"required,startswith=feed_"`
}
FeedSubscription represents a feed a user has subscribed to.
func (*FeedSubscription) GetFeedID ¶
func (s *FeedSubscription) GetFeedID() FeedID
GetFeedID returns the feed ID.
func (*FeedSubscription) Valid ¶
func (s *FeedSubscription) Valid() error
Valid returns a boolean indicating if the Subscription contains valid data (true). If it contains invalid data (false) a non-nil error is also returned which contains validation issues.
type FeedSubscriptionRequest ¶ added in v0.82.4
type FeedSubscriptionRequest struct {
// URL is the URL of the feed data. Used when adding a new feed subscription.
URL string `form:"url" json:"URL" validate:"required_without=SubscriptionID,omitempty,url"`
// ArticleFilters holds filters to apply to the articles within a subscription.
ArticleFilters *SubscriptionArticleFilters `form:"article_filters" json:"article_filters"`
// Customisation contains object fields that can be customised (overridden) by a user.
Customisation *SubscriptionCustomisation `form:"customisation" json:"customisation,omitempty"`
Settings *SubscriptionSettings `form:"settings" json:"settings,omitempty"`
// SubscriptionID is the existing subscription ID. Will be empty when adding a new feed subscription.
SubscriptionID string `form:"subscription_id" json:"subscription_id" validate:"required_without=URL,omitempty,startswith=sub_"`
// SuggestedCategories is a list of suggested categories for the subscription.
SuggestedCategories []Category `form:"-" json:"-"`
}
FeedSubscriptionRequest is a request to add a new feed subscription.
func GenerateRequestsFromOutlines ¶
func GenerateRequestsFromOutlines(outlines ...opml.Outline) []FeedSubscriptionRequest
func (*FeedSubscriptionRequest) Sanitise ¶ added in v0.82.4
func (r *FeedSubscriptionRequest) Sanitise() error
func (*FeedSubscriptionRequest) Valid ¶ added in v0.82.4
func (r *FeedSubscriptionRequest) Valid() error
type FeedSubscriptionResult ¶ added in v0.82.4
type FeedSubscriptionResult struct {
// Error represents an error returned from any API within the service/application.
Error *APIError `json:"error,omitempty"`
// Request is a request to add a new feed subscription.
Request *FeedSubscriptionRequest `json:"request,omitempty"`
// Subscription represents any kind of subscription.
Subscription *Subscription `json:"subscription,omitempty"`
}
FeedSubscriptionResult is the result of adding a feed subscription.
func BulkImportFeeds ¶ added in v0.82.4
func BulkImportFeeds(ctx context.Context, requests ...FeedSubscriptionRequest) []FeedSubscriptionResult
BulkImportFeeds handles processing any number of NewFeedSubscriptionRequest requests.
type Feeds ¶
type Feeds []*Feed
Feeds is a slice of Feed objects.
type FileDetails ¶ added in v0.49.0
type FileDetails struct {
// File is the path in an embedded FS to the file.
File string `json:"file" toml:"file" validate:"required,filepath"`
// Path is the relative URL path from where this document should be served.
Path string `json:"path" toml:"path" validate:"required,filepath"`
}
FileDetails contains a mapping of a file in an embedded FS to the URL path it is served from.
type FileIndex ¶ added in v0.49.0
type FileIndex struct {
// Files is a list of details for files.
Files []FileDetails `json:"files,omitempty" toml:"file"`
// UpdatedAt indicates when the index was last updated.
UpdatedAt *time.Time `json:"updated_at,omitempty" toml:"updated_at"`
}
FileIndex contains a listing of files in a directory of an embedded FS.
type FileUpload ¶
type FileUpload struct {
// Data is the file data/content.
Data multipart.File `json:"data" validate:"required"`
// Header is the mime header information of the file.
Header *multipart.FileHeader `json:"header" validate:"required"`
}
FileUpload represents a file upload by a user.
func (*FileUpload) ParseMimetype ¶
func (f *FileUpload) ParseMimetype() (string, error)
ParseMimetype attempts to parse and return the mimetype of the file from its mime header.
func (*FileUpload) Valid ¶
func (f *FileUpload) Valid() error
Valid will return a non-nill error containing details of any validation issues with the file upload data. Otherwise, a nil error is returned if the data is valid.
type Filters ¶
type Filters interface {
Valid() error
GetSort() Sort
GetCount() int
GetView() View
GetCategories() Categories
Values() map[string]any
QueryString() string
}
Filters represents either Subscription or Article filters.
type GetSubscriptionOption ¶ added in v0.110.0
type GetSubscriptionOption func(*GetSubscriptionOptions)
func Favorites ¶ added in v0.110.0
func Favorites(value bool) GetSubscriptionOption
func WithDynamicInfo ¶ added in v0.112.0
func WithDynamicInfo(value bool) GetSubscriptionOption
func WithSubscriptionCategories ¶ added in v0.110.0
func WithSubscriptionCategories(categories ...Category) GetSubscriptionOption
func WithSubscriptionIDs ¶ added in v0.110.0
func WithSubscriptionIDs(ids ...SubscriptionID) GetSubscriptionOption
type GetSubscriptionOptions ¶ added in v0.110.0
type GetSubscriptionOptions struct {
OnlyFavorites bool
DynamicInfo bool
IDs []SubscriptionID
Categories []Category
}
GetSubscriptionOptions holds the options for fetching a user's subscriptions.
type GetSubscriptionsSuggestionRequest ¶
type GetSubscriptionsSuggestionRequest struct {
// IgnoredSubscriptions is a list of subscription IDs to ignore for suggestions.
IgnoredSubscriptions []SubscriptionID `form:"subscription_id" json:"ignored_subscriptions,omitempty"`
// Text is a string that should match a subscription.
Text string `form:"subscription-suggestion-text" json:"text"`
}
GetSubscriptionsSuggestionRequest contains the data for finding matching subscriptions as suggestion results.
func (*GetSubscriptionsSuggestionRequest) Sanitise ¶
func (r *GetSubscriptionsSuggestionRequest) Sanitise() error
func (*GetSubscriptionsSuggestionRequest) Valid ¶
func (r *GetSubscriptionsSuggestionRequest) Valid() error
type GroupSubscription ¶
type GroupSubscription struct {
// ArticleFilters holds filters to apply to the articles within a subscription.
ArticleFilters *SubscriptionArticleFilters `form:"article_filters" json:"article_filters"`
// Subscriptions is the list of subscription IDs belonging to the group.
Subscriptions []SubscriptionID `form:"subscriptions" json:"subscriptions" validate:"required,dive,startswith=sub_"`
}
GroupSubscription represents a subscription that combines other subscriptions.
func (*GroupSubscription) Valid ¶
func (s *GroupSubscription) Valid() error
Valid returns a boolean indicating if the Subscription contains valid data (true). If it contains invalid data (false) a non-nil error is also returned which contains validation issues.
type GroupSubscriptionRequest ¶
type GroupSubscriptionRequest struct {
// ArticleFilters holds filters to apply to the articles within a subscription.
ArticleFilters *SubscriptionArticleFilters `form:"article_filters" json:"article_filters"`
Customisation *SubscriptionCustomisation `form:"customisation" json:"customisation,omitempty"`
Settings *SubscriptionSettings `form:"settings" json:"settings,omitempty"`
// SubscriptionID will be a subscription ID if the user is editing an existing group subscription.
SubscriptionID *SubscriptionID `form:"subscription_id" json:"-" validate:"omitempty,startswith=sub_"`
// Subscriptions contains details of the subscriptions in the group.
Subscriptions map[SubscriptionID]string `form:"subscriptions" json:"subscriptions" validate:"required"`
// SuggestedCategories is a list of suggested categories for the subscription.
SuggestedCategories []Category `form:"-" json:"-"`
// SuggestedSubscriptions is a list of suggested subscriptions for the subscription.
SuggestedSubscriptions Subscriptions `form:"-" json:"-"`
}
GroupSubscriptionRequest represents a request to create a group subscription.
func NewGroupSubscriptionRequest ¶ added in v0.54.0
func NewGroupSubscriptionRequest( suggestedSubscriptions Subscriptions, suggestedCategories []Category, ) *GroupSubscriptionRequest
func (*GroupSubscriptionRequest) Sanitise ¶
func (r *GroupSubscriptionRequest) Sanitise() error
func (*GroupSubscriptionRequest) Valid ¶
func (r *GroupSubscriptionRequest) Valid() error
type GroupSubscriptionSuggestionRequest ¶ added in v0.54.0
type GroupSubscriptionSuggestionRequest struct {
// IgnoredSubscriptions contains subscriptions that can be ignored and not suggested.
IgnoredSubscriptions map[SubscriptionID]string `form:"subscriptions" json:"ignored_subscriptions,omitempty"`
// Text is the text of a subscription to match for a suggestion.
Text string `form:"text" json:"text"`
}
GroupSubscriptionSuggestionRequest contains details for suggesting a subscription to add to a group.
func (*GroupSubscriptionSuggestionRequest) Sanitise ¶ added in v0.54.0
func (r *GroupSubscriptionSuggestionRequest) Sanitise() error
func (*GroupSubscriptionSuggestionRequest) Valid ¶ added in v0.54.0
func (r *GroupSubscriptionSuggestionRequest) Valid() error
type HomeResponse ¶ added in v0.37.0
type HomeResponse struct {
LatestArticles Articles `json:"latest_articles,omitempty"`
RareCategories CategoryCounts `json:"rare_categories,omitempty"`
Subscriptions Subscriptions `json:"subscriptions,omitempty"`
TopCategories map[CategoryCount]Articles `json:"top_categories,omitempty"`
}
HomeResponse contains the data for displaying the home page.
type Item ¶
type Item struct {
// Timestamp is when the document was created.
Timestamp Timestamp `json:"@timestamp" validate:"required"`
// Authors is a list of people (names, nicknames and/or emails) who "authored" the object content.
Authors []string `json:"authors,omitempty"`
// Categories is a list of categories that define a taxonomy for the feed or item.
Categories []Category `json:"categories,omitempty" validate:"omitempty,unique"`
// Content contains the item content.
Content *string `json:"content,omitempty"`
// Contributors is a list of people (names, nicknames and/or emails) who "contributed" the object content.
Contributors []string `json:"contributors,omitempty"`
Copyright *string `json:"copyright,omitempty"`
// Description is a short summary or description of the feed or item.
Description *string `json:"description,omitempty"`
// ExtensionData contains the embedded extension data.
ExtensionData *Item_ExtensionData `json:"extension_data,omitempty"`
// ExtensionType is the type of extension for this item.
ExtensionType *ItemExtensionType `json:"extension_type,omitempty"`
// FeedID is the unique ID of a feed.
FeedID FeedID `form:"feed_id" json:"feed_id" validate:"required,startswith=feed_"`
// FeedTitle is the title of the feed to which this item belongs.
FeedTitle string `json:"feed_title" validate:"required"`
// Image contains details about a remote image.
Image *RemoteImage `json:"image,omitempty"`
// ItemID is the unique ID of an item.
ItemID ItemID `form:"item_id" json:"item_id" validate:"required,startswith=item_"`
Language *string `json:"language,omitempty"`
// Published is the datetime at which the feed or item was published.
Published time.Time `json:"published"`
// SourceType indicates what type of source the object came from.
SourceType SourceType `json:"source_type"`
// Title is the title of the feed or item.
Title string `json:"title"`
// Updated is the datetime at which the feed or item was updated.
Updated *time.Time `json:"updated,omitempty"`
// URL is the URL to the webpage for the feed or item. For a feed, this is most likely the webpage the feed is sourced from. For an item, this is most likely the webpage containing the full item contents.
URL string `json:"url,omitempty" validate:"omitempty,url"`
}
Item defines model for Item.
func NewEmailItem ¶ added in v0.25.0
func NewEmailItem(email Email, subscription *Subscription) *Item
NewEmailItem generates a new Item from an email.
func NewFeedItem ¶ added in v0.25.0
NewFeedItem generates an Item from the underlying feed data.
func (*Item) GetAuthors ¶
GetAuthors returns a slice of the item's authors, if any.
func (*Item) GetCategories ¶
GetCategories returns a slice of the item's categories, if any.
func (*Item) GetContent ¶
GetContent returns the full item content, if set.
func (*Item) GetContributors ¶
GetContributors returns a slice of the item's contributors, if any.
func (*Item) GetDescription ¶
GetDescription returns the summary of the item content, if any.
func (*Item) GetImage ¶
func (i *Item) GetImage() *RemoteImage
GetImage returns an image that can represent the item, if any.
func (*Item) GetLanguage ¶
GetLanguage returns the language of the item, if set.
func (*Item) GetLink ¶
GetLink returns the URL that should point to a page containing the full item content.
func (*Item) GetTimestamp ¶
GetTimestamp returns a timestamp indicating when the item was last updated. This will be either, the published timestamp, or, the updated timestamp, or the indexing timestamp, whichever is found and is a valid value, in that order.
func (*Item) HasContent ¶ added in v0.104.0
HasContent returns a boolean indicating whether the item has full or partial content.
func (*Item) IsNewer ¶
IsNewer returns a boolean indicating whether this item has been updated or published after the given time and before now (to ignore potentially incorrect dates in the future).
func (*Item) WasUpdated ¶ added in v0.104.0
WasUpdated returns a boolean indicating whether the item has been updated since being published.
type ItemExtensionType ¶ added in v0.61.0
type ItemExtensionType string
ItemExtensionType is the type of extension for this item.
const (
ItemExtensionTypeYoutube ItemExtensionType = "youtube"
)
Defines values for ItemExtensionType.
func (ItemExtensionType) Valid ¶ added in v0.79.0
func (e ItemExtensionType) Valid() bool
Valid indicates whether the value is a known member of the ItemExtensionType enum.
type ItemExtensionYoutube ¶ added in v0.61.0
type ItemExtensionYoutube struct {
// Height is the video height.
Height *int `json:"height,omitempty"`
// VideoId is the Youtube video ID for the video.
VideoId string `json:"video_id"`
// Width is the video width.
Width *int `json:"width,omitempty"`
}
ItemExtensionYoutube is an item extension for Youtube videos.
type ItemSorting ¶
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 ¶
func (s *ItemSorting) SortCombinationsCaster() *estypes.SortCombinations
SortCombinationsCaster is required to allow ItemSorting to be used as Elasticsearch sort values.
type ItemSource ¶ added in v0.27.0
type Item_ExtensionData ¶ added in v0.61.0
type Item_ExtensionData struct {
// contains filtered or unexported fields
}
Item_ExtensionData contains the embedded extension data.
func (Item_ExtensionData) AsItemExtensionYoutube ¶ added in v0.61.0
func (t Item_ExtensionData) AsItemExtensionYoutube() (ItemExtensionYoutube, error)
AsItemExtensionYoutube returns the union data inside the Item_ExtensionData as a ItemExtensionYoutube
func (*Item_ExtensionData) FromItemExtensionYoutube ¶ added in v0.61.0
func (t *Item_ExtensionData) FromItemExtensionYoutube(v ItemExtensionYoutube) error
FromItemExtensionYoutube overwrites any union data inside the Item_ExtensionData as the provided ItemExtensionYoutube
func (Item_ExtensionData) MarshalJSON ¶ added in v0.61.0
func (t Item_ExtensionData) MarshalJSON() ([]byte, error)
func (*Item_ExtensionData) MergeItemExtensionYoutube ¶ added in v0.61.0
func (t *Item_ExtensionData) MergeItemExtensionYoutube(v ItemExtensionYoutube) error
MergeItemExtensionYoutube performs a merge with any union data inside the Item_ExtensionData, using the provided ItemExtensionYoutube
func (*Item_ExtensionData) UnmarshalJSON ¶ added in v0.61.0
func (t *Item_ExtensionData) UnmarshalJSON(b []byte) error
type Items ¶
type Items []Item
Items is a slice of items.
func (Items) FilterByFeed ¶
FilterByFeed filters items to ones which match the given feed ID.
func (Items) FilterSince ¶
FilterSince filters items to ones which are newer than the given timestamp.
func (Items) GetCategoryCounts ¶
func (i Items) GetCategoryCounts() CategoryCounts
GetCategoryCounts returns a count of the occurrence of a Category across all the Items.
func (Items) GetFeedIDs ¶
GetFeedIDs retrieves a list of all FeedIDs from all items.
func (Items) SortByTimestamp ¶
SortByTimestamp sorts the items by their timestamps, in descending order.
type JobState ¶
type JobState struct {
JobData json.RawMessage `json:"job_data,omitempty"`
// UpdatedAt records when the object was last updated in the database.
UpdatedAt UpdatedAt `json:"updated_at,omitempty" validate:"omitnil"`
}
JobState represents the stored state of a scheduled job.
type LastFetched ¶ added in v0.46.0
LastFetched indicates when an object was last fetched.
type ListArticlesResponse ¶
type ListArticlesResponse struct {
Articles Articles `json:"articles"`
// Filters contains filters for altering the display of objects.
Filters ListFilters `json:"filters" validate:"required"`
// Pagination contains data for paginating through results.
Pagination Pagination `form:"pagination" json:"pagination" validate:"omitempty,url_encoded"`
Subscription *Subscription `json:"subscription,omitempty"`
}
ListArticlesResponse contains the data retrieved and relevant for listing articles.
type ListFavoritesResponse ¶ added in v0.39.0
type ListFavoritesResponse struct {
Articles Articles `json:"articles,omitempty"`
Subscriptions Subscriptions `json:"subscriptions,omitempty"`
}
ListFavoritesResponse contains the data for displaying the favorites page.
type ListFilters ¶
type ListFilters struct {
// Categories is a list of categories.
Categories []Category `form:"categories" json:"categories" validate:"omitnil,unique,dive,url_encoded"`
// Count is the count of items to retrieve with a request.
Count Count `form:"count" json:"count" validate:"gt=0,lt=20"`
// OnlyFavorites indicates whether to filter by favorites only.
OnlyFavorites bool `form:"only_favorites" json:"only_favorites" validate:"omitempty,boolean"`
// Sort is how a list of objects is sorted.
Sort Sort `form:"sort" json:"sort" validate:"required,oneof=newest_first oldest_first most_unread least_unread most_relevant"`
// Subscriptions is a list of subscription IDs.
Subscriptions []SubscriptionID `form:"subscriptions" json:"subscriptions" validate:"omitnil,dive,startswith=sub_"`
// View The state of objects to view.
View View `form:"view" json:"view" validate:"required,oneof=read unread all"`
}
ListFilters contains filters for altering the display of objects.
func NewListDisplayFilters ¶
func NewListDisplayFilters() ListFilters
NewListDisplayFilters creates a new set of display filters with sensible defaults.
func (*ListFilters) GetCategories ¶
func (f *ListFilters) GetCategories() Categories
GetCategories returns any category filters.
func (*ListFilters) GetCount ¶
func (f *ListFilters) GetCount() int
GetCount returns the count value (encoded as a string in the filters) as an int.
func (*ListFilters) GetSort ¶
func (f *ListFilters) GetSort() Sort
GetSort returns the Sort object for the Filters.
func (*ListFilters) GetSubscriptions ¶
func (f *ListFilters) GetSubscriptions() []SubscriptionID
GetSubscriptions retrieves any subscription filters.
func (*ListFilters) QueryParams ¶
func (f *ListFilters) QueryParams() url.Values
QueryParams converts the filters into query parameters.
func (*ListFilters) QueryString ¶
func (f *ListFilters) QueryString() string
QueryString converts the filters into a string that can be appended to a URL to represent the filters.
func (*ListFilters) Sanitise ¶
func (f *ListFilters) Sanitise() error
Sanitise performs sanitisation of the filter values to ensure correctness.
func (*ListFilters) Valid ¶
func (f *ListFilters) Valid() error
Valid will return a boolean indicating whether the filters are valid and a non-nil error with details if not.
func (*ListFilters) Values ¶
func (f *ListFilters) Values() map[string]any
Values converts the filters into a map[string]string object, that can be further manipulated before being (most likely) used as the value of hx-vals in a HTMX request.
type ListRequest ¶
type ListRequest struct {
// Filters contains filters for altering the display of objects.
Filters ListFilters `json:"filters" validate:"required"`
// Pagination contains data for paginating through results.
Pagination *Pagination `form:"pagination" json:"pagination,omitempty" validate:"omitempty,url_encoded"`
// Query is an additional query to apply for this request.
Query query.Option `json:"query,omitempty"`
}
ListRequest contains the parameters needed for listing subscriptions or articles.
func (*ListRequest) Valid ¶
func (r *ListRequest) Valid() error
Valid will return an error if the request object does not pass validation.
type ListSubscriptionCategoriesRequest ¶ added in v0.27.0
type ListSubscriptionCategoriesRequest struct {
// Subscriptions is a list of subscription IDs.
Subscriptions []SubscriptionID `form:"displayed_subscriptions" json:"subscriptions,omitempty" validate:"omitempty,dive,startswith=sub_"`
}
ListSubscriptionCategoriesRequest contains data for listing categories for a list of subscriptions.
func (*ListSubscriptionCategoriesRequest) Sanitise ¶ added in v0.27.0
func (r *ListSubscriptionCategoriesRequest) Sanitise() error
func (*ListSubscriptionCategoriesRequest) Valid ¶ added in v0.27.0
func (r *ListSubscriptionCategoriesRequest) Valid() error
type ListSubscriptionsResponse ¶
type ListSubscriptionsResponse struct {
// Filters contains filters for altering the display of objects.
Filters ListFilters `json:"filters" validate:"required"`
// LatestArticles is a map of the latest articles for each subscription in the result.
LatestArticles *sync.Map `json:"latest_articles,omitempty"`
// Pagination contains data for paginating through results.
Pagination Pagination `form:"pagination" json:"pagination" validate:"omitempty,url_encoded"`
// Subscriptions is the list of subscriptions.
Subscriptions Subscriptions `json:"subscriptions"`
}
ListSubscriptionsResponse contains the data retrieved and relevant for listing subscriptions.
type MarkArticleRequest ¶ added in v0.28.0
type MarkArticleRequest struct {
// ItemID is the unique ID of an item.
ItemID ItemID `form:"item_id" json:"item_id" validate:"required,startswith=item_"`
// Mark applies the given mark action to objects.
Mark Mark `form:"mark" json:"mark" validate:"oneof=read unread"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
}
MarkArticleRequest contains parameters for marking an article.
func (*MarkArticleRequest) Sanitise ¶ added in v0.28.0
func (r *MarkArticleRequest) Sanitise() error
func (*MarkArticleRequest) Valid ¶ added in v0.28.0
func (r *MarkArticleRequest) Valid() error
type MarkArticlesRequest ¶
type MarkArticlesRequest struct {
// DisplayedArticles is a map of item ids per subscription.
DisplayedArticles map[SubscriptionID][]ItemID `form:"displayed_articles" json:"displayed_articles"`
// Mark applies the given mark action to objects.
Mark Mark `form:"mark" json:"mark" validate:"oneof=read unread"`
}
MarkArticlesRequest contains the parameters for marking articles.
func (*MarkArticlesRequest) Sanitise ¶
func (r *MarkArticlesRequest) Sanitise() error
Sanitise will alter MarkArticlesRequest data to ensure safety, where needed.
func (*MarkArticlesRequest) Valid ¶
func (r *MarkArticlesRequest) Valid() error
Valid ensures that the MarkArticlesRequest contains valid data.
type MarkObjectParams ¶
type MarkObjectParams struct {
// ObjectID represents an ID of any user-facing object.
ObjectID ObjectID `form:"id" json:"id" validate:"required,startswith=sub_|startswith=item_"`
// Mark applies the given mark action to objects.
Mark Mark `form:"mark" json:"mark" validate:"oneof=read unread"`
// Object represents the type of any user-facing object.
Object ObjectType `form:"object" json:"object" validate:"required,oneof=subscription article"`
}
MarkObjectParams defines model for MarkObjectParams.
func (*MarkObjectParams) Sanitise ¶
func (m *MarkObjectParams) Sanitise() error
func (*MarkObjectParams) Valid ¶
func (m *MarkObjectParams) Valid() error
type MarkSubscriptionRequest ¶ added in v0.31.0
type MarkSubscriptionRequest struct {
// Mark applies the given mark action to objects.
Mark Mark `form:"mark" json:"mark" validate:"oneof=read unread"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
}
MarkSubscriptionRequest contains the parameters for marking a subscription.
func (*MarkSubscriptionRequest) Sanitise ¶ added in v0.31.0
func (s *MarkSubscriptionRequest) Sanitise() error
Sanitise will sanitise the MarkSubscriptionRequest, ensuring it contains valid field values.
func (*MarkSubscriptionRequest) Valid ¶ added in v0.31.0
func (s *MarkSubscriptionRequest) Valid() error
Valid checks that the MarkSubscriptionRequest contains valid data.
type MarkSubscriptionsRequest ¶
type MarkSubscriptionsRequest struct {
// Mark applies the given mark action to objects.
Mark Mark `form:"mark" json:"mark" validate:"oneof=read unread"`
// Subscriptions is a list of subscription IDs.
Subscriptions []SubscriptionID `form:"displayed_subscriptions" json:"subscriptions" validate:"omitempty,dive,startswith=sub_"`
// View The state of objects to view.
View View `form:"view" json:"view" validate:"required,oneof=read unread all"`
}
MarkSubscriptionsRequest contains the parameters for marking a list of subscriptions.
func (*MarkSubscriptionsRequest) Sanitise ¶
func (s *MarkSubscriptionsRequest) Sanitise() error
Sanitise will sanitise the MarkSubscriptionsRequest, ensuring it contains valid field values.
func (*MarkSubscriptionsRequest) Valid ¶
func (s *MarkSubscriptionsRequest) Valid() error
Valid checks that the MarkSubscriptionsRequest contains valid data.
type MarkdownFile ¶ added in v0.49.0
type MarkdownFile struct {
Content []byte `json:"content"`
// Details contains a mapping of a file in an embedded FS to the URL path it is served from.
Details FileDetails `json:"details"`
// Frontmatter contains metadata about a markdown file that allows mapping it to a path under a documentation directory.
Frontmatter MarkdownFrontMatter `json:"frontmatter" toml:"doc_metadata"`
// JsonLD is the JSON-LD format for the file.
JsonLD *json.RawMessage `json:"jsonLD,omitempty"`
}
MarkdownFile contains the raw markdown file data and its frontmatter.
type MarkdownFrontMatter ¶ added in v0.49.0
type MarkdownFrontMatter struct {
// Author the person who wrote or is responsible for the document.
Author *string `json:"author,omitempty" toml:"author"`
// CreatedAt is when the post was created.
CreatedAt string `json:"created_at" toml:"created_at" validate:"required,datetime=2006-01-02"`
// Description is a description of the document, used in metadata headers of the page.
Description string `json:"description" toml:"description" validate:"required"`
// Image is a URL to an image to represent the file.
Image *string `json:"image,omitempty" toml:"image" validate:"omitempty,url"`
// PageTitle is the title rendered in the page header (i.e., <title/>).
PageTitle string `json:"page_title" toml:"page_title" validate:"required"`
// Title is the in-page title of the document.
Title string `json:"title" toml:"title" validate:"required"`
// UpdatedAt is when the post was updated.
UpdatedAt *string `json:"updated_at,omitempty" toml:"updated_at" validate:"omitempty,datetime=2006-01-02"`
}
MarkdownFrontMatter contains metadata about a markdown file that allows mapping it to a path under a documentation directory.
type OPMLFile ¶
type OPMLFile struct {
*FileUpload
}
OPMLFile is an opml file used for importing/exporting subscriptions.
func (*OPMLFile) GenerateRequests ¶
func (f *OPMLFile) GenerateRequests() ([]FeedSubscriptionRequest, error)
GenerateRequests extracts the feed outlines from the OPML file and returns a slice of subscription requests.
type ObjectCommon ¶
type ObjectCommon struct {
// Authors is a list of people (names, nicknames and/or emails) who "authored" the object content.
Authors []string `json:"authors,omitempty"`
// Categories is a list of categories that define a taxonomy for the feed or item.
Categories []Category `json:"categories,omitempty" validate:"omitempty,unique"`
// Contributors is a list of people (names, nicknames and/or emails) who "contributed" the object content.
Contributors []string `json:"contributors,omitempty"`
Copyright *string `json:"copyright,omitempty"`
// Description is a short summary or description of the feed or item.
Description *string `json:"description,omitempty"`
// Image contains details about a remote image.
Image *RemoteImage `json:"image,omitempty"`
Language *string `json:"language,omitempty"`
// Published is the datetime at which the feed or item was published.
Published time.Time `json:"published"`
// SourceType indicates what type of source the object came from.
SourceType SourceType `json:"source_type"`
// Title is the title of the feed or item.
Title string `json:"title"`
// Updated is the datetime at which the feed or item was updated.
Updated *time.Time `json:"updated,omitempty"`
// URL is the URL to the webpage for the feed or item. For a feed, this is most likely the webpage the feed is sourced from. For an item, this is most likely the webpage containing the full item contents.
URL string `json:"url,omitempty" validate:"omitempty,url"`
}
ObjectCommon contains common fields across objects.
type ObjectParams ¶
type ObjectParams struct {
// ObjectID represents an ID of any user-facing object.
ObjectID ObjectID `form:"id" json:"id" validate:"required,startswith=sub_|startswith=item_"`
// Object represents the type of any user-facing object.
Object ObjectType `form:"object" json:"object" validate:"required,oneof=subscription article"`
}
ObjectParams contains the parameters for viewing an object.
func (*ObjectParams) Sanitise ¶
func (p *ObjectParams) Sanitise() error
func (*ObjectParams) Valid ¶
func (p *ObjectParams) Valid() error
type ObjectType ¶
type ObjectType string
ObjectType represents the type of any user-facing object.
const ( ObjectTypeArticle ObjectType = "article" ObjectTypeSubscription ObjectType = "subscription" )
Defines values for ObjectType.
func (ObjectType) Valid ¶ added in v0.79.0
func (e ObjectType) Valid() bool
Valid indicates whether the value is a known member of the ObjectType enum.
type RemoteImage ¶ added in v0.79.0
type RemoteImage struct {
// Title the description of the image
Title *string `json:"title,omitempty"`
// URL is a URL.
URL *URL `form:"url" json:"url" validate:"omitempty,url"`
}
RemoteImage contains details about a remote image.
func ExtractImageFromContent ¶ added in v0.28.0
func ExtractImageFromContent(content string) (*RemoteImage, error)
func NewRemoteImage ¶ added in v0.79.0
func NewRemoteImage(url, title string) *RemoteImage
NewRemoteImage creates a new RemoteImage object.
func (*RemoteImage) GetTitle ¶ added in v0.79.0
func (i *RemoteImage) GetTitle() string
GetTitle returns the title (i.e., alt text) of the image, if any.
func (*RemoteImage) GetURL ¶ added in v0.79.0
func (i *RemoteImage) GetURL() string
GetURL returns the URL to the image.
func (*RemoteImage) String ¶ added in v0.82.0
func (i *RemoteImage) String() string
type RemoveSubscriptionRequest ¶
type RemoveSubscriptionRequest struct {
Nickname string `form:"nickname" json:"nickname" validate:"required"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
}
RemoveSubscriptionRequest contains the parameters for removing a subscription.
func (*RemoveSubscriptionRequest) Valid ¶
func (r *RemoveSubscriptionRequest) Valid() error
Valid checks that the RemoveSubscriptionRequest contains valid data.
type ReportIssueRequest ¶
type ReportIssueRequest struct {
// Details is the user-submitted text about the issue.
Details *string `form:"details" json:"details,omitempty"`
// PageUrl is the URL of the page on which the user selected the report issue action.
PageUrl string `form:"page_url" json:"page_url" validate:"required,url"`
// ScreenshotURL is a URL to a screenshot the user has uploaded that is related to or showing the problem.
ScreenshotURL *string `form:"-" json:"screenshot_url,omitempty" validate:"omitempty,url"`
// UserEmail is the email address the user has entered for getting in touch about the issue.
UserEmail string `form:"user_email" json:"user_email" validate:"required,email"`
}
ReportIssueRequest contains details about an issue with the service.
func (*ReportIssueRequest) Sanitise ¶
func (i *ReportIssueRequest) Sanitise() error
func (*ReportIssueRequest) Valid ¶
func (i *ReportIssueRequest) Valid() error
type ReportObjectIssueRequest ¶
type ReportObjectIssueRequest struct {
// Details is the user-submitted text about the issue.
Details *string `form:"details" json:"details,omitempty"`
// Duplicate indicates that the object has a duplicate.
Duplicate bool `form:"duplicate" json:"duplicate"`
// ObjectID represents an ID of any user-facing object.
ObjectID ObjectID `form:"id" json:"id" validate:"required,startswith=sub_|startswith=item_"`
// MangledContent indicates that the text content of the object is mangled/malformed or otherwise incorrect in some way.
MangledContent bool `form:"mangled_content" json:"mangled_content"`
// MissingImage indicates the object is expected to have an image, but it is missing.
MissingImage bool `form:"missing_image" json:"missing_image"`
// Object represents the type of any user-facing object.
Object ObjectType `form:"object" json:"object" validate:"required,oneof=subscription article"`
// PageUrl is the URL of the page on which the user selected the report issue action.
PageUrl string `form:"page_url" json:"page_url" validate:"required,url"`
// ScreenshotURL is a URL to a screenshot the user has uploaded that is related to or showing the problem.
ScreenshotURL *string `form:"-" json:"screenshot_url,omitempty" validate:"omitempty,url"`
// UserEmail is the email address the user has entered for getting in touch about the issue.
UserEmail string `form:"user_email" json:"user_email" validate:"required,email"`
}
ReportObjectIssueRequest defines model for ReportObjectIssueRequest.
func NewObjectIssue ¶
func NewObjectIssue(obj *ObjectParams, email, url string) *ReportObjectIssueRequest
func (*ReportObjectIssueRequest) Sanitise ¶
func (i *ReportObjectIssueRequest) Sanitise() error
func (*ReportObjectIssueRequest) Valid ¶
func (i *ReportObjectIssueRequest) Valid() error
type SearchRequest ¶
type SearchRequest struct {
// Authors a list of search terms for authors.
Authors *string `form:"authors" json:"authors,omitempty"`
// Categories a list of search terms for categories.
Categories *string `form:"categories" json:"categories,omitempty"`
// PublishedWithin represents a time range within which the objects should be published
PublishedWithin SearchRequestPublishedWithin `` /* 135-byte string literal not displayed */
// Sort is how a list of objects is sorted.
Sort Sort `form:"sort" json:"sort" validate:"required,oneof=newest_first oldest_first most_unread least_unread most_relevant"`
// SubscriptionID will be a subscription ID if the user has created a SearchSubscription for this request.
SubscriptionID *SubscriptionID `form:"subscription_id" json:"subscription_id,omitempty" validate:"omitzero,startswith=sub_"`
// Subscriptions is a list of subscription IDs.
Subscriptions []SubscriptionID `form:"subscriptions" json:"subscriptions,omitempty" validate:"omitempty,unique,dive,startswith=sub_"`
// Text is the text to search.
Text string `form:"text" json:"text" validate:"omitempty,required"`
// Timezone represents the timezone of the browser (i.e., user), used for calculating published_within offset.
Timezone string `form:"timezone" json:"timezone" validate:"required,timezone"`
// View The state of objects to view.
View View `form:"view" json:"view" validate:"required,oneof=read unread all"`
}
SearchRequest represents a search request by the user.
func NewSearchRequest ¶
func NewSearchRequest() *SearchRequest
NewSearchRequest creates a new SearchRequest object with default values. Defaults are search all objects within last week, sorted by most relevant.
func (*SearchRequest) HXVals ¶
func (r *SearchRequest) HXVals() string
HXVals returns a string that represents the search as hx-vals.
func (*SearchRequest) Query ¶
func (r *SearchRequest) Query() string
Query returns a string that represents the search as query parameters.
func (*SearchRequest) Sanitise ¶
func (r *SearchRequest) Sanitise() error
Sanitise will sanitise the search request data.
func (*SearchRequest) Valid ¶
func (r *SearchRequest) Valid() error
Valid returns a boolean indicating whether the search request data is valid.
func (*SearchRequest) Values ¶ added in v0.101.0
func (r *SearchRequest) Values() map[string]any
type SearchRequestPublishedWithin ¶
type SearchRequestPublishedWithin string
SearchRequestPublishedWithin represents a time range within which the objects should be published
const ( SearchRequestPublishedWithinAllTime SearchRequestPublishedWithin = "all_time" SearchRequestPublishedWithinLast12hours SearchRequestPublishedWithin = "last_12hours" SearchRequestPublishedWithinLast5mins SearchRequestPublishedWithin = "last_5mins" SearchRequestPublishedWithinLastDay SearchRequestPublishedWithin = "last_day" SearchRequestPublishedWithinLastHour SearchRequestPublishedWithin = "last_hour" SearchRequestPublishedWithinLastMonth SearchRequestPublishedWithin = "last_month" SearchRequestPublishedWithinLastWeek SearchRequestPublishedWithin = "last_week" )
Defines values for SearchRequestPublishedWithin.
func (SearchRequestPublishedWithin) Valid ¶ added in v0.79.0
func (e SearchRequestPublishedWithin) Valid() bool
Valid indicates whether the value is a known member of the SearchRequestPublishedWithin enum.
type SearchResults ¶ added in v0.28.1
type SearchResults struct {
Articles Articles `json:"articles,omitempty"`
// Categories is a list of categories.
Categories []Category `form:"categories" json:"categories" validate:"omitnil,unique,dive,url_encoded"`
// Pagination contains data for paginating through results.
Pagination *Pagination `form:"pagination" json:"pagination,omitempty" validate:"omitempty,url_encoded"`
// Search represents a search request by the user.
Search SearchRequest `form:"search" json:"search" validate:"required"`
Subscriptions Subscriptions `json:"subscriptions,omitempty"`
}
SearchResults contains the results of a search.
type SearchSubscription ¶
type SearchSubscription struct {
// Search represents a search request by the user.
Search SearchRequest `form:"search" json:"search" validate:"required"`
}
SearchSubscription is a custom subscription created from a search request.
func (*SearchSubscription) Valid ¶
func (s *SearchSubscription) Valid() error
Valid returns a boolean indicating if the Subscription contains valid data (true). If it contains invalid data (false) a non-nil error is also returned which contains validation issues.
type SearchSubscriptionRequest ¶
type SearchSubscriptionRequest struct {
// Customisation contains object fields that can be customised (overridden) by a user.
Customisation *SubscriptionCustomisation `form:"customisation" json:"customisation,omitempty"`
// Search represents a search request by the user.
Search SearchRequest `form:"search" json:"search" validate:"required"`
// Settings contains options that control how the subscription is stored/displayed.
Settings *SubscriptionSettings `form:"settings" json:"settings,omitempty"`
// SuggestedCategories is a list of suggested categories for the subscription.
SuggestedCategories []Category `form:"-" json:"-"`
}
SearchSubscriptionRequest represents a request to create a search subscription.
func NewSearchSubscriptionRequest ¶ added in v0.54.0
func NewSearchSubscriptionRequest( search SearchRequest, suggestedCategories []Category, ) *SearchSubscriptionRequest
func (*SearchSubscriptionRequest) Sanitise ¶
func (r *SearchSubscriptionRequest) Sanitise() error
func (*SearchSubscriptionRequest) Valid ¶
func (r *SearchSubscriptionRequest) Valid() error
type ShareArticleRequest ¶ added in v0.34.1
type ShareArticleRequest struct {
ItemID ItemID `form:"item_id" json:"item_id" validate:"required,startswith=item_"`
Link string `form:"link" json:"link" validate:"required,url"`
Title string `form:"title" json:"title" validate:"required"`
}
ShareArticleRequest contains parameters for sharing an article.
func (*ShareArticleRequest) Sanitise ¶ added in v0.34.1
func (r *ShareArticleRequest) Sanitise() error
func (*ShareArticleRequest) Valid ¶ added in v0.34.1
func (r *ShareArticleRequest) Valid() error
type Sort ¶
type Sort string
Sort is how a list of objects is sorted.
type SourceType ¶ added in v0.26.0
type SourceType string
SourceType indicates what type of source the object came from.
const ( SourceTypeAtom SourceType = "Atom" SourceTypeEmail SourceType = "Email" SourceTypeJSONFeed SourceType = "JSONFeed" SourceTypeRSS SourceType = "RSS" )
Defines values for SourceType.
func (SourceType) Valid ¶ added in v0.79.0
func (e SourceType) Valid() bool
Valid indicates whether the value is a known member of the SourceType enum.
type StoredImage ¶
StoredImage is an image stored locally (i.e., the binary data to represent the image).
type Subscription ¶
type Subscription struct {
// CreatedAt records when the object was created in the database.
CreatedAt CreatedAt `json:"created_at" validate:"required"`
// Customisation contains object fields that can be customised (overridden) by a user.
Customisation *SubscriptionCustomisation `form:"customisation" json:"customisation,omitempty"`
// EmailData is a subscription to an email newsletter source.
EmailData *EmailSubscription `json:"email_data,omitempty" validate:"omitempty"`
// Favorite indicates whether this subscription has been marked as a favorite by the user.
Favorite bool `json:"favorite"`
// FeedData represents a feed a user has subscribed to.
FeedData *FeedSubscription `json:"feed_data,omitempty" validate:"omitempty"`
// GroupData represents a subscription that combines other subscriptions.
GroupData *GroupSubscription `json:"group_data,omitempty" validate:"omitempty"`
// MarkedReadAt indicates when the subscription was last marked read. Any articles older than this timestamp are considered read, any newer unread.
MarkedReadAt *time.Time `json:"marked_read_at,omitempty"`
// SearchData is a custom subscription created from a search request.
SearchData *SearchSubscription `json:"search_data,omitempty" validate:"omitempty"`
// Settings contains options that control how the subscription is stored/displayed.
Settings SubscriptionSettings `form:"settings" json:"settings"`
// Stats contains stats about a subscription.
Stats *SubscriptionStats `json:"-" validate:"-"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
// Type is the type of subscription.
Type SubscriptionType `json:"type" validate:"required,oneof=feed search group email"`
// UpdatedAt records when the object was last updated in the database.
UpdatedAt *UpdatedAt `json:"updated_at,omitempty" validate:"omitnil"`
// UserID is the unique ID of a user.
UserID UserID `form:"user_id" json:"user_id" validate:"required,startswith=user_"`
}
Subscription defines model for Subscription.
func GetEmailSubscription ¶ added in v0.25.0
func GetEmailSubscription(ctx context.Context, userID UserID, from *mail.Address) (*Subscription, error)
GetEmailSubscription retrieves an EmailSubscription for the given user ID and email sender.
func GetSubscription ¶
func GetSubscription( ctx context.Context, id SubscriptionID, options ...subscriptionsRequestOption, ) (*Subscription, error)
GetSubscription returns the subscription that matches the given ID.
Accepts the GetSubscriptionsDynamicInfo request option to generate dynamic info (i.e. stats) for the subscription.
func GetSubscriptionByFeedID ¶
func GetSubscriptionByFeedID( ctx context.Context, id FeedID, options ...subscriptionsRequestOption, ) (*Subscription, error)
GetSubscriptionByFeedID returns the subscription that matches the given feed ID.
Accepts the GetSubscriptionsDynamicInfo request option to generate dynamic info (i.e. stats) for the subscription.
func NewEmailSubscription ¶ added in v0.25.0
func NewFeedSubscription ¶
func NewFeedSubscription( ctx context.Context, feed *Feed, customisation *SubscriptionCustomisation, ) (*Subscription, error)
NewFeedSubscription creates a new subscription for a feed with any user customisations given.
func NewGroupSubscription ¶
func NewGroupSubscription(ctx context.Context, request *GroupSubscriptionRequest) (*Subscription, error)
NewGroupSubscription creates a GroupSubscription. A GroupSubscription is a kind of meta-subscription that aggregates all articles from multiple individual subscriptions into a single custom subscription.
func NewSearchSubscription ¶
func NewSearchSubscription(ctx context.Context, request *SearchSubscriptionRequest) (*Subscription, error)
NewSearchSubscription creates a new SearchSubscription. A SearchSubscription collates articles that match a search into a single custom subscription.
func (*Subscription) GetArticleFilters ¶ added in v0.26.0
func (s *Subscription) GetArticleFilters() SubscriptionArticleFilters
func (*Subscription) GetCategories ¶
func (s *Subscription) GetCategories(maxCount int) Categories
GetCategories returns the categories of the subscription. It is the combined list of any user-assigned categories and the categories in the feed content.
func (*Subscription) GetFeedID ¶ added in v0.26.0
func (s *Subscription) GetFeedID() FeedID
GetFeedID returns the unqiue FeedID of the subscription. Not all subscription types will have a FeedID.
func (*Subscription) GetID ¶
func (s *Subscription) GetID() SubscriptionID
GetID returns the unqiue ID of the subscription.
func (*Subscription) GetImage ¶
func (s *Subscription) GetImage() URL
GetImage retrieves the image that represents the subscription, or nil if no image is available.
func (*Subscription) GetItemState ¶ added in v0.26.0
func (s *Subscription) GetItemState(itemID ItemID) *ArticleState
GetItemState retrieves the item state (read/unread/saved) from the subscription. By default it will return unread unless the user has explicitly marked or saved the item.
func (*Subscription) GetLink ¶
func (s *Subscription) GetLink() string
GetLink returns the source feed link. For a search subscription, there is no source so this returns an empty string.
func (*Subscription) GetMarkedReadAt ¶ added in v0.26.0
func (s *Subscription) GetMarkedReadAt() time.Time
func (*Subscription) GetReadItems ¶ added in v0.26.0
func (s *Subscription) GetReadItems() []ItemID
GetReadItems retrieves a list of ItemIDs for the feed subscription that user has explicitly marked as read.
func (*Subscription) GetStats ¶
func (s *Subscription) GetStats() *SubscriptionStats
GetStats returns the stats object containing the dynamically generated stats (i.e., unread count, article rate) of the subscription.
func (*Subscription) GetSubscriptionType ¶
func (s *Subscription) GetSubscriptionType() SubscriptionType
GetSubscriptionType returns the type of subscription (i.e., feed, search, group, etc.).
func (*Subscription) GetTitle ¶
func (s *Subscription) GetTitle() string
GetTitle returns the title (or user nickname if assigned) of the subscription.
func (*Subscription) GetUnreadItems ¶ added in v0.26.0
func (s *Subscription) GetUnreadItems() []ItemID
GetUnreadItems retrieves a list of ItemIDs for the feed subscription that user has explicitly marked as unread.
func (*Subscription) GetUpdatedDate ¶
func (s *Subscription) GetUpdatedDate() time.Time
GetUpdatedDate returns the timestamp that represents when the subscription was last updated. Usually, this means the timestamp of the newest article in the subscription.
func (*Subscription) IsFavorite ¶
func (s *Subscription) IsFavorite() bool
IsFavorite returns a boolean indicating whether the user has marked this subscription as a favorite. Note for some subscription types, this will always return true.
func (*Subscription) Mark ¶
func (s *Subscription) Mark(user *User, mark Mark)
Mark applies the given mark (read/unread) to a subscription.
func (*Subscription) MarkItems ¶
func (s *Subscription) MarkItems(mark Mark, itemIDs ...ItemID)
MarkItems marks the given items in a user subscription the given mark.
func (*Subscription) MarkItemsRead ¶
func (s *Subscription) MarkItemsRead(itemIDs ...ItemID)
MarkItemsRead will mark the given items as read for the subscription.
func (*Subscription) MarkItemsUnread ¶
func (s *Subscription) MarkItemsUnread(itemIDs ...ItemID)
MarkItemsUnread will mark the given items as unread for the subscription.
func (*Subscription) SetItemState ¶ added in v0.26.0
func (s *Subscription) SetItemState(itemID ItemID, state *ArticleState)
SetItemState will set the state of the item to the given state.
func (*Subscription) Valid ¶
func (s *Subscription) Valid() error
Valid returns a boolean indicating if the Subscription contains valid data (true). If it contains invalid data (false) a non-nil error is also returned which contains validation issues.
type SubscriptionArticleFilters ¶
type SubscriptionArticleFilters struct {
// Authors is the author filters to apply.
Authors *string `form:"authors" json:"authors,omitempty"`
// Categories is the category filters to apply.
Categories *string `form:"categories" json:"categories,omitempty"`
// Text is the filters on the title/content to apply.
Text *string `form:"text" json:"text,omitempty"`
}
SubscriptionArticleFilters holds filters to apply to the articles within a subscription.
func (*SubscriptionArticleFilters) Sanitise ¶ added in v0.82.4
func (f *SubscriptionArticleFilters) Sanitise() error
func (*SubscriptionArticleFilters) Valid ¶ added in v0.82.4
func (f *SubscriptionArticleFilters) Valid() error
type SubscriptionCustomisation ¶
type SubscriptionCustomisation struct {
// Categories is a custom list of categories for an object.
Categories []Category `form:"categories" json:"categories,omitempty" validate:"omitempty,unique"`
// ImageURL is a custom image to represent the object.
ImageURL *string `json:"image_url,omitempty" validate:"omitzero,url"`
// Nickname is an optional alias or label for an object.
Nickname *string `form:"nickname" json:"nickname,omitempty" validate:"omitempty"`
}
SubscriptionCustomisation contains object fields that can be customised (overridden) by a user.
func (*SubscriptionCustomisation) GetCategories ¶ added in v0.82.4
func (c *SubscriptionCustomisation) GetCategories() Categories
func (*SubscriptionCustomisation) GetImageURL ¶ added in v0.82.4
func (c *SubscriptionCustomisation) GetImageURL() string
func (*SubscriptionCustomisation) GetNickname ¶ added in v0.82.4
func (c *SubscriptionCustomisation) GetNickname() string
func (*SubscriptionCustomisation) Sanitise ¶ added in v0.82.4
func (c *SubscriptionCustomisation) Sanitise() error
func (*SubscriptionCustomisation) Valid ¶ added in v0.82.4
func (c *SubscriptionCustomisation) Valid() error
type SubscriptionID ¶
type SubscriptionID = string
SubscriptionID is the unique ID of a subscription.
type SubscriptionMetadata ¶
type SubscriptionMetadata struct {
// CreatedAt records when the object was created in the database.
CreatedAt CreatedAt `json:"created_at" validate:"required"`
// Customisation contains object fields that can be customised (overridden) by a user.
Customisation *SubscriptionCustomisation `form:"customisation" json:"customisation,omitempty"`
// Favorite indicates whether this subscription has been marked as a favorite by the user.
Favorite bool `json:"favorite"`
// MarkedReadAt indicates when the subscription was last marked read. Any articles older than this timestamp are considered read, any newer unread.
MarkedReadAt *time.Time `json:"marked_read_at,omitempty"`
// Settings contains options that control how the subscription is stored/displayed.
Settings SubscriptionSettings `form:"settings" json:"settings"`
// SubscriptionID is the unique ID of a subscription.
SubscriptionID SubscriptionID `form:"subscription_id" json:"subscription_id" validate:"required,startswith=sub_"`
// Type is the type of subscription.
Type SubscriptionMetadataType `json:"type" validate:"required,oneof=feed search group email"`
// UpdatedAt records when the object was last updated in the database.
UpdatedAt *UpdatedAt `json:"updated_at,omitempty" validate:"omitnil"`
// UserID is the unique ID of a user.
UserID UserID `form:"user_id" json:"user_id" validate:"required,startswith=user_"`
}
SubscriptionMetadata contains common fields across all subscription types.
type SubscriptionMetadataType ¶
type SubscriptionMetadataType string
SubscriptionMetadataType is the type of subscription.
const ( SubscriptionMetadataTypeEmail SubscriptionMetadataType = "email" SubscriptionMetadataTypeFeed SubscriptionMetadataType = "feed" SubscriptionMetadataTypeGroup SubscriptionMetadataType = "group" SubscriptionMetadataTypeSearch SubscriptionMetadataType = "search" )
Defines values for SubscriptionMetadataType.
func (SubscriptionMetadataType) Valid ¶ added in v0.79.0
func (e SubscriptionMetadataType) Valid() bool
Valid indicates whether the value is a known member of the SubscriptionMetadataType enum.
type SubscriptionSettings ¶
type SubscriptionSettings struct {
// ShowFullArticleContent toggles whether articles in the subscription should be always displayed with remote content.
ShowFullArticleContent bool `form:"show_full_article_content" json:"show_full_article_content"`
}
SubscriptionSettings contains options that control how the subscription is stored/displayed.
type SubscriptionSorting ¶
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 ¶
func (s *SubscriptionSorting) SortCombinationsCaster() *estypes.SortCombinations
SortCombinationsCaster is required to allow FeedSorting to be used as Elasticsearch sort values.
type SubscriptionStats ¶
type SubscriptionStats struct {
// AvgDailyUpdates is the avergage number of articles published per day.
AvgDailyUpdates float64 `json:"-" validate:"gte=0"`
// LastUpdate is the timestamp of the most newest item that matches the search.
LastUpdate time.Time `json:"-" validate:"required"`
// UnreadCount is the value of items that are not explicitly marked unread by the user for this subscription.
UnreadCount int `json:"-" validate:"gte=0"`
}
SubscriptionStats contains stats about a subscription.
func (*SubscriptionStats) IsUnread ¶
func (s *SubscriptionStats) IsUnread() bool
IsUnread returns a boolean indicating whether the subscription is considered unread.
func (*SubscriptionStats) UnreadTotal ¶
func (s *SubscriptionStats) UnreadTotal() int
UnreadTotal returns the unread count of items in the subscription.
func (*SubscriptionStats) UpdateFrequency ¶
func (s *SubscriptionStats) UpdateFrequency() string
UpdateFrequency returns a string that roughly indicates how often the subscription is updated.
type SubscriptionType ¶
type SubscriptionType string
SubscriptionType is the type of subscription.
const ( SubscriptionTypeEmail SubscriptionType = "email" SubscriptionTypeFeed SubscriptionType = "feed" SubscriptionTypeGroup SubscriptionType = "group" SubscriptionTypeSearch SubscriptionType = "search" )
Defines values for SubscriptionType.
func (SubscriptionType) Valid ¶ added in v0.79.0
func (e SubscriptionType) Valid() bool
Valid indicates whether the value is a known member of the SubscriptionType enum.
type Subscriptions ¶
type Subscriptions []*Subscription
Subscriptions is a slice of subscriptions of any type.
func GetSubscriptionSuggestions ¶
func GetSubscriptionSuggestions( ctx context.Context, text string, count int, options ...subscriptionsRequestOption, ) (Subscriptions, error)
GetSubscriptionSuggestions returns subscriptions that match the given text.
Accepts the GetSubscriptionsDynamicInfo request option to generate dynamic info (i.e. stats) for the subscription suggestions.
func GetSubscriptions ¶
func GetSubscriptions( ctx context.Context, options ...subscriptionsRequestOption, ) (Subscriptions, error)
GetSubscriptions performs a search request to fetch subscriptions. Accepts all request options to filter/enrich the results.
func GetSubscriptionsForItems ¶ added in v0.26.0
func GetSubscriptionsForItems(ctx context.Context, items Items) (Subscriptions, error)
GetSubscriptionsForItems returns the subscriptions that the list of items belong to.
func SubscriptionsFromCtx ¶
func SubscriptionsFromCtx(ctx context.Context) Subscriptions
SubscriptionsFromCtx retrieves the slice of Subscriptions from the context. If no Subscriptions slice is in the context, it returns an empty slice.
func (Subscriptions) FilterByCategories ¶
func (s Subscriptions) FilterByCategories(categories ...Category) Subscriptions
FilterByCategories returns a new slice containing the subscriptions which have a category matching the given categories.
func (Subscriptions) FilterByFavorites ¶
func (s Subscriptions) FilterByFavorites(value bool) Subscriptions
FilterByFavorites returns a slice containing only favorite subscriptions.
func (Subscriptions) FilterByType ¶
func (s Subscriptions) FilterByType(t ...SubscriptionType) Subscriptions
FilterByType returns a slice containing subscriptions of the specified type.
func (Subscriptions) FilterByView ¶
func (s Subscriptions) FilterByView(view View) Subscriptions
FilterByView returns a slice containing the subscription which match the given view state.
func (Subscriptions) GetByFeedID ¶
func (s Subscriptions) GetByFeedID(id FeedID) *Subscription
GetByFeedID will return the subscription that matches the given feed ID, if any.
func (Subscriptions) GetCategories ¶ added in v0.54.0
func (s Subscriptions) GetCategories() Categories
GetCategories returns all categories across all the subscriptions. Duplicates are removed.
func (Subscriptions) GetFeedIDs ¶
func (s Subscriptions) GetFeedIDs() []FeedID
GetFeedIDs returns the IDs of feeds the subscriptions are for. This may return an empty slice if the subscriptions are only of type search, for example as those subscriptions do not represent any particular feed.
func (Subscriptions) GetIDs ¶
func (s Subscriptions) GetIDs() []SubscriptionID
GetIDs returns the subscription ids for all subscription states in the slice.
func (Subscriptions) Paginate ¶
func (s Subscriptions) Paginate(pagination Pagination, count int) (Subscriptions, Pagination)
Paginate will paginate through a slice of subscriptions, returning a new slice of subscriptions and the next pagination value (if any).
func (Subscriptions) Sort ¶
func (s Subscriptions) Sort(sort Sort) Subscriptions
Sort will sort the slice of subscriptions by the given sort option. Favorite subscriptions are always sorted before other subscriptions, and the sort option is used as a tiebreaker.
type User ¶
type User struct {
// AvatarURL is a link to an image file to user as an avatar for the user.
AvatarURL *string `form:"avatar_url" json:"avatar_url,omitempty" validate:"omitempty,url"`
// CreatedAt records when the object was created in the database.
CreatedAt CreatedAt `json:"created_at" validate:"required"`
// Email is the email address of the user.
Email string `form:"email" json:"email" validate:"required,email"`
// ExternalUserID is the ID of the user on the external backend that was used to create the account.
ExternalUserID string `json:"external_user_id" validate:"required"`
// ItemFavorites is the IDs of items (articles) the user has favorited.
ItemFavorites []ItemID `json:"item_favorites,omitempty" validate:"omitempty,dive,startswith=item_"`
// LastLogin is the timestamp of when the user last logged in to the app.
LastLogin time.Time `json:"last_login"`
// LoginCount is the total number of logins of the user.
LoginCount int `json:"login_count"`
// Metadata contains metadata related to the user's account.
Metadata UserMetadata `json:"metadata"`
// Nickname is a nickname for the user.
Nickname string `form:"nickname" json:"nickname" validate:"required"`
// PromotionalEmail is a flag indicating whether the user is accepting promotional (non-account/administrative) emails.
PromotionalEmail bool `form:"promotional_email" json:"promotional_email" validate:"required"`
// Provider is the backend provider that was used to create the account.
Provider string `json:"provider" validate:"required"`
// Settings contains user-specific settings for the application.
Settings UserSettings `json:"settings"`
// Subscription contains details about the user's paid subscription.
Subscription *UserSubscription `json:"subscription,omitempty"`
// UpdatedAt records when the object was last updated in the database.
UpdatedAt *UpdatedAt `json:"updated_at,omitempty" validate:"omitnil"`
// UserID is the unique ID of a user.
UserID UserID `form:"user_id" json:"user_id" validate:"required,startswith=user_"`
}
User defines model for User.
func GetUserByEmail ¶ added in v0.87.0
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 ¶ added in v0.25.0
GetUserBySubscriptionEmail will retrieve a user from their Foragd newsletter subscription email.
func UserFromCtx ¶
UserFromCtx retrieves a user from the context, if any.
func (*User) Active ¶
Active returns a boolean indicating whether the user is "active", which means a paying customer with no payment issues or customer currently on a trial.
func (*User) AddSubscriptions ¶ added in v0.110.0
func (u *User) AddSubscriptions(ctx context.Context, subscriptions ...*Subscription) error
AddSubscriptions adds the given subscriptions to a user.
func (*User) Cancelled ¶
Cancelled returns a boolean indicating whether the user has cancelled their subscription plan and if so, a timestamp indicating when the cancellation will apply.
func (*User) GetExternalID ¶
GetExternalID returns the backend ID for the user.
func (*User) GetMaxHistory ¶
GetMaxHistory returns a timestamp in the past from which the user can view items. If there is an issue retrieving and parsing the value from the user's metadata, it will default to using the lowest plan max history.
func (*User) GetNickname ¶
GetNickname retrieves the nickname of the user.
func (*User) GetSettings ¶
func (u *User) GetSettings() *UserSettings
GetSettings returns the user's settings. If the user has no settings (i.e. new user), default settings will be returned.
func (*User) GetSubscriptionPlan ¶
GetSubscriptionPlan returns the name of the subscription plan of the user.
func (*User) GetSubscriptions ¶ added in v0.110.0
func (u *User) GetSubscriptions(ctx context.Context, options ...GetSubscriptionOption) (Subscriptions, error)
func (*User) GetUpdatesFrequency ¶
GetUpdatesFrequency returns a duration on which the user will see new updates. If there is an issue retrieving and parsing the value from the user's metdata, it will use the lowest plan updates frequency.
type UserCustomisation ¶
type UserCustomisation struct {
// AvatarURL is a link to an image file to user as an avatar for the user.
AvatarURL *string `form:"avatar_url" json:"avatar_url,omitempty" validate:"omitempty,url"`
// Email is the email address of the user.
Email string `form:"email" json:"email" validate:"required,email"`
// Nickname is a nickname for the user.
Nickname string `form:"nickname" json:"nickname" validate:"required"`
// PromotionalEmail is a flag indicating whether the user is accepting promotional (non-account/administrative) emails.
PromotionalEmail bool `form:"promotional_email" json:"promotional_email" validate:"required"`
}
UserCustomisation contains account fields that a user can customize.
type UserMessage ¶
type UserMessage struct {
// Details is a longer description and/or background details about the message.
Details *string `json:"details,omitempty"`
// Status indicates the severity or importance of the message.
Status UserMessageStatus `json:"status" validate:"required"`
// Summary is a user-level brief description for the message, which can be used as a title or summary.
Summary string `json:"summary" validate:"required"`
}
UserMessage represents a message that can be displayed to the user as the result of an action.
func NewErrorMessage ¶
func NewErrorMessage(summary string, details string) *UserMessage
NewErrorMessage creates a new UserMessage indicating an error with the given summary and (optional) details.
func NewInfoMessage ¶
func NewInfoMessage(summary string, details string) *UserMessage
NewInfoMessage creates a new UserMessage indicating informational details with the given summary and (optional) details.
func NewSuccessMessage ¶
func NewSuccessMessage(summary string, details string) *UserMessage
NewSuccessMessage creates a new UserMessage indicating success with the given summary and (optional) details.
func NewWarningMessage ¶
func NewWarningMessage(summary string, details string) *UserMessage
NewWarningMessage creates a new UserMessage indicating a warning with the given summary and (optional) details.
func (*UserMessage) HasDetails ¶
func (msg *UserMessage) HasDetails() bool
HasDetails returns a boolean indicating whether the message has additional details.
func (*UserMessage) IsError ¶
func (msg *UserMessage) IsError() bool
IsError returns true when the message indicates an error.
func (*UserMessage) IsInfo ¶
func (msg *UserMessage) IsInfo() bool
IsInfo returns true when the message indicates informational status.
func (*UserMessage) IsSuccess ¶
func (msg *UserMessage) IsSuccess() bool
IsSuccess returns true when the message indicates success.
func (*UserMessage) IsWarning ¶
func (msg *UserMessage) IsWarning() bool
IsWarning returns true when the message indicates a warning.
func (*UserMessage) String ¶
func (msg *UserMessage) String() string
String returns the message as a formatted string. This allows Message to satisfy the Stringer interface.
type UserMessageStatus ¶
type UserMessageStatus string
UserMessageStatus indicates the severity or importance of the message.
const ( UserMessageStatusError UserMessageStatus = "error" UserMessageStatusInfo UserMessageStatus = "info" UserMessageStatusSuccess UserMessageStatus = "success" UserMessageStatusWarning UserMessageStatus = "warning" )
Defines values for UserMessageStatus.
func (UserMessageStatus) Valid ¶ added in v0.79.0
func (e UserMessageStatus) Valid() bool
Valid indicates whether the value is a known member of the UserMessageStatus enum.
type UserMetadata ¶
type UserMetadata struct {
// Blocked indicates whether the user is blocked from the app.
Blocked bool `json:"blocked"`
// EmailVerified indicates whether the user has verfied their email address.
EmailVerified bool `json:"email_verified" validate:"required"`
// PendingDeletion indicates whether the user account is pending deletion.
PendingDeletion *bool `json:"pending_deletion,omitempty,omitzero"`
// PoliciesAccepted indicates whether the user has accepted the app policies.
PoliciesAccepted bool `json:"policies_accepted" validate:"required"`
// PromotionalEmail is a flag indicating whether the user is accepting promotional (non-account/administrative) emails.
PromotionalEmail bool `json:"promotional_email" validate:"required"`
}
UserMetadata contains metadata related to the user's account.
func (*UserMetadata) Valid ¶
func (s *UserMetadata) Valid() error
Valid returns a boolean indicating if the UserSettings contains valid data (true). If it contains invalid data (false) a non-nil error is also returned which contains validation issues.
type UserSession ¶
type UserSession struct {
// Data the encoded session data.
Data []byte `json:"data"`
// Expiry the time at which this session token expires.
Expiry time.Time `json:"expiry"`
// Token the session token for the user.
Token string `json:"token"`
}
UserSession tracks a user session.
type UserSettings ¶
type UserSettings struct {
// MarkArticleReadOnView indicates whether to automatically mark an article as read when viewed.
MarkArticleReadOnView bool `form:"mark_article_read_on_view" json:"mark_article_read_on_view"`
// MaxViewHistory is a user-specified limit on how far back in time to view articles.
MaxViewHistory time.Duration `form:"max_view_history" json:"max_view_history" validate:"gte=0"`
// ShowOnboarding indicates whether to show onboarding information (i.e., for a new user).
ShowOnboarding bool `form:"-" json:"show_onboarding"`
// ShowSubscriptionStats indicates whether various subscription stats (e.g., unread counts, articles/day, etc.) should be shown.
ShowSubscriptionStats bool `form:"show_subscription_stats" json:"show_subscription_stats"`
// SubscriptionEmail is an email address the user can use to subscribe to email newsletters.
SubscriptionEmail *string `form:"subscription_email" json:"subscription_email,omitempty" validate:"omitempty,email"`
// UpdatesInterval is the interval on which to check for new updates.
UpdatesInterval time.Duration `form:"update_interval" json:"updates_interval" validate:"gte=0"`
}
UserSettings contains user-specific settings for the application.
func (*UserSettings) Sanitise ¶
func (s *UserSettings) Sanitise() error
Sanitise will sanitise UserSettings values.
func (*UserSettings) Valid ¶
func (s *UserSettings) Valid() error
Valid returns a boolean indicating if the UserSettings contains valid data (true). If it contains invalid data (false) a non-nil error is also returned which contains validation issues.
type UserSubscription ¶ added in v0.87.0
type UserSubscription struct {
// CancelAt is a date in the future at which the subscription will automatically get canceled.
CancelAt *time.Time `json:"cancel_at,omitempty"`
// Plan is the name of the subscription plan that the user is paying for.
// Possible values will come from the product defined in Stripe.
Plan *string `json:"plan,omitempty" validate:"required"`
// PlanID is the unique identifier for the plan.
// Possible values will come from the product defined in Stripe.
PlanID *string `json:"plan_id,omitempty" validate:"required"`
// PlanStatus is the name current status of the subscription plan.
// Possible values come directly from the Stripe API:
// https://docs.stripe.com/api/subscriptions/object?api-version=2025-11-17.preview#subscription_object-status
PlanStatus *stripe.SubscriptionStatus `json:"plan_status,omitempty" validate:"required"`
// StripeCustomerID is the stripe customer id of the user.
// https://docs.stripe.com/api/customers/object?api-version=2025-11-17.preview#customer_object-id
StripeCustomerID *string `json:"stripe_customer_id,omitempty" validate:"required"`
// StripeSubscriptionID is the stripe subscription id of the user's plan.
// https://docs.stripe.com/api/subscriptions/object?api-version=2025-11-17.preview#subscription_object-id
StripeSubscriptionID *string `json:"stripe_subscription_id,omitempty" validate:"required"`
// TrialEnd is the date when the trial for the subscription ended.
TrialEnd *time.Time `json:"trial_end,omitempty"`
}
UserSubscription contains details about the user's paid subscription.