Documentation
¶
Overview ¶
Package repo holds database queries.
Index ¶
- Constants
- Variables
- func FeedTokenForUser(ctx context.Context, exec boil.ContextExecutor, userID string) (*core.UserFeedToken, error)
- func FeedTokenOwner(ctx context.Context, exec boil.ContextExecutor, token string) (*core.User, error)
- func RegenerateFeedToken(ctx context.Context, exec boil.ContextExecutor, userID string) (*core.UserFeedToken, error)
- type Hop
- type LockScope
- type MailQueue
- type Page
- type PostsPage
- type Store
- func (s *Store) APIKeyForUser(ctx context.Context, userID string) (*core.UserAPIKey, error)
- func (s *Store) AddMediatorDecision(ctx context.Context, requestID, mediatorID string, ...) error
- func (s *Store) CommentByID(ctx context.Context, id string) (*core.PostComment, error)
- func (s *Store) CommentForMail(ctx context.Context, id string) (*core.PostComment, error)
- func (s *Store) CommentInPost(ctx context.Context, commentID, postID string) (*core.PostComment, error)
- func (s *Store) CommentParticipants(ctx context.Context, postID, authorID string) ([]*core.PostComment, error)
- func (s *Store) CommentedPostIDs(ctx context.Context, userID string) ([]string, error)
- func (s *Store) CommentsOfPost(ctx context.Context, postID string) (core.PostCommentSlice, error)
- func (s *Store) CommentsOnPostsNotBy(ctx context.Context, postIDs []string, userID string, page Page) (core.PostCommentSlice, error)
- func (s *Store) Connected(ctx context.Context, userID, otherID string) (bool, error)
- func (s *Store) ConnectedThroughOne(ctx context.Context, userID, otherID string) (bool, error)
- func (s *Store) ConnectedUserIDs(ctx context.Context, userID string) ([]string, error)
- func (s *Store) CountNewComment(ctx context.Context, postID string) error
- func (s *Store) CreateAPIKey(ctx context.Context, userID string) error
- func (s *Store) CreateConnection(ctx context.Context, user1ID, user2ID string) (*core.UserConnection, *core.UserConnection, error)
- func (s *Store) CreateGrant(ctx context.Context, whoID, allowsWhoID string) error
- func (s *Store) CreateMediaUpload(ctx context.Context, upload *core.MediaUpload) error
- func (s *Store) CreateMediationRequest(ctx context.Context, whoID, targetID, note string) error
- func (s *Store) CreateOrUpdateOutgoingEmail(ctx context.Context, email *core.OutgoingEmail) error
- func (s *Store) CreateShare(ctx context.Context, postID string) error
- func (s *Store) DeleteConnectionsBetween(ctx context.Context, userID, otherID string) error
- func (s *Store) DeleteLoginAttemptsExpiredBefore(ctx context.Context, t time.Time) (int64, error)
- func (s *Store) DeleteMediationRequestBetween(ctx context.Context, whoID, targetID string) error
- func (s *Store) DeleteOpenGrant(ctx context.Context, whoID, allowsWhoID string) error
- func (s *Store) DeletePost(ctx context.Context, postID string) error
- func (s *Store) DeleteProfileAbout(ctx context.Context, userID string) error
- func (s *Store) DeleteShares(ctx context.Context, postID string) error
- func (s *Store) DeleteSubscription(ctx context.Context, userID, subscriptionID string) error
- func (s *Store) DeleteUnconfirmedUser(ctx context.Context, id string) (bool, error)
- func (s *Store) DismissFeedItem(ctx context.Context, item *core.UserFeedItem) error
- func (s *Store) DismissPrompt(ctx context.Context, recipientID, id string, at time.Time) error
- func (s *Store) DraftPosts(ctx context.Context, userID string) ([]*core.Post, error)
- func (s *Store) Exec() boil.ContextExecutor
- func (s *Store) FeedItemCount(ctx context.Context, feedID string) (int64, error)
- func (s *Store) FeedItemExists(ctx context.Context, feedID, urlID string) (bool, error)
- func (s *Store) FeedSubscriptions(ctx context.Context, feedID string) (core.UserFeedSubscriptionSlice, error)
- func (s *Store) FeedTokenForUser(ctx context.Context, userID string) (*core.UserFeedToken, error)
- func (s *Store) FeedTokenOwner(ctx context.Context, token string) (*core.User, error)
- func (s *Store) FeedsToRefresh(ctx context.Context) ([]*core.RSSFeed, error)
- func (s *Store) GetPendingEmails(ctx context.Context) ([]*core.OutgoingEmail, error)
- func (s *Store) GrantExists(ctx context.Context, whoID, allowsWhoID string) (bool, error)
- func (s *Store) InsertComment(ctx context.Context, comment *core.PostComment) error
- func (s *Store) InsertInvitation(ctx context.Context, inv *core.UserInvitation) error
- func (s *Store) InsertLoginAttempt(ctx context.Context, a *core.LoginAttempt) error
- func (s *Store) InsertPost(ctx context.Context, post *core.Post) error
- func (s *Store) InsertPrompt(ctx context.Context, prompt *core.PostPrompt) error
- func (s *Store) InsertSignupRequest(ctx context.Context, r *core.UserSignupRequest) error
- func (s *Store) InsertUser(ctx context.Context, u *core.User) error
- func (s *Store) InsertUserFeedItem(ctx context.Context, userID, rssItemID, urlID string) error
- func (s *Store) InvitationCount(ctx context.Context, userID string) (int64, error)
- func (s *Store) InvitationSentTo(ctx context.Context, email string) (bool, error)
- func (s *Store) LastImportedAt(ctx context.Context, feedIDs []string) (map[string]time.Time, error)
- func (s *Store) LastPromptBy(ctx context.Context, askerID string) (*core.PostPrompt, error)
- func (s *Store) LockFeed(ctx context.Context, feedID string) (*core.RSSFeed, error)
- func (s *Store) LockLoginAttempt(ctx context.Context, id string) (*core.LoginAttempt, error)
- func (s *Store) LockMailbox(ctx context.Context, scope LockScope, canonical string) error
- func (s *Store) LockOpenGrant(ctx context.Context, whoID, allowsWhoID string) (*core.WhitelistedConnection, error)
- func (s *Store) LockUndecidedRequest(ctx context.Context, requestID, targetID string) (*core.UserConnectionMediationRequest, error)
- func (s *Store) LockUnusedInvitation(ctx context.Context, userID string) (*core.UserInvitation, error)
- func (s *Store) LockUser(ctx context.Context, scope LockScope, userID string) error
- func (s *Store) LoginCodesSince(ctx context.Context, userID string, since time.Time) (int64, error)
- func (s *Store) MailboxHasAccount(ctx context.Context, canonical string) (bool, error)
- func (s *Store) MediationRequestBetween(ctx context.Context, whoID, targetID string) (*core.UserConnectionMediationRequest, error)
- func (s *Store) MediationRequestExists(ctx context.Context, whoID, targetID string) (bool, error)
- func (s *Store) OpenGrantExists(ctx context.Context, whoID, allowsWhoID string) (bool, error)
- func (s *Store) OpenInvitationByID(ctx context.Context, id string) (*core.UserInvitation, error)
- func (s *Store) OpenPromptsFor(ctx context.Context, recipientID string) (core.PostPromptSlice, error)
- func (s *Store) OwnPost(ctx context.Context, postID, authorID string) (*core.Post, error)
- func (s *Store) OwnPostForUpdate(ctx context.Context, postID, authorID string, draftOnly bool) (*core.Post, error)
- func (s *Store) OwnPostsByIDs(ctx context.Context, authorID string, ids []string) ([]*core.Post, error)
- func (s *Store) PendingInvitationExists(ctx context.Context, email string) (bool, error)
- func (s *Store) PostByID(ctx context.Context, id string) (*core.Post, error)
- func (s *Store) PostForEdit(ctx context.Context, id string) (*core.Post, error)
- func (s *Store) PostToRead(ctx context.Context, id string) (*core.Post, error)
- func (s *Store) PostWithAuthorAndURL(ctx context.Context, id string) (*core.Post, error)
- func (s *Store) PostsByAuthor(ctx context.Context, page PostsPage) ([]*core.Post, error)
- func (s *Store) PostsForExport(ctx context.Context, authorID, postID string) ([]*core.Post, error)
- func (s *Store) PostsOfOrAmong(ctx context.Context, userID string, authorIDs, postIDs []string) (core.PostSlice, error)
- func (s *Store) ProfileAbout(ctx context.Context, userID string) (string, error)
- func (s *Store) PromptForPost(ctx context.Context, postID string) (*core.PostPrompt, error)
- func (s *Store) PromptForRecipient(ctx context.Context, recipientID, id string) (*core.PostPrompt, error)
- func (s *Store) PublishedPostsByProfile(ctx context.Context, visibility core.PostVisibility, ...) (core.PostSlice, error)
- func (s *Store) PublishedPostsOf(ctx context.Context, authorID string, visibilities []core.PostVisibility, ...) (core.PostSlice, error)
- func (s *Store) PublishedPostsOfUsers(ctx context.Context, allOf, someOf []string, ...) (core.PostSlice, error)
- func (s *Store) RecordTargetDecision(ctx context.Context, req *core.UserConnectionMediationRequest, ...) error
- func (s *Store) RegenerateFeedToken(ctx context.Context, userID string) (*core.UserFeedToken, error)
- func (s *Store) RegistrationOpen(ctx context.Context) (bool, error)
- func (s *Store) RequestsToDecide(ctx context.Context, targetID string) ([]*core.UserConnectionMediationRequest, error)
- func (s *Store) RequestsToMediate(ctx context.Context, userIDs []string, mediatorID string) ([]*core.UserConnectionMediationRequest, error)
- func (s *Store) SaveFeed(ctx context.Context, feed *core.RSSFeed) error
- func (s *Store) SaveInvitation(ctx context.Context, inv *core.UserInvitation) error
- func (s *Store) SaveLoginAttempt(ctx context.Context, a *core.LoginAttempt, columns ...string) error
- func (s *Store) SaveProfileAbout(ctx context.Context, userID, about string) error
- func (s *Store) SaveSignupRequest(ctx context.Context, r *core.UserSignupRequest) error
- func (s *Store) SaveUser(ctx context.Context, u *core.User, columns ...string) error
- func (s *Store) SaveUserStyle(ctx context.Context, userID, styles string) error
- func (s *Store) SendMail(ctx context.Context, snd MailQueue, uniqueID, emailType string, ...) error
- func (s *Store) SentInvitations(ctx context.Context, userID string) (core.UserInvitationSlice, error)
- func (s *Store) SetRegistrationOpen(ctx context.Context, open bool) error
- func (s *Store) ShareByID(ctx context.Context, id string) (*core.PostShare, error)
- func (s *Store) ShareOfPost(ctx context.Context, postID string) (*core.PostShare, error)
- func (s *Store) SignupRequestByID(ctx context.Context, id string) (*core.UserSignupRequest, error)
- func (s *Store) SignupRequestEmailExists(ctx context.Context, email string) (bool, error)
- func (s *Store) StoreURL(ctx context.Context, rawURL string) (*core.NormalizedURL, error)
- func (s *Store) Subscribe(ctx context.Context, userID, feedID string) error
- func (s *Store) SubscriptionsOf(ctx context.Context, userID string) (core.UserFeedSubscriptionSlice, error)
- func (s *Store) TwoHops(ctx context.Context, userID string) ([]*Hop, error)
- func (s *Store) Tx(ctx context.Context, fn func(tx *Store) error) error
- func (s *Store) UnconfirmedUserIDsCreatedBefore(ctx context.Context, t time.Time) ([]string, error)
- func (s *Store) UndecidedRequestBetween(ctx context.Context, requestID string, userIDs []string) (*core.UserConnectionMediationRequest, error)
- func (s *Store) UndismissedFeedItems(ctx context.Context, userID string, page Page) (core.UserFeedItemSlice, error)
- func (s *Store) UnexpiredLoginAttempts(ctx context.Context, userID string, now time.Time) (core.LoginAttemptSlice, error)
- func (s *Store) UpdateCommentBody(ctx context.Context, comment *core.PostComment, body string) error
- func (s *Store) UpdateOutgoingEmail(ctx context.Context, email *core.OutgoingEmail) error
- func (s *Store) UpdatePost(ctx context.Context, post *core.Post) error
- func (s *Store) UpdatePrompt(ctx context.Context, prompt *core.PostPrompt) error
- func (s *Store) UploadsByName(ctx context.Context, userID string, names []string) ([]*core.MediaUpload, error)
- func (s *Store) UpsertFeed(ctx context.Context, normalizedURL string) (*core.RSSFeed, error)
- func (s *Store) UpsertFeedItem(ctx context.Context, item *core.RSSItem) (created bool, err error)
- func (s *Store) UseGrant(ctx context.Context, grant *core.WhitelistedConnection, connectionID string) error
- func (s *Store) UserByAPIKey(ctx context.Context, key string) (*core.User, error)
- func (s *Store) UserByEmail(ctx context.Context, email string) (*core.User, error)
- func (s *Store) UserByID(ctx context.Context, id string) (*core.User, error)
- func (s *Store) UserByUsername(ctx context.Context, username string) (*core.User, error)
- func (s *Store) UserEmailExists(ctx context.Context, email string) (bool, error)
- func (s *Store) UserFeedItemByID(ctx context.Context, userID, itemID string) (*core.UserFeedItem, error)
- func (s *Store) UserStyleByUsername(ctx context.Context, username string) (*core.UserStyle, error)
- func (s *Store) UserStyleForUser(ctx context.Context, userID string) (*core.UserStyle, error)
- func (s *Store) UsernameExists(ctx context.Context, username string) (bool, error)
- func (s *Store) UsersByIDs(ctx context.Context, ids []string) (core.UserSlice, error)
- func (s *Store) UsersByIDsNewestFirst(ctx context.Context, ids []string) (core.UserSlice, error)
- func (s *Store) WhitelistTarget(ctx context.Context, username string) (*core.User, error)
- func (s *Store) WhitelistedUsers(ctx context.Context, whoID string) ([]*core.User, error)
- func (s *Store) WrongLoginTriesSince(ctx context.Context, userID string, since time.Time) (int64, error)
Constants ¶
const ( KindComment = "comment" KindPost = "post" KindRSSItem = "rss" )
The kinds of the lists a feed merges. Kinds compare as strings and the merged order is descending, so on a tie it is rss, post, comment.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound replaces sql.ErrNoRows at the repository boundary.
Functions ¶
func FeedTokenForUser ¶
func FeedTokenForUser(ctx context.Context, exec boil.ContextExecutor, userID string) (*core.UserFeedToken, error)
func FeedTokenOwner ¶
func RegenerateFeedToken ¶
func RegenerateFeedToken(ctx context.Context, exec boil.ContextExecutor, userID string) (*core.UserFeedToken, error)
Types ¶
type Hop ¶
Hop is one path of length two from a user: UserID is reached through ViaUserID. UserID may be the user themselves or a direct connection too.
type LockScope ¶
type LockScope string
LockScope names what a per-user advisory lock guards, so that locks taken on the same user for different reasons never wait on each other.
type MailQueue ¶
type MailQueue interface {
Send(ctx context.Context, exec boil.ContextExecutor, uniqueID, emailType string, mail *sender.Mail) error
}
MailQueue stores a mail on the caller's executor, so the mail goes out only if the transaction commits. It is not a delivery channel: delivery is gogo's sender.Sender, which the queue's poller calls later.
type Page ¶
Page is one page of a list sorted newest first by a time, then by kind and ID, so that the order is total even across lists that are merged. A page holds what comes after the item (Before, BeforeKind, BeforeID); a zero Before is the first page. Limit caps the rows, 0 means no cap.
type PostsPage ¶
type PostsPage struct {
AuthorID string
// UpdatedSince keeps posts updated after it, when it is not zero.
UpdatedSince time.Time
// Cursor keeps posts with a smaller ID, when it is not empty.
Cursor string
Limit int
}
PostsPage is the query the API lists posts with.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the entry point to every query. Methods live one file per aggregate (shares.go, posts.go, ...). They take no executor: the Store carries it, either the database or the transaction it was handed by Tx.
func ConnectPostgres ¶
ConnectPostgres opens a store on the database at dsn, for commands that run outside the web server. Close it with the returned function.
func Using ¶
func Using(exec boil.ContextExecutor) *Store
Using returns a Store over an executor that already exists: a transaction opened elsewhere, or the executor a legacy function or a test factory holds. Tx on such a Store joins the executor instead of opening a transaction.
func (*Store) APIKeyForUser ¶
APIKeyForUser returns the user's API key, or nil when they have none.
func (*Store) AddMediatorDecision ¶
func (s *Store) AddMediatorDecision(ctx context.Context, requestID, mediatorID string, decision core.ConnectionMediationDecision, note string) error
AddMediatorDecision records the decision of a mediator on a request.
func (*Store) CommentByID ¶
CommentByID returns a comment, or ErrNotFound.
func (*Store) CommentForMail ¶
CommentForMail returns a comment with its author, its post and the post's author and linked URL loaded.
func (*Store) CommentInPost ¶
func (s *Store) CommentInPost(ctx context.Context, commentID, postID string) (*core.PostComment, error)
CommentInPost returns a comment of the given post, or ErrNotFound.
func (*Store) CommentParticipants ¶
func (s *Store) CommentParticipants(ctx context.Context, postID, authorID string) ([]*core.PostComment, error)
CommentParticipants returns one comment of every user, other than the post's author, who commented on the post, with the commenter loaded (comment.R.User).
func (*Store) CommentedPostIDs ¶
CommentedPostIDs returns the IDs of the posts userID has commented on.
func (*Store) CommentsOfPost ¶
CommentsOfPost returns a post's comments, oldest first, with their authors loaded.
func (*Store) CommentsOnPostsNotBy ¶
func (s *Store) CommentsOnPostsNotBy(ctx context.Context, postIDs []string, userID string, page Page) (core.PostCommentSlice, error)
CommentsOnPostsNotBy returns a page of the comments on postIDs that someone other than userID left, newest first, with their authors loaded.
func (*Store) ConnectedThroughOne ¶
ConnectedThroughOne reports whether a path of length two joins the users.
func (*Store) ConnectedUserIDs ¶
ConnectedUserIDs returns the IDs of userID's direct connections.
func (*Store) CountNewComment ¶
CountNewComment adds one to the comment counter of a post.
func (*Store) CreateAPIKey ¶
CreateAPIKey gives the user an API key. A user has at most one, and there is no rotation: creating again keeps the existing key.
func (*Store) CreateConnection ¶
func (s *Store) CreateConnection(ctx context.Context, user1ID, user2ID string) (*core.UserConnection, *core.UserConnection, error)
CreateConnection stores a connection between two users. Since connections form an undirected graph, the ids go in in both combinations to simplify queries, at the cost of twice the rows. It is meant to run in a transaction. The (user1, user2) row is returned first.
func (*Store) CreateGrant ¶
CreateGrant lets allowsWho connect to who without mediation.
func (*Store) CreateMediaUpload ¶
CreateMediaUpload inserts a media upload record.
func (*Store) CreateMediationRequest ¶
CreateMediationRequest stores a request of who to target with an optional note.
func (*Store) CreateOrUpdateOutgoingEmail ¶
CreateOrUpdateOutgoingEmail creates or updates an outgoing email using upsert.
func (*Store) CreateShare ¶
CreateShare gives a post its share link. A post has at most one, so creating it again keeps the existing link.
func (*Store) DeleteConnectionsBetween ¶
DeleteConnectionsBetween removes the connection of two users, in both directions, together with the whitelist grant and the mediation request (and its mediators) that led to it. Without a connection it does nothing. It is meant to run in a transaction.
func (*Store) DeleteLoginAttemptsExpiredBefore ¶
DeleteLoginAttemptsExpiredBefore deletes the attempts that expired before t and returns how many there were.
func (*Store) DeleteMediationRequestBetween ¶
DeleteMediationRequestBetween removes the request of who to target with its mediators' decisions, locking them first. ErrNotFound when there is none.
func (*Store) DeleteOpenGrant ¶
DeleteOpenGrant withdraws the open grant of who for allowsWho.
func (*Store) DeletePost ¶
DeletePost removes a post with everything that hangs off it: comments, stats, share link and the prompt it answered.
func (*Store) DeleteProfileAbout ¶
DeleteProfileAbout removes the user's "About" text; no text is fine.
func (*Store) DeleteShares ¶
DeleteShares removes a post's share link, if it has one.
func (*Store) DeleteSubscription ¶
DeleteSubscription removes a user's subscription. The feed row stays: the poller skips feeds without subscribers, and this avoids racing a user who adds the feed back.
func (*Store) DeleteUnconfirmedUser ¶
DeleteUnconfirmedUser deletes the user unless they have confirmed their address meanwhile, and reports whether it did.
func (*Store) DismissFeedItem ¶
DismissFeedItem marks a feed item as dismissed.
func (*Store) DismissPrompt ¶
DismissPrompt marks a prompt addressed to the recipient as dismissed at the given time.
func (*Store) DraftPosts ¶
DraftPosts returns the unpublished posts of a user, the last edited first.
func (*Store) Exec ¶
func (s *Store) Exec() boil.ContextExecutor
Exec is the executor, for code that still takes one: forms' Save and the packages RS has not converted yet. Every call is a step RS removes.
func (*Store) FeedItemCount ¶
FeedItemCount is the number of items stored for a feed.
func (*Store) FeedItemExists ¶
FeedItemExists reports whether a feed has an item for a URL.
func (*Store) FeedSubscriptions ¶
func (s *Store) FeedSubscriptions(ctx context.Context, feedID string) (core.UserFeedSubscriptionSlice, error)
FeedSubscriptions returns every subscription to a feed.
func (*Store) FeedTokenForUser ¶
FeedTokenForUser returns the user's feed token, or nil when they have none.
func (*Store) FeedTokenOwner ¶
FeedTokenOwner returns the user a private RSS feed token belongs to, or ErrNotFound when the token is unknown.
func (*Store) FeedsToRefresh ¶
FeedsToRefresh returns the feeds due for a fetch that have at least one subscriber.
func (*Store) GetPendingEmails ¶
GetPendingEmails returns emails ready to be sent, locked for update.
func (*Store) GrantExists ¶
GrantExists reports whether who has a grant for allowsWho, open or used.
func (*Store) InsertComment ¶
InsertComment stores a new comment.
func (*Store) InsertInvitation ¶
InsertInvitation inserts a new invitation.
func (*Store) InsertLoginAttempt ¶
InsertLoginAttempt stores a new login attempt.
func (*Store) InsertPost ¶
InsertPost stores a new post.
func (*Store) InsertPrompt ¶
InsertPrompt stores a new prompt.
func (*Store) InsertSignupRequest ¶
InsertSignupRequest adds an email to the waiting list; an email that is there already keeps its row.
func (*Store) InsertUser ¶
InsertUser inserts a new account.
func (*Store) InsertUserFeedItem ¶
InsertUserFeedItem shows a stored item to a user.
func (*Store) InvitationCount ¶
InvitationCount counts every invitation the user owns, sent or not.
func (*Store) InvitationSentTo ¶
InvitationSentTo reports whether any invitation went to the (normalized) email, accepted or not.
func (*Store) LastImportedAt ¶
LastImportedAt maps each feed to the time its newest item was stored. Feeds without items are missing from the map.
func (*Store) LastPromptBy ¶
LastPromptBy returns the newest prompt the user sent, or ErrNotFound.
func (*Store) LockFeed ¶
LockFeed loads a feed and locks its row until the transaction ends. A feed another transaction holds is skipped, which reads as ErrNotFound.
func (*Store) LockLoginAttempt ¶
LockLoginAttempt returns the attempt locked for update, or ErrNotFound.
func (*Store) LockMailbox ¶
LockMailbox is LockUser for a mailbox (see pgsession.CanonicalEmail), so every spelling of an address takes the same lock.
func (*Store) LockOpenGrant ¶
func (s *Store) LockOpenGrant(ctx context.Context, whoID, allowsWhoID string) (*core.WhitelistedConnection, error)
LockOpenGrant returns the open grant of who for allowsWho and locks it until the transaction ends. ErrNotFound when there is none.
func (*Store) LockUndecidedRequest ¶
func (s *Store) LockUndecidedRequest(ctx context.Context, requestID, targetID string) (*core.UserConnectionMediationRequest, error)
LockUndecidedRequest returns request requestID addressed to targetID, if the target has not decided yet, and locks it until the transaction ends. ErrNotFound otherwise.
func (*Store) LockUnusedInvitation ¶
func (s *Store) LockUnusedInvitation(ctx context.Context, userID string) (*core.UserInvitation, error)
LockUnusedInvitation returns and locks one of the user's invitations that has no email yet, skipping rows locked by others, or ErrNotFound.
func (*Store) LockUser ¶
LockUser takes the transaction-level advisory lock of scope on the user, waiting while another transaction holds it; commit or rollback releases it. Outside a transaction it fails, since the lock would be gone before the next statement.
func (*Store) LoginCodesSince ¶
LoginCodesSince counts the user's attempts created after since that were issued a code.
func (*Store) MailboxHasAccount ¶
MailboxHasAccount reports whether an account uses an address that delivers to the mailbox canonical (see pgsession.CanonicalEmail).
func (*Store) MediationRequestBetween ¶
func (s *Store) MediationRequestBetween(ctx context.Context, whoID, targetID string) (*core.UserConnectionMediationRequest, error)
MediationRequestBetween returns the request of who to target. ErrNotFound when there is none.
func (*Store) MediationRequestExists ¶
MediationRequestExists reports whether who has a request to target.
func (*Store) OpenGrantExists ¶
OpenGrantExists reports whether who has an open grant for allowsWho.
func (*Store) OpenInvitationByID ¶
OpenInvitationByID returns an invitation nobody has accepted yet, with its inviter loaded (invite.R.User), or ErrNotFound.
func (*Store) OpenPromptsFor ¶
func (s *Store) OpenPromptsFor(ctx context.Context, recipientID string) (core.PostPromptSlice, error)
OpenPromptsFor returns the prompts sent to recipientID that they haven't dismissed, newest first, with the asker and the answer post loaded.
func (*Store) OwnPostForUpdate ¶
func (s *Store) OwnPostForUpdate(ctx context.Context, postID, authorID string, draftOnly bool) (*core.Post, error)
OwnPostForUpdate locks and returns a post of the given author. With draftOnly a published post is not found.
func (*Store) OwnPostsByIDs ¶
func (s *Store) OwnPostsByIDs(ctx context.Context, authorID string, ids []string) ([]*core.Post, error)
OwnPostsByIDs returns those of the given posts that belong to the author.
func (*Store) PendingInvitationExists ¶
PendingInvitationExists reports whether an invitation to the (normalized) email has been sent and not yet used to create an account.
func (*Store) PostForEdit ¶
PostForEdit returns a post with its author, stats and linked URL loaded (post.R.User, post.R.PostStat, post.R.URL).
func (*Store) PostToRead ¶
PostToRead returns a post, draft or published, with its author, stats and linked URL loaded (post.R.User, post.R.PostStat, post.R.URL).
func (*Store) PostWithAuthorAndURL ¶
PostWithAuthorAndURL returns a post with its author and linked URL loaded (post.R.User, post.R.URL).
func (*Store) PostsByAuthor ¶
PostsByAuthor returns an author's posts, newest ID first.
func (*Store) PostsForExport ¶
PostsForExport returns an author's posts with their linked URL loaded. With postID only that post is returned.
func (*Store) PostsOfOrAmong ¶
func (s *Store) PostsOfOrAmong(ctx context.Context, userID string, authorIDs, postIDs []string) (core.PostSlice, error)
PostsOfOrAmong returns the posts, drafts included, written by userID, and those written by one of authorIDs whose ID is in postIDs, with their authors loaded.
func (*Store) ProfileAbout ¶
ProfileAbout returns the user's "About" text, or "" when there is none.
func (*Store) PromptForPost ¶
PromptForPost returns the prompt a post answers, with the asker loaded.
func (*Store) PromptForRecipient ¶
func (s *Store) PromptForRecipient(ctx context.Context, recipientID, id string) (*core.PostPrompt, error)
PromptForRecipient returns a prompt addressed to the recipient, with the asker loaded (prompt.R.Asker).
func (*Store) PublishedPostsByProfile ¶
func (s *Store) PublishedPostsByProfile(ctx context.Context, visibility core.PostVisibility, profiles []core.ProfileVisibility, page Page) (core.PostSlice, error)
PublishedPostsByProfile returns a page, newest first, of the published posts with the given visibility whose authors have one of the profile visibilities given. Author, stats and linked URL are loaded.
func (*Store) PublishedPostsOf ¶
func (s *Store) PublishedPostsOf(ctx context.Context, authorID string, visibilities []core.PostVisibility, withStats bool, page Page) (core.PostSlice, error)
PublishedPostsOf returns a page of the author's published posts, newest first, with the author and linked URL loaded. visibilities limits the posts to those visibilities; nil means any. withStats loads post.R.PostStat too.
func (*Store) PublishedPostsOfUsers ¶
func (s *Store) PublishedPostsOfUsers(ctx context.Context, allOf, someOf []string, visibilities []core.PostVisibility, page Page) (core.PostSlice, error)
PublishedPostsOfUsers returns a page, newest first, of the published posts of the users in allOf, and those of the users in someOf that have one of the visibilities given. Author, stats and linked URL are loaded.
func (*Store) RecordTargetDecision ¶
func (s *Store) RecordTargetDecision(ctx context.Context, req *core.UserConnectionMediationRequest, decision core.ConnectionRequestDecision, connectionID, note string) error
RecordTargetDecision stores the decision of the request's target. A connectionID (empty for none) links the connection an approval created.
func (*Store) RegenerateFeedToken ¶
func (s *Store) RegenerateFeedToken(ctx context.Context, userID string) (*core.UserFeedToken, error)
RegenerateFeedToken creates the user's feed token or replaces the existing one, which stops working at once.
func (*Store) RegistrationOpen ¶
RegistrationOpen reports the system setting that lets anybody sign up.
func (*Store) RequestsToDecide ¶
func (s *Store) RequestsToDecide(ctx context.Context, targetID string) ([]*core.UserConnectionMediationRequest, error)
RequestsToDecide returns the undecided requests addressed to targetID that at least one mediator signed, with the requester and the signing mediators loaded.
func (*Store) RequestsToMediate ¶
func (s *Store) RequestsToMediate(ctx context.Context, userIDs []string, mediatorID string) ([]*core.UserConnectionMediationRequest, error)
RequestsToMediate returns the undecided requests between users of userIDs that mediatorID has not answered yet, with both sides loaded.
func (*Store) SaveInvitation ¶
SaveInvitation writes every column of the invitation.
func (*Store) SaveLoginAttempt ¶
func (s *Store) SaveLoginAttempt(ctx context.Context, a *core.LoginAttempt, columns ...string) error
SaveLoginAttempt writes the given columns of the attempt (all when none).
func (*Store) SaveProfileAbout ¶
SaveProfileAbout creates the user's "About" text or replaces it.
func (*Store) SaveSignupRequest ¶
SaveSignupRequest writes every column of the waiting list entry.
func (*Store) SaveUserStyle ¶
SaveUserStyle creates the user's custom CSS or replaces it.
func (*Store) SendMail ¶
func (s *Store) SendMail(ctx context.Context, snd MailQueue, uniqueID, emailType string, mail *sender.Mail) error
SendMail hands a mail to the queue on the store's executor, so a service that sends inside Tx sends only if the transaction commits.
func (*Store) SentInvitations ¶
func (s *Store) SentInvitations(ctx context.Context, userID string) (core.UserInvitationSlice, error)
SentInvitations returns the user's invitations that went to an email.
func (*Store) SetRegistrationOpen ¶
SetRegistrationOpen flips the system setting that lets anybody sign up.
func (*Store) ShareByID ¶
ShareByID returns a share with its post and the post's author loaded (share.R.Post, share.R.Post.R.User).
func (*Store) ShareOfPost ¶
ShareOfPost returns a post's share link, or nil when it has none.
func (*Store) SignupRequestByID ¶
SignupRequestByID returns a waiting list entry, or ErrNotFound.
func (*Store) SignupRequestEmailExists ¶
SignupRequestEmailExists reports whether the (normalized) email waits in the list.
func (*Store) StoreURL ¶
StoreURL normalizes the given URL and stores it in the normalized_urls table, keeping the existing row when the URL is known already.
func (*Store) SubscriptionsOf ¶
func (s *Store) SubscriptionsOf(ctx context.Context, userID string) (core.UserFeedSubscriptionSlice, error)
SubscriptionsOf returns a user's subscriptions oldest first, with the feed loaded (sub.R.Feed).
func (*Store) Tx ¶
Tx runs fn in a transaction and commits when fn returns nil. Inside a transaction, Tx joins it, so a service method that opens one may call another that does. Repositories never call Tx; services do.
func (*Store) UnconfirmedUserIDsCreatedBefore ¶
UnconfirmedUserIDsCreatedBefore returns the ids of the users who never confirmed their address, were created before t and hold no invitations.
func (*Store) UndecidedRequestBetween ¶
func (s *Store) UndecidedRequestBetween(ctx context.Context, requestID string, userIDs []string) (*core.UserConnectionMediationRequest, error)
UndecidedRequestBetween returns request requestID when both its sides are among userIDs and the target has not decided yet. ErrNotFound otherwise.
func (*Store) UndismissedFeedItems ¶
func (s *Store) UndismissedFeedItems(ctx context.Context, userID string, page Page) (core.UserFeedItemSlice, error)
UndismissedFeedItems returns a page of a user's feed items that are not dismissed, newest addition first, with the item, its feed and its URL loaded.
func (*Store) UnexpiredLoginAttempts ¶
func (s *Store) UnexpiredLoginAttempts(ctx context.Context, userID string, now time.Time) (core.LoginAttemptSlice, error)
UnexpiredLoginAttempts returns the user's attempts that expire after now, newest first; the service decides which of them can still log in.
func (*Store) UpdateCommentBody ¶
func (s *Store) UpdateCommentBody(ctx context.Context, comment *core.PostComment, body string) error
UpdateCommentBody stores a new body of a comment and marks it as edited.
func (*Store) UpdateOutgoingEmail ¶
UpdateOutgoingEmail updates an outgoing email record.
func (*Store) UpdatePost ¶
UpdatePost writes every column of an existing post.
func (*Store) UpdatePrompt ¶
UpdatePrompt writes every column of an existing prompt.
func (*Store) UploadsByName ¶
func (s *Store) UploadsByName(ctx context.Context, userID string, names []string) ([]*core.MediaUpload, error)
UploadsByName returns the user's uploads among the given file names.
func (*Store) UpsertFeed ¶
UpsertFeed returns the feed with this (already normalized) URL, creating it if nobody subscribed to it yet.
func (*Store) UpsertFeedItem ¶
UpsertFeedItem stores an item. If the feed already has one for the URL, the stored one is kept and created is false.
func (*Store) UseGrant ¶
func (s *Store) UseGrant(ctx context.Context, grant *core.WhitelistedConnection, connectionID string) error
UseGrant marks a grant as used by the connection.
func (*Store) UserByAPIKey ¶
UserByAPIKey returns the user an API key belongs to, or ErrNotFound.
func (*Store) UserByEmail ¶
UserByEmail returns the user whose stored email is email, or ErrNotFound.
func (*Store) UserByUsername ¶
UserByUsername returns the user with that username.
func (*Store) UserEmailExists ¶
UserEmailExists reports whether an account uses the (normalized) email.
func (*Store) UserFeedItemByID ¶
func (s *Store) UserFeedItemByID(ctx context.Context, userID, itemID string) (*core.UserFeedItem, error)
UserFeedItemByID returns a user's feed item, or ErrNotFound if the user has no such item.
func (*Store) UserStyleByUsername ¶
UserStyleByUsername returns the custom CSS row of the user with the username, or nil when the user or the row does not exist.
func (*Store) UserStyleForUser ¶
UserStyleForUser returns the user's custom CSS row, or nil when they have none.
func (*Store) UsernameExists ¶
UsernameExists reports whether an account has the username.
func (*Store) UsersByIDs ¶
UsersByIDs returns the users with those IDs, in no particular order.
func (*Store) UsersByIDsNewestFirst ¶
UsersByIDsNewestFirst returns the users with those IDs, the most recently signed up first.
func (*Store) WhitelistTarget ¶
WhitelistTarget finds the user a whitelist grant is about, by username.
func (*Store) WhitelistedUsers ¶
WhitelistedUsers returns the users whoID has an open grant for.