Documentation
¶
Overview ¶
Package reading decides who may read what: a single post with its comments, a user's journal, the explore page, the feed and the RSS feeds built from them. Every visibility rule of pcom is applied here, on top of the pure checks in postops.
Index ¶
- Constants
- func CanSeeProfile(profile *core.User, visitor *core.User, connRadius graph.Radius) bool
- func CannotSeeProfileLite(profile *core.User, visitor *core.User) bool
- type Cursor
- type Feed
- type FeedItem
- type Journal
- type Option
- type Post
- type Posts
- type PrivateFeed
- type Service
- func (s *Service) Explore(ctx context.Context, actor *core.User, cursor string) (*Posts, error)
- func (s *Service) Feed(ctx context.Context, actor *core.User, cursor string) (*Feed, error)
- func (s *Service) Journal(ctx context.Context, actor *core.User, username, cursor string) (*Journal, error)
- func (s *Service) Post(ctx context.Context, actor *core.User, postID string, editPreview bool) (*Post, error)
- func (s *Service) PrivateFeed(ctx context.Context, token string) (*PrivateFeed, error)
- func (s *Service) PublicFeed(ctx context.Context, username string) (*Journal, error)
- func (s *Service) PublicPosts(ctx context.Context, cursor string) (*Posts, error)
- func (s *Service) PublicPostsRSS(ctx context.Context) ([]*postops.Post, error)
Constants ¶
const DefaultPageSize = 30
DefaultPageSize is how many items a page of a list holds (the feed, explore, the index page and a journal) unless WithLimits sets it.
const DefaultRSSLimit = 50
DefaultRSSLimit caps every RSS output, which isn't paged, unless WithLimits sets it.
Variables ¶
This section is empty.
Functions ¶
func CanSeeProfile ¶
Types ¶
type Cursor ¶
Cursor is where a page starts: right after the item with this sort time, kind and ID. Clients get it as an opaque string.
func ParseCursor ¶
ParseCursor decodes a cursor. An empty string is the first page, the zero Cursor; one that doesn't parse is service.Invalid.
type Feed ¶
type Feed struct {
Items []*FeedItem
Next string
DirectConnections []*core.User
OpenPrompts []*postops.PostPrompt
// FeedToken is the actor's private RSS feed token, nil when they have none.
FeedToken *core.UserFeedToken
}
Feed is a page of the actor's feed. Only the first page carries the connections, prompts and feed token. Next is the cursor of the next page, empty on the last one.
type FeedItem ¶
FeedItem is one entry of the feed: a post, an RSS item or a comment.
func (*FeedItem) AddedToFeedAt ¶
type Journal ¶
type Journal struct {
Author *core.User
ConnectionRadius graph.Radius
ConnectionAllowed bool
MediationRequest *core.UserConnectionMediationRequest
Posts []*postops.Post
About string // the author's "About" text, empty when there is none
// Next is the cursor of the next page of posts, empty on the last one.
Next string
}
Journal is a user's profile page as the actor may see it.
type Option ¶
type Option func(*Service)
Option changes how New builds the service.
func WithLimits ¶
WithLimits sets how many items a page of a list holds and how many an RSS output lists. A value that isn't positive keeps the default.
type Post ¶
Post is a post as the actor may see it: the comments and the share link are set only when the post's capabilities let the actor see them.
type PrivateFeed ¶
PrivateFeed is what a private RSS feed lists: the posts of its owner's feed.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Explore ¶
Explore lists the page after cursor (empty for the first) of the published public posts of the profiles the actor could open without a connection: public ones, and for a logged in actor those open to registered users. Nobody gets comments or actions there.
func (*Service) Feed ¶
Feed is the page after cursor (empty for the first) of what the actor reads at /feed, newest first: the published posts of their direct connections, the posts of second-degree connections shared that far, their RSS items and the comments on posts they take part in.
func (*Service) Journal ¶
func (s *Service) Journal(ctx context.Context, actor *core.User, username, cursor string) (*Journal, error)
Journal opens the profile of the user with that username for the actor, nil for an anonymous visitor: the page after cursor (empty for the first) of the published posts the actor may read, and how the actor could connect to the author. A profile the actor may not see is not found, so whether it exists isn't revealed.
func (*Service) Post ¶
func (s *Service) Post(ctx context.Context, actor *core.User, postID string, editPreview bool) (*Post, error)
Post opens a post for the actor, nil for an anonymous visitor. A post the actor may not see is not found, so its existence isn't revealed, except that an anonymous visitor is asked to log in. editPreview marks the page the author previews while editing.
func (*Service) PrivateFeed ¶
PrivateFeed resolves a private RSS feed token. Anybody who has the token may read the feed, so there is no actor. It lists the newest rss limit posts of the owner's feed.
func (*Service) PublicFeed ¶
PublicFeed is what the public RSS feed of the user with that username lists: the journal an anonymous visitor sees. Only a public profile has one. It lists the newest rss limit posts (WithLimits).
func (*Service) PublicPosts ¶
PublicPosts is the page after cursor (empty for the first) of the public feed (Q15): the published public posts by authors whose profile is public, newest publication first. A public post of a profile open to registered users or connections only stays readable at its own page but is not listed here. Posts are built for nobody: no actor, no comments, no actions.