Documentation ¶
Index ¶
- Constants
- func Migrations(opts ...migration.SuiteOption) *migration.Suite
- type Audit
- type Chirp
- type ChirpAttachment
- type ChirpFull
- type ChirpLike
- type ChirpStats
- type ChirpStatus
- type EdgeType
- type Feed
- type Graph
- type Manager
- func (m Manager) Audit(ctx context.Context, userID uuid.UUID, verb, noun, subject string) error
- func (m Manager) Block(ctx context.Context, userID, targetUserID uuid.UUID) error
- func (m Manager) BlocksForUserID(ctx context.Context, userID uuid.UUID) (output []uuid.UUID, err error)
- func (m Manager) Chirp(ctx context.Context, userID, id uuid.UUID) (c ChirpFull, found bool, err error)
- func (m Manager) ChirpReplies(ctx context.Context, selfUserID, chirpID uuid.UUID) (output []ChirpFull, err error)
- func (m Manager) CreateChirp(ctx context.Context, c *Chirp) (err error)
- func (m Manager) DeleteChirp(ctx context.Context, c Chirp) (deleted bool, err error)
- func (m Manager) EnsureUserInfoOnCreate(ctx context.Context, user *apputil.User) error
- func (m Manager) EnsureUserInfoOnFetch(ctx context.Context, session *web.Session) error
- func (m Manager) FeedForUserID(ctx context.Context, userID uuid.UUID, take int, afterChirpID *uuid.UUID) (output []ChirpFull, err error)
- func (m Manager) Follow(ctx context.Context, userID, targetUserID uuid.UUID) error
- func (m Manager) FollowingForUserID(ctx context.Context, userID uuid.UUID) (output []uuid.UUID, err error)
- func (m Manager) FollowsForUserID(ctx context.Context, userID uuid.UUID) (output []uuid.UUID, err error)
- func (m Manager) LikeChirp(ctx context.Context, userID uuid.UUID, chirp Chirp) error
- func (m Manager) MarkNotificationsRead(ctx context.Context, userID uuid.UUID, notificationIDs []uuid.UUID) error
- func (m Manager) Mute(ctx context.Context, userID, targetUserID uuid.UUID) error
- func (m Manager) MutesForUserID(ctx context.Context, userID uuid.UUID) (output []uuid.UUID, err error)
- func (m Manager) Notifications(ctx context.Context, userID uuid.UUID, take int, ...) (output []NotificationFull, err error)
- func (m Manager) NotificationsUnread(ctx context.Context, userID uuid.UUID) (output int, err error)
- func (m Manager) ProfileLikes(ctx context.Context, selfUserID, targetUserID uuid.UUID, take int, ...) (output []ChirpFull, err error)
- func (m Manager) ProfilePosts(ctx context.Context, selfUserID, userID uuid.UUID, take int, ...) (output []ChirpFull, err error)
- func (m Manager) ProfileReplies(ctx context.Context, selfUserID, userID uuid.UUID, take int, ...) (output []ChirpFull, err error)
- func (m Manager) PublishChirp(ctx context.Context, c *Chirp) (err error)
- func (m Manager) SearchUsers(ctx context.Context, userID uuid.UUID, query string) (output []UserFull, err error)
- func (m Manager) Unblock(ctx context.Context, userID, targetUserID uuid.UUID) error
- func (m Manager) Unfollow(ctx context.Context, userID, targetUserID uuid.UUID) error
- func (m Manager) UnlikeChirp(ctx context.Context, userID, chirpID uuid.UUID) error
- func (m Manager) Unmute(ctx context.Context, userID, targetUserID uuid.UUID) error
- func (m Manager) User(ctx context.Context, selfUserID, userID uuid.UUID) (output UserFull, found bool, err error)
- func (m Manager) UserByUsername(ctx context.Context, selfUserID uuid.UUID, username string) (output UserFull, found bool, err error)
- type Notification
- type NotificationFull
- type NotificationType
- type SessionState
- type UserFull
- type UserInfo
- type UserStatus
Constants ¶
const ( EdgeTypeFollow = "follow" EdgeTypeBlock = "block" EdgeTypeMute = "mute" )
EdgeType values.
const ( NotificationTypeFollow = "follow" NotificationTypeLike = "like" )
NotificationTypes
Variables ¶
This section is empty.
Functions ¶
func Migrations ¶
func Migrations(opts ...migration.SuiteOption) *migration.Suite
Migrations returns the migration suite to bootstrap the database.
Types ¶
type Audit ¶
type Audit struct { ID uuid.UUID `db:"id,pk,auto"` TimestampUTC time.Time `db:"timestamp_utc"` UserID uuid.UUID `db:"user_id"` Verb string `db:"verb"` Noun string `db:"noun"` Subject string `db:"subject"` }
Audit records an action by a user.
type Chirp ¶
type Chirp struct { ID uuid.UUID `db:"id,pk,auto"` UserID uuid.UUID `db:"user_id"` CreatedUTC time.Time `db:"created_utc"` PublishedUTC *time.Time `db:"published_utc"` Text string `db:"text"` ReplyID *uuid.UUID `db:"reply_id"` QuotedID *uuid.UUID `db:"quoted_id"` Attachments []ChirpAttachment `db:"attachments,json"` }
Chirp is the main primitive of the app.
It is either a text post, a rechirp, and can include attachments.
type ChirpAttachment ¶
ChirpAttachment is an attachment, e.g. a picture to a chrip.
type ChirpFull ¶
type ChirpFull struct { Chirp User apputil.User UserInfo UserInfo Status ChirpStatus Stats ChirpStats ReplyTo *ChirpFull Quoted *ChirpFull }
ChirpFull is a hydrated chirp with all the extra stuff on it.
type ChirpLike ¶
type ChirpLike struct { ChirpID uuid.UUID `db:"chirp_id,pk"` UserID uuid.UUID `db:"user_id,pk"` TimestampUTC time.Time `db:"timestamp_utc"` }
ChirpLike are stats about chrips e.g. likes and rechirps.
type ChirpStats ¶
type ChirpStats struct { ChirpID uuid.UUID `db:"chirp_id,pk"` UserID uuid.UUID `db:"user_id"` Replies uint64 `db:"replies"` Likes uint64 `db:"likes"` Rechirps uint64 `db:"rechirps"` }
ChirpStats are stats about chrips e.g. likes and rechirps.
func (ChirpStats) TableName ¶
func (c ChirpStats) TableName() string
TableName is the mapped table name.
type ChirpStatus ¶
type Feed ¶
type Feed struct { UserID uuid.UUID `db:"user_id,pk"` ChirpID uuid.UUID `db:"chirp_id,pk"` TimestampUTC time.Time `db:"timestamp_utc"` }
Feed is the record of specific chirps mapped to relevant (following) users.
type Graph ¶
type Graph struct { UserID uuid.UUID `db:"user_id,pk"` TargetID uuid.UUID `db:"target_id,pk"` Type string `db:"type,pk"` TimestampUTC time.Time `db:"timestamp_utc"` }
Graph holds the following, mute and block relationships between users.
type Manager ¶
type Manager struct {
dbutil.BaseManager
}
Manager is the datumsbase manager.
func (Manager) BlocksForUserID ¶
func (m Manager) BlocksForUserID(ctx context.Context, userID uuid.UUID) (output []uuid.UUID, err error)
BlocksForUserID gets the users a given user blocks.
func (Manager) Chirp ¶
func (m Manager) Chirp(ctx context.Context, userID, id uuid.UUID) (c ChirpFull, found bool, err error)
Chirp gets a chirp by ID (and infers status based on the provided userID).
func (Manager) ChirpReplies ¶
func (m Manager) ChirpReplies(ctx context.Context, selfUserID, chirpID uuid.UUID) (output []ChirpFull, err error)
ChirpReplies returns the replies for a given chirp id.
func (Manager) CreateChirp ¶
CreateChirp creates the chirp staging it for publishing.
func (Manager) DeleteChirp ¶
DeleteChirp deletes a chirp and removes it from any referenced table(s).
func (Manager) EnsureUserInfoOnCreate ¶
EnsureUserInfoOnCreate creates the rest of the user components on login.
func (Manager) EnsureUserInfoOnFetch ¶
EnsureUserInfoOnFetch fetches the rest of the user components.
func (Manager) FeedForUserID ¶
func (m Manager) FeedForUserID(ctx context.Context, userID uuid.UUID, take int, afterChirpID *uuid.UUID) (output []ChirpFull, err error)
FeedForUserID returns the feed for a given user, optionally after a given chirpID.
func (Manager) Follow ¶
Follow adds a graph record that a given user follows a target user as well as adds that target user's chirps to the given user's feed.
func (Manager) FollowingForUserID ¶
func (m Manager) FollowingForUserID(ctx context.Context, userID uuid.UUID) (output []uuid.UUID, err error)
FollowingForUserID gets the users that a given user follows.
func (Manager) FollowsForUserID ¶
func (m Manager) FollowsForUserID(ctx context.Context, userID uuid.UUID) (output []uuid.UUID, err error)
FollowsForUserID gets the users that follow a given user.
func (Manager) MarkNotificationsRead ¶
func (m Manager) MarkNotificationsRead(ctx context.Context, userID uuid.UUID, notificationIDs []uuid.UUID) error
MarkNotificationsRead marks a list of notifications as read.
func (Manager) Mute ¶
Mute adds a graph record to indicate we should not show a target user's chirps in a given user's feed but we should not block the target user from following the given user or seeing their chirps.
func (Manager) MutesForUserID ¶
func (m Manager) MutesForUserID(ctx context.Context, userID uuid.UUID) (output []uuid.UUID, err error)
BlocksForUserID gets the users a given user has muted.
func (Manager) Notifications ¶
func (m Manager) Notifications(ctx context.Context, userID uuid.UUID, take int, afterNotificationID *uuid.UUID) (output []NotificationFull, err error)
Notifications yields the last N notifications for a user
func (Manager) NotificationsUnread ¶
NotificationsUnread returns the unread notification count.
func (Manager) ProfileLikes ¶
func (m Manager) ProfileLikes(ctx context.Context, selfUserID, targetUserID uuid.UUID, take int, afterChirpID *uuid.UUID) (output []ChirpFull, err error)
ProfileLikes returns the liked chirps for a given user.
func (Manager) ProfilePosts ¶
func (m Manager) ProfilePosts(ctx context.Context, selfUserID, userID uuid.UUID, take int, afterChirpID *uuid.UUID) (output []ChirpFull, err error)
ProfilePosts returns the posts (non-reply, non-likes) for a given user, optionally after a given chirpID.
func (Manager) ProfileReplies ¶
func (m Manager) ProfileReplies(ctx context.Context, selfUserID, userID uuid.UUID, take int, afterChirpID *uuid.UUID) (output []ChirpFull, err error)
ProfileReplies returns the posts (non-reply, non-likes) for a given user, optionally after a given chirpID.
func (Manager) PublishChirp ¶
PublishChirp publishes the chirp, adding attachments and forwarding to the feed table.
func (Manager) SearchUsers ¶
func (m Manager) SearchUsers(ctx context.Context, userID uuid.UUID, query string) (output []UserFull, err error)
SearchUsers returns a list of users that match a search query.
func (Manager) Unfollow ¶
Unfollow is the reverse of follow and removes a target user's chirps from a given user's feed and removes the graph record that the given user follows the target user.
func (Manager) UnlikeChirp ¶
UnlikeChirp undoes a like to a chirp.
func (Manager) Unmute ¶
Unmute is the reverse of mute and allows a target user's chirps to appear in a given user's feed.
type Notification ¶
type Notification struct { ID uuid.UUID `db:"id,pk,auto"` UserID uuid.UUID `db:"user_id"` CreatedUTC time.Time `db:"created_utc"` ReadUTC *time.Time `db:"read_utc"` ActingUserID uuid.UUID `db:"acting_user_id"` ChirpID *uuid.UUID `db:"chirp_id"` Type string `db:"type"` }
Notification is someting we're going to show in the UI at some point.
func (Notification) TableName ¶
func (n Notification) TableName() string
TableName is a name of a table.
type NotificationFull ¶
type NotificationFull struct { Notification ActingUser UserFull Chirp *Chirp }
NotificationFull is a notification with associated information.
type SessionState ¶
type SessionState struct { apputil.SessionState UnreadNotifications int UserInfo UserInfo }
SessionState is an application specific session state.
type UserFull ¶
type UserFull struct { apputil.User Info UserInfo Status UserStatus }
UserFull is all relevant information about a user.