repo

package
v0.0.0-...-41f0c78 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package repo holds database queries.

Index

Constants

View Source
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

View Source
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 FeedTokenOwner(ctx context.Context, exec boil.ContextExecutor, token string) (*core.User, error)

func RegenerateFeedToken

func RegenerateFeedToken(ctx context.Context, exec boil.ContextExecutor, userID string) (*core.UserFeedToken, error)

Types

type Hop

type Hop struct {
	UserID    string `boil:"user_id"`
	ViaUserID string `boil:"via_user_id"`
}

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.

const (
	// LockLoginCodes guards the counts behind a user's login code limits.
	LockLoginCodes LockScope = "login_codes"
	// LockSignupMailbox guards the check that a mailbox has no account yet.
	LockSignupMailbox LockScope = "signup_mailbox"
)

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

type Page struct {
	Before     time.Time
	BeforeKind string
	BeforeID   string
	Limit      int
}

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

func ConnectPostgres(dsn string) (*Store, func() error, error)

ConnectPostgres opens a store on the database at dsn, for commands that run outside the web server. Close it with the returned function.

func New

func New(db *sqlx.DB) *Store

New returns a Store over db.

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

func (s *Store) APIKeyForUser(ctx context.Context, userID string) (*core.UserAPIKey, error)

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

func (s *Store) CommentByID(ctx context.Context, id string) (*core.PostComment, error)

CommentByID returns a comment, or ErrNotFound.

func (*Store) CommentForMail

func (s *Store) CommentForMail(ctx context.Context, id string) (*core.PostComment, error)

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

func (s *Store) CommentedPostIDs(ctx context.Context, userID string) ([]string, error)

CommentedPostIDs returns the IDs of the posts userID has commented on.

func (*Store) CommentsOfPost

func (s *Store) CommentsOfPost(ctx context.Context, postID string) (core.PostCommentSlice, error)

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) Connected

func (s *Store) Connected(ctx context.Context, userID, otherID string) (bool, error)

Connected reports whether two users are directly connected.

func (*Store) ConnectedThroughOne

func (s *Store) ConnectedThroughOne(ctx context.Context, userID, otherID string) (bool, error)

ConnectedThroughOne reports whether a path of length two joins the users.

func (*Store) ConnectedUserIDs

func (s *Store) ConnectedUserIDs(ctx context.Context, userID string) ([]string, error)

ConnectedUserIDs returns the IDs of userID's direct connections.

func (*Store) CountNewComment

func (s *Store) CountNewComment(ctx context.Context, postID string) error

CountNewComment adds one to the comment counter of a post.

func (*Store) CreateAPIKey

func (s *Store) CreateAPIKey(ctx context.Context, userID string) error

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

func (s *Store) CreateGrant(ctx context.Context, whoID, allowsWhoID string) error

CreateGrant lets allowsWho connect to who without mediation.

func (*Store) CreateMediaUpload

func (s *Store) CreateMediaUpload(ctx context.Context, upload *core.MediaUpload) error

CreateMediaUpload inserts a media upload record.

func (*Store) CreateMediationRequest

func (s *Store) CreateMediationRequest(ctx context.Context, whoID, targetID, note string) error

CreateMediationRequest stores a request of who to target with an optional note.

func (*Store) CreateOrUpdateOutgoingEmail

func (s *Store) CreateOrUpdateOutgoingEmail(ctx context.Context, email *core.OutgoingEmail) error

CreateOrUpdateOutgoingEmail creates or updates an outgoing email using upsert.

func (*Store) CreateShare

func (s *Store) CreateShare(ctx context.Context, postID string) error

CreateShare gives a post its share link. A post has at most one, so creating it again keeps the existing link.

func (*Store) DeleteConnectionsBetween

func (s *Store) DeleteConnectionsBetween(ctx context.Context, userID, otherID string) error

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

func (s *Store) DeleteLoginAttemptsExpiredBefore(ctx context.Context, t time.Time) (int64, error)

DeleteLoginAttemptsExpiredBefore deletes the attempts that expired before t and returns how many there were.

func (*Store) DeleteMediationRequestBetween

func (s *Store) DeleteMediationRequestBetween(ctx context.Context, whoID, targetID string) error

DeleteMediationRequestBetween removes the request of who to target with its mediators' decisions, locking them first. ErrNotFound when there is none.

func (*Store) DeleteOpenGrant

func (s *Store) DeleteOpenGrant(ctx context.Context, whoID, allowsWhoID string) error

DeleteOpenGrant withdraws the open grant of who for allowsWho.

func (*Store) DeletePost

func (s *Store) DeletePost(ctx context.Context, postID string) error

DeletePost removes a post with everything that hangs off it: comments, stats, share link and the prompt it answered.

func (*Store) DeleteProfileAbout

func (s *Store) DeleteProfileAbout(ctx context.Context, userID string) error

DeleteProfileAbout removes the user's "About" text; no text is fine.

func (*Store) DeleteShares

func (s *Store) DeleteShares(ctx context.Context, postID string) error

DeleteShares removes a post's share link, if it has one.

func (*Store) DeleteSubscription

func (s *Store) DeleteSubscription(ctx context.Context, userID, subscriptionID string) error

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

func (s *Store) DeleteUnconfirmedUser(ctx context.Context, id string) (bool, error)

DeleteUnconfirmedUser deletes the user unless they have confirmed their address meanwhile, and reports whether it did.

func (*Store) DismissFeedItem

func (s *Store) DismissFeedItem(ctx context.Context, item *core.UserFeedItem) error

DismissFeedItem marks a feed item as dismissed.

func (*Store) DismissPrompt

func (s *Store) DismissPrompt(ctx context.Context, recipientID, id string, at time.Time) error

DismissPrompt marks a prompt addressed to the recipient as dismissed at the given time.

func (*Store) DraftPosts

func (s *Store) DraftPosts(ctx context.Context, userID string) ([]*core.Post, error)

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

func (s *Store) FeedItemCount(ctx context.Context, feedID string) (int64, error)

FeedItemCount is the number of items stored for a feed.

func (*Store) FeedItemExists

func (s *Store) FeedItemExists(ctx context.Context, feedID, urlID string) (bool, error)

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

func (s *Store) FeedTokenForUser(ctx context.Context, userID string) (*core.UserFeedToken, error)

FeedTokenForUser returns the user's feed token, or nil when they have none.

func (*Store) FeedTokenOwner

func (s *Store) FeedTokenOwner(ctx context.Context, token string) (*core.User, error)

FeedTokenOwner returns the user a private RSS feed token belongs to, or ErrNotFound when the token is unknown.

func (*Store) FeedsToRefresh

func (s *Store) FeedsToRefresh(ctx context.Context) ([]*core.RSSFeed, error)

FeedsToRefresh returns the feeds due for a fetch that have at least one subscriber.

func (*Store) GetPendingEmails

func (s *Store) GetPendingEmails(ctx context.Context) ([]*core.OutgoingEmail, error)

GetPendingEmails returns emails ready to be sent, locked for update.

func (*Store) GrantExists

func (s *Store) GrantExists(ctx context.Context, whoID, allowsWhoID string) (bool, error)

GrantExists reports whether who has a grant for allowsWho, open or used.

func (*Store) InsertComment

func (s *Store) InsertComment(ctx context.Context, comment *core.PostComment) error

InsertComment stores a new comment.

func (*Store) InsertInvitation

func (s *Store) InsertInvitation(ctx context.Context, inv *core.UserInvitation) error

InsertInvitation inserts a new invitation.

func (*Store) InsertLoginAttempt

func (s *Store) InsertLoginAttempt(ctx context.Context, a *core.LoginAttempt) error

InsertLoginAttempt stores a new login attempt.

func (*Store) InsertPost

func (s *Store) InsertPost(ctx context.Context, post *core.Post) error

InsertPost stores a new post.

func (*Store) InsertPrompt

func (s *Store) InsertPrompt(ctx context.Context, prompt *core.PostPrompt) error

InsertPrompt stores a new prompt.

func (*Store) InsertSignupRequest

func (s *Store) InsertSignupRequest(ctx context.Context, r *core.UserSignupRequest) error

InsertSignupRequest adds an email to the waiting list; an email that is there already keeps its row.

func (*Store) InsertUser

func (s *Store) InsertUser(ctx context.Context, u *core.User) error

InsertUser inserts a new account.

func (*Store) InsertUserFeedItem

func (s *Store) InsertUserFeedItem(ctx context.Context, userID, rssItemID, urlID string) error

InsertUserFeedItem shows a stored item to a user.

func (*Store) InvitationCount

func (s *Store) InvitationCount(ctx context.Context, userID string) (int64, error)

InvitationCount counts every invitation the user owns, sent or not.

func (*Store) InvitationSentTo

func (s *Store) InvitationSentTo(ctx context.Context, email string) (bool, error)

InvitationSentTo reports whether any invitation went to the (normalized) email, accepted or not.

func (*Store) LastImportedAt

func (s *Store) LastImportedAt(ctx context.Context, feedIDs []string) (map[string]time.Time, error)

LastImportedAt maps each feed to the time its newest item was stored. Feeds without items are missing from the map.

func (*Store) LastPromptBy

func (s *Store) LastPromptBy(ctx context.Context, askerID string) (*core.PostPrompt, error)

LastPromptBy returns the newest prompt the user sent, or ErrNotFound.

func (*Store) LockFeed

func (s *Store) LockFeed(ctx context.Context, feedID string) (*core.RSSFeed, error)

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

func (s *Store) LockLoginAttempt(ctx context.Context, id string) (*core.LoginAttempt, error)

LockLoginAttempt returns the attempt locked for update, or ErrNotFound.

func (*Store) LockMailbox

func (s *Store) LockMailbox(ctx context.Context, scope LockScope, canonical string) error

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

func (s *Store) LockUser(ctx context.Context, scope LockScope, userID string) error

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

func (s *Store) LoginCodesSince(ctx context.Context, userID string, since time.Time) (int64, error)

LoginCodesSince counts the user's attempts created after since that were issued a code.

func (*Store) MailboxHasAccount

func (s *Store) MailboxHasAccount(ctx context.Context, canonical string) (bool, error)

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

func (s *Store) MediationRequestExists(ctx context.Context, whoID, targetID string) (bool, error)

MediationRequestExists reports whether who has a request to target.

func (*Store) OpenGrantExists

func (s *Store) OpenGrantExists(ctx context.Context, whoID, allowsWhoID string) (bool, error)

OpenGrantExists reports whether who has an open grant for allowsWho.

func (*Store) OpenInvitationByID

func (s *Store) OpenInvitationByID(ctx context.Context, id string) (*core.UserInvitation, error)

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) OwnPost

func (s *Store) OwnPost(ctx context.Context, postID, authorID string) (*core.Post, error)

OwnPost returns a post of the given author, or ErrNotFound.

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

func (s *Store) PendingInvitationExists(ctx context.Context, email string) (bool, error)

PendingInvitationExists reports whether an invitation to the (normalized) email has been sent and not yet used to create an account.

func (*Store) PostByID

func (s *Store) PostByID(ctx context.Context, id string) (*core.Post, error)

PostByID returns a post, draft or published.

func (*Store) PostForEdit

func (s *Store) PostForEdit(ctx context.Context, id string) (*core.Post, error)

PostForEdit returns a post with its author, stats and linked URL loaded (post.R.User, post.R.PostStat, post.R.URL).

func (*Store) PostToRead

func (s *Store) PostToRead(ctx context.Context, id string) (*core.Post, error)

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

func (s *Store) PostWithAuthorAndURL(ctx context.Context, id string) (*core.Post, error)

PostWithAuthorAndURL returns a post with its author and linked URL loaded (post.R.User, post.R.URL).

func (*Store) PostsByAuthor

func (s *Store) PostsByAuthor(ctx context.Context, page PostsPage) ([]*core.Post, error)

PostsByAuthor returns an author's posts, newest ID first.

func (*Store) PostsForExport

func (s *Store) PostsForExport(ctx context.Context, authorID, postID string) ([]*core.Post, error)

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

func (s *Store) ProfileAbout(ctx context.Context, userID string) (string, error)

ProfileAbout returns the user's "About" text, or "" when there is none.

func (*Store) PromptForPost

func (s *Store) PromptForPost(ctx context.Context, postID string) (*core.PostPrompt, error)

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

func (s *Store) RegistrationOpen(ctx context.Context) (bool, error)

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) SaveFeed

func (s *Store) SaveFeed(ctx context.Context, feed *core.RSSFeed) error

SaveFeed writes the feed's fields back.

func (*Store) SaveInvitation

func (s *Store) SaveInvitation(ctx context.Context, inv *core.UserInvitation) error

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

func (s *Store) SaveProfileAbout(ctx context.Context, userID, about string) error

SaveProfileAbout creates the user's "About" text or replaces it.

func (*Store) SaveSignupRequest

func (s *Store) SaveSignupRequest(ctx context.Context, r *core.UserSignupRequest) error

SaveSignupRequest writes every column of the waiting list entry.

func (*Store) SaveUser

func (s *Store) SaveUser(ctx context.Context, u *core.User, columns ...string) error

SaveUser writes the named columns of u, or all of them when none is named.

func (*Store) SaveUserStyle

func (s *Store) SaveUserStyle(ctx context.Context, userID, styles string) error

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

func (s *Store) SetRegistrationOpen(ctx context.Context, open bool) error

SetRegistrationOpen flips the system setting that lets anybody sign up.

func (*Store) ShareByID

func (s *Store) ShareByID(ctx context.Context, id string) (*core.PostShare, error)

ShareByID returns a share with its post and the post's author loaded (share.R.Post, share.R.Post.R.User).

func (*Store) ShareOfPost

func (s *Store) ShareOfPost(ctx context.Context, postID string) (*core.PostShare, error)

ShareOfPost returns a post's share link, or nil when it has none.

func (*Store) SignupRequestByID

func (s *Store) SignupRequestByID(ctx context.Context, id string) (*core.UserSignupRequest, error)

SignupRequestByID returns a waiting list entry, or ErrNotFound.

func (*Store) SignupRequestEmailExists

func (s *Store) SignupRequestEmailExists(ctx context.Context, email string) (bool, error)

SignupRequestEmailExists reports whether the (normalized) email waits in the list.

func (*Store) StoreURL

func (s *Store) StoreURL(ctx context.Context, rawURL string) (*core.NormalizedURL, error)

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) Subscribe

func (s *Store) Subscribe(ctx context.Context, userID, feedID string) error

Subscribe subscribes a user to a feed, keeping an existing subscription.

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) TwoHops

func (s *Store) TwoHops(ctx context.Context, userID string) ([]*Hop, error)

TwoHops returns every path of length two from userID.

func (*Store) Tx

func (s *Store) Tx(ctx context.Context, fn func(tx *Store) error) error

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

func (s *Store) UnconfirmedUserIDsCreatedBefore(ctx context.Context, t time.Time) ([]string, error)

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

func (s *Store) UpdateOutgoingEmail(ctx context.Context, email *core.OutgoingEmail) error

UpdateOutgoingEmail updates an outgoing email record.

func (*Store) UpdatePost

func (s *Store) UpdatePost(ctx context.Context, post *core.Post) error

UpdatePost writes every column of an existing post.

func (*Store) UpdatePrompt

func (s *Store) UpdatePrompt(ctx context.Context, prompt *core.PostPrompt) error

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

func (s *Store) UpsertFeed(ctx context.Context, normalizedURL string) (*core.RSSFeed, error)

UpsertFeed returns the feed with this (already normalized) URL, creating it if nobody subscribed to it yet.

func (*Store) UpsertFeedItem

func (s *Store) UpsertFeedItem(ctx context.Context, item *core.RSSItem) (created bool, err error)

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

func (s *Store) UserByAPIKey(ctx context.Context, key string) (*core.User, error)

UserByAPIKey returns the user an API key belongs to, or ErrNotFound.

func (*Store) UserByEmail

func (s *Store) UserByEmail(ctx context.Context, email string) (*core.User, error)

UserByEmail returns the user whose stored email is email, or ErrNotFound.

func (*Store) UserByID

func (s *Store) UserByID(ctx context.Context, id string) (*core.User, error)

UserByID returns the user, or ErrNotFound.

func (*Store) UserByUsername

func (s *Store) UserByUsername(ctx context.Context, username string) (*core.User, error)

UserByUsername returns the user with that username.

func (*Store) UserEmailExists

func (s *Store) UserEmailExists(ctx context.Context, email string) (bool, error)

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

func (s *Store) UserStyleByUsername(ctx context.Context, username string) (*core.UserStyle, error)

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

func (s *Store) UserStyleForUser(ctx context.Context, userID string) (*core.UserStyle, error)

UserStyleForUser returns the user's custom CSS row, or nil when they have none.

func (*Store) UsernameExists

func (s *Store) UsernameExists(ctx context.Context, username string) (bool, error)

UsernameExists reports whether an account has the username.

func (*Store) UsersByIDs

func (s *Store) UsersByIDs(ctx context.Context, ids []string) (core.UserSlice, error)

UsersByIDs returns the users with those IDs, in no particular order.

func (*Store) UsersByIDsNewestFirst

func (s *Store) UsersByIDsNewestFirst(ctx context.Context, ids []string) (core.UserSlice, error)

UsersByIDsNewestFirst returns the users with those IDs, the most recently signed up first.

func (*Store) WhitelistTarget

func (s *Store) WhitelistTarget(ctx context.Context, username string) (*core.User, error)

WhitelistTarget finds the user a whitelist grant is about, by username.

func (*Store) WhitelistedUsers

func (s *Store) WhitelistedUsers(ctx context.Context, whoID string) ([]*core.User, error)

WhitelistedUsers returns the users whoID has an open grant for.

func (*Store) WrongLoginTriesSince

func (s *Store) WrongLoginTriesSince(ctx context.Context, userID string, since time.Time) (int64, error)

WrongLoginTriesSince sums the wrong codes tried on the user's attempts created after since.

Jump to

Keyboard shortcuts

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