model

package
v0.0.0-...-4fdfd55 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Types
	CommentType           = "comment"
	MentionType           = "mention"
	BoostType             = "boost"
	InviteAcceptedType    = "inviteAccepted"
	AnnouncementType      = "announcement"
	IntroductionType      = "introduction"
	NewInvitesType        = "newInvites"
	FollowType            = "follow"
	CoinsReceivedType     = "coinsReceived"
	PopularPostType       = "popularPost"
	LeaderboardRankType   = "leaderboardRank"
	FirstPostActivityType = "firstPostActivity"

	// ActionTypes
	OpenThreadAction = "openThread"
	// "threadRootID"
	OpenUserProfileAction = "openProfile"
	// "username"
	OpenComposerAction = "openComposer"
	// "startingPrompt"
	OpenInvitesAction = "openInvites"
	// no params
	OpenWalletAction = "openWallet"

	NavigateToAction = "navigateTo"
)
View Source
const (
	TimeScalingFactor = 45000.0
	PopularRankPower  = 0.7
	OctoberUnixOffset = 1475280000.0

	//these are basically random -- let's revisit these parameters
	UpvoteMult   = 1.0
	DownvoteMult = 2.0
	CommentMult  = 1.5
)
View Source
const (
	// FacebookProvider is the constant stored in the database to identify
	// Facebook OAuth 2.0 accounts.
	FacebookProvider = "facebook"
)
View Source
const SessionTTL = 30 * 24 * time.Hour

SessionTTL defines the time to live after which a session is expired.

Variables

View Source
var (
	// AllCardReactions      = []ReactionType{Boost, Bury, HighFive, Pass, Seen, Comment, Like, Love, Haha, Wow, Sad, Angry}
	GraphCardReactions    = []ReactionType{UpVote, DownVote, Comment}
	ExplicitCardReactions = []ReactionType{Boost, Bury}
	GossipedReactions     = []ReactionType{UpVote, DownVote, Comment, Post, UndoComment}
	CardReactions         = []ReactionType{Like, Love, Haha, Wow, Sad, Angry}
	Votes                 = []ReactionType{UpVote, DownVote}
)

The Card Reactions, from least to most restrictive AllCardReactions is everything the FE can throw into the ReactToCard RPC GraphCardReactions is everything the ReactToCard RPC can throw to the graph ExplicitCardReactions is one-time explicit button press signals tracked by the graph GossipedReactions is reactions which are sent via gossip to all neighbors paying attention

View Source
var (
	// ErrUsernameTaken is used when a username is validated but it is already in
	// use by another user.
	ErrInsufficientBalance = errors.New("not enough coins to pay cost")
)
View Source
var ErrInvalidInviteCode = errors.New("invalid or expired invite code")
View Source
var ErrWrongPassword = errors.New("password did not match")

Functions

func CardReaction

func CardReaction(reaction ReactionType) bool

func ExplicitReaction

func ExplicitReaction(reaction ReactionType) bool

func GossipedReaction

func GossipedReaction(reaction ReactionType) bool

func GraphCardReaction

func GraphCardReaction(reaction ReactionType) bool

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes the password using bcrypt.

func HashResetToken

func HashResetToken(token globalid.ID) (string, error)

func NewDBTime

func NewDBTime(t time.Time) dbTime

func NilDBTime

func NilDBTime() dbTime

func TimeByNormalizedDerivativePower

func TimeByNormalizedDerivativePower(v, power float64) float64

func ValidateChannelName

func ValidateChannelName(name string) error

func ValidateUsername

func ValidateUsername(username string, blacklist map[string]bool) error

ValidateUsername checks if the username satisfies the constraints.

func VoteReaction

func VoteReaction(reaction ReactionType) bool

Types

type Activity

type Activity struct {
	ID        globalid.ID     `db:"id"          json:"-"`
	RPC       string          `db:"rpc"         json:"rpc"`
	Data      json.RawMessage `db:"data"        json:"data,omitempty"`
	UserID    globalid.ID     `db:"user_id"     json:"userID,omitempty"`
	Error     string          `db:"error"       json:"error,omitempty"`
	CreatedAt time.Time       `db:"created_at"  json:"-"`
}

type Announcement

type Announcement struct {
	ID      globalid.ID `db:"id" json:"id"`
	UserID  globalid.ID `db:"from_user" json:"userID"`
	CardID  globalid.ID `db:"card_id" json:"cardID"`
	Message string      `db:"message" json:"message"`
	//Action     string                 `db:"action" json:"action"`
	//ActionData AnnouncementActionData `db:"action_data" json:"actionData"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
	DeletedAt dbTime    `db:"deleted_at" json:"deletedAt"`
}

type AnnouncementActionData

type AnnouncementActionData map[string]string

func (*AnnouncementActionData) Scan

func (d *AnnouncementActionData) Scan(src interface{}) error

func (AnnouncementActionData) UnmarshalJSON

func (d AnnouncementActionData) UnmarshalJSON(b []byte) error

func (AnnouncementActionData) UnmarshalText

func (d AnnouncementActionData) UnmarshalText(text []byte) error

func (AnnouncementActionData) Value

type AnonymousAlias

type AnonymousAlias struct {
	ID               globalid.ID `db:"id"`
	DisplayName      string      `db:"display_name"`
	Username         string      `db:"username"`
	ProfileImagePath string      `db:"profile_image_path"`
	CreatedAt        time.Time   `db:"created_at"`
	UpdatedAt        time.Time   `db:"updated_at"`
	Inactive         bool        `db:"inactive"`
}

func (*AnonymousAlias) Author

func (al *AnonymousAlias) Author() *Author

func (*AnonymousAlias) TaggableUser

func (al *AnonymousAlias) TaggableUser() TaggableUser

type AttentionNode

type AttentionNode struct {
	ID                globalid.ID `json:"id"`
	CardRankTableSize int         `json:"cardRankTableSize"`
	FollowerCount     int         `json:"followerCount"`
	FollowingCount    int         `json:"followingCount"`
}

type Author

type Author struct {
	ID               globalid.ID `db:"id" json:"nodeId,omitempty"`
	DisplayName      string      `db:"display_name" json:"displayname"`
	Username         string      `db:"username" json:"username"`
	ProfileImagePath string      `db:"profile_image_path" json:"profileimg_path"`
	IsAnonymous      bool        `db:"is_anonymous" json:"isAnonymous"`
}

Author is what is used on the client and application side to display who wrote a card. This can be a user or an anonymous alias.

type Card

type Card struct {
	ID                  globalid.ID `db:"id"`
	OwnerID             globalid.ID `db:"owner_id"`
	AliasID             globalid.ID `db:"alias_id"`
	ThreadReplyID       globalid.ID `db:"thread_reply_id"`
	ThreadRootID        globalid.ID `db:"thread_root_id"`
	ChannelID           globalid.ID `db:"channel_id"`
	ThreadLevel         int         `db:"thread_level"`
	CoinsEarned         int         `db:"coins_earned"`
	Title               string      `db:"title"`
	Content             string      `db:"content"`
	URL                 string      `db:"url"`
	Anonymous           bool        `db:"anonymous"`
	BackgroundImagePath string      `db:"background_image_path"`
	BackgroundColor     string      `db:"background_color"`
	AuthorToAlias       IdentityMap `db:"author_to_alias"`
	IsIntroCard         bool        `db:"is_intro_card"`

	DeletedAt      dbTime    `db:"deleted_at"`
	ShadowbannedAt dbTime    `db:"shadowbanned_at"`
	CreatedAt      time.Time `db:"created_at"`
	UpdatedAt      time.Time `db:"updated_at"`

	Author *Author
}

func NewCard

func NewCard(id globalid.ID, title, content string) Card

func (*Card) Export

func (c *Card) Export() *CardView

func (*Card) IsComment

func (c *Card) IsComment() bool

IsComment returns whether the card is participating in a thread.

func (*Card) MarshalJSON

func (c *Card) MarshalJSON() ([]byte, error)

func (*Card) Reply

func (c *Card) Reply() bool

Reply returns whether this card is a reply to another card.

func (*Card) ReplyTo

func (c *Card) ReplyTo(card *Card)

ReplyTo ensures all the thread related fields are set accordingly to the threading model.

type CardReport

type CardReport struct {
	CardID globalid.ID `json:"cardID" db:"card_id"`
	UserID globalid.ID `json:"userID" db:"user_id"`

	CreatedAt time.Time `json:"createdAt" db:"created_at"`
	UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}

Mention is an @mention in a card's text.

type CardResponse

type CardResponse struct {
	Card             *CardView         `json:"card"`
	Author           *Author           `json:"author"`
	Channel          *Channel          `json:"channel,omitempty"`
	Viewer           *Viewer           `json:"viewer,omitempty"`
	Replies          int               `json:"replies"`
	FeaturedComments *FeaturedComments `json:"featuredComments,omitempty"`
	Reactions        *Reaction         `json:"reaction,omitempty"`
	ViewerReaction   *UserReaction     `json:"viewerReaction,omitempty"`
	Engagement       *Engagement       `json:"engagement,omitempty"`
	Score            int64             `json:"score"`
	Subscribed       bool              `json:"subscribed"`
	IsMine           bool              `json:"isMine,omitempty"`
	Vote             *VoteResponse     `json:"vote,omitempty"`
	LatestComment    *CardResponse     `json:"latestComment,omitempty"`
	RankingReason    string            `json:"rankingReason,omitempty"`
}

type CardView

type CardView struct {
	ID                  globalid.ID `json:"cardID"`
	ThreadReplyID       globalid.ID `json:"replyID,omitempty"`
	ThreadRootID        globalid.ID `json:"rootID,omitempty"`
	ThreadLevel         int         `json:"threadLevel"`
	CoinsEarned         int         `json:"coinsEarned"`
	Title               string      `json:"title"`
	Content             string      `json:"body"`
	URL                 string      `json:"url"`
	BackgroundColor     string      `json:"bgColor"`
	BackgroundImagePath string      `json:"background_image_path"`
	Anonymous           bool        `json:"anonymous"`
	CreatedAt           int64       `json:"post_timestamp"`
}

func (*CardView) ToCard

func (c *CardView) ToCard() *Card

type CardsResponse

type CardsResponse struct {
	Cards    []*CardResponse `json:"cards"`
	NextPage bool            `json:"hasNextPage"`
}

type Channel

type Channel struct {
	ID          globalid.ID `db:"id" json:"id"`
	Name        string      `db:"name" json:"name"`
	Description string      `db:"description" json:"description"`
	Private     bool        `db:"private" json:"private"`
	OwnerID     globalid.ID `db:"owner_id" json:"-"`
	Handle      string      `db:"handle" json:"-"`
	IsDefault   bool        `db:"is_default" json:"-"`

	CreatedAt time.Time `db:"created_at" json:"-"`
	UpdatedAt time.Time `db:"updated_at" json:"-"`
}

type ChannelEngagement

type ChannelEngagement struct {
	ChannelID       globalid.ID `db:"channel_id" json:"channelID"`
	TotalPosts      int         `db:"total_posts" json:"totalPosts"`
	TotalLikes      int         `db:"total_likes" json:"totalLikes"`
	TotalDislikes   int         `db:"total_dislikes" json:"totalDislikes"`
	TotalComments   int         `db:"total_comments" json:"totalComments"`
	TotalCommenters int         `db:"total_commenters" json:"totalCommenters"`
}

type ChannelSubscription

type ChannelSubscription struct {
	UserID     globalid.ID `db:"user_id"`
	ChannelID  globalid.ID `db:"channel_id"`
	Subscribed bool        `db:"subscribed"`
	Muted      bool        `db:"muted"`
	CreatedAt  time.Time   `db:"created_at" json:"-"`
}

type ChannelUserInfo

type ChannelUserInfo struct {
	ChannelID   globalid.ID `db:"channel_id" json:"channel"`
	MemberCount int         `db:"member_count" json:"memberCount"`
	Subscribed  bool        `db:"subscribed" json:"subscribed"`
}

type CoinBalances

type CoinBalances struct {
	CoinBalance          int64 `db:"coin_balance" json:"coinBalance"`
	TemporaryCoinBalance int64 `db:"temporary_coin_balance" json:"temporaryCoinBalance"`
}

type CoinReward

type CoinReward struct {
	ID             globalid.ID `db:"id"`
	UserID         globalid.ID `db:"user_id"`
	CoinsReceived  int64       `db:"coins_received"`
	LastRewardedOn dbTime      `db:"last_rewarded_on"`
	UpdatedAt      time.Time   `db:"updated_at"`
	CreatedAt      time.Time   `db:"created_at"`
}

type CoinTransaction

type CoinTransaction struct {
	ID globalid.ID `db:"id"`

	// ID of user paying coins (null means system generated coins)
	SourceUserID globalid.ID `db:"source_user_id"`
	// ID of user getting coins (null means paid to system)
	RecipientUserID globalid.ID `db:"recipient_user_id"`

	CardID    globalid.ID         `db:"card_id"`
	Amount    int                 `db:"amount"`
	Type      CoinTransactionType `db:"type"`
	UpdatedAt time.Time           `db:"updated_at"`
	CreatedAt time.Time           `db:"created_at"`
}

type CoinTransactionType

type CoinTransactionType string
const (
	// Initial balance
	CoinTransactionType_InitialBalance CoinTransactionType = "initialBalance"

	// Invite transactions
	// use a code when signing up
	CoinTransactionType_UsedInvite CoinTransactionType = "usedInvite"
	// someone uses your code to sign up
	CoinTransactionType_InviteAccepted CoinTransactionType = "inviteAccepted"

	// Post transactions
	// someone liked a post or comment you authored
	CoinTransactionType_LikeReceived CoinTransactionType = "likeReceived"
	// someone replied to a post or comment you authored
	CoinTransactionType_ReplyReceived CoinTransactionType = "replyReceived"
	// one of your posts performend well
	CoinTransactionType_FirstPostActivity CoinTransactionType = "firstPostActivity"
	// one of your posts performend well
	CoinTransactionType_PopularPost CoinTransactionType = "popularPost"
	// Someone tipped a post or comment you authored
	CoinTransactionType_TipGiven CoinTransactionType = "tipGiven"

	// Leaderboard transactions
	// placed on the leaderboard
	CoinTransactionType_LeaderboardFirst  CoinTransactionType = "leaderboardFirst"
	CoinTransactionType_LeaderboardSecond CoinTransactionType = "leaderboardSecond"
	CoinTransactionType_LeaderboardThird  CoinTransactionType = "leaderboardThird"
	CoinTransactionType_LeaderboardTopTen CoinTransactionType = "leaderboardTopTen"
	CoinTransactionType_LeaderboardRanked CoinTransactionType = "leaderboardRanked"

	// Alias transactions
	// Bought an alias to reply in someone else's thread with
	CoinTransactionType_BoughtThreadAlias CoinTransactionType = "boughtThreadAlias"
	// Bought an alias to post a new post with
	CoinTransactionType_BoughtPostAlias CoinTransactionType = "boughtPostAlias"

	// Channel transactins
	// Bought a channel
	CoinTransactionType_BoughtChannel CoinTransactionType = "boughtChannel"
)

type Condition

type Condition struct {
	ID        globalid.ID `db:"id"        json:"id"`
	Condition bool        `db:"condition" json:"condition"`
}

type ConfidenceData

type ConfidenceData struct {
	ID                  globalid.ID `json:"id"`
	UpvoteCount         int64       `json:"upvoteCount"`
	DownvoteCount       int64       `json:"downvoteCount"`
	CommentCount        int64       `json:"commentCount"`
	ScoreMod            float64     `json:"scoreMod"`
	ViewCount           int64       `json:"viewCount"`
	Goodness            float64     `json:"goodness"`
	EngagementScore     float64     `json:"engagementScore"`
	Confidence          float64     `json:"confidence"`
	ProbabilitySurfaced float64     `json:"probabilitySurfaced"`
	Rank                float64     `json:"rank"`
}

type Count

type Count struct {
	UserID globalid.ID `db:"user_id" json:"id"`
	Count  int         `db:"count"   json:"count"`
}

type DBTime

type DBTime struct {
	WEIRDNAME time.Time //TODO: rename this to Time after upgrading graphql
	Valid     bool
}

THIS IS SO FUCKING STUPID WHAT THE FUCK

func (DBTime) MarshalJSON

func (dt DBTime) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*DBTime) Scan

func (dt *DBTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*DBTime) UnmarshalJSON

func (dt *DBTime) UnmarshalJSON(b []byte) error

func (DBTime) Value

func (dt DBTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Device

type Device struct {
	Token    string
	Platform string
}

Device is the representation of the mobile device on which the mobile application is run. The platform specifies the operating system, i.e. Android, iOS.

func NewDevice

func NewDevice(token, platform string) *Device

type Devices

type Devices map[string]Device

func (*Devices) Scan

func (d *Devices) Scan(src interface{}) error

func (Devices) UnmarshalJSON

func (d Devices) UnmarshalJSON(b []byte) error

func (Devices) UnmarshalText

func (d Devices) UnmarshalText(text []byte) error

func (Devices) Value

func (d Devices) Value() (driver.Value, error)

type EngagedUser

type EngagedUser struct {
	CardID           globalid.ID  `db:"card_id"            json:"-"`
	UserID           globalid.ID  `db:"user_id"            json:"userID,omitempty"`
	AliasID          globalid.ID  `db:"alias_id"           json:"aliasID,omitempty"`
	ProfileImagePath string       `db:"profile_image_path" json:"profileImagePath"`
	Username         string       `db:"username"           json:"username"`
	DisplayName      string       `db:"display_name"       json:"displayName"`
	Type             ReactionType `db:"type"               json:"type"`
	CreatedAt        time.Time    `db:"created_at"         json:"-"`
}

type EngagedUsersByType

type EngagedUsersByType struct {
	Like    []*EngagedUser `json:"like"`
	Love    []*EngagedUser `json:"love"`
	Haha    []*EngagedUser `json:"haha"`
	Wow     []*EngagedUser `json:"wow"`
	Sad     []*EngagedUser `json:"sad"`
	Angry   []*EngagedUser `json:"angry"`
	Comment []*EngagedUser `json:"comment"`
	Tip     []*TippingUser `json:"tip"`
}

type Engagement

type Engagement struct {
	EngagedUsers       []*EngagedUser     `json:"engagedUsers"`
	EngagedUsersByType EngagedUsersByType `json:"engagedUsersByType"`
	Count              int                `json:"count"`
	CommentCount       int                `json:"commentCount"`
}

type ExportedNotification

type ExportedNotification struct {
	ID           globalid.ID `json:"id"`
	UserID       globalid.ID `json:"userID"`
	ImagePath    string      `json:"imagePath"`
	Message      string      `json:"message"`
	Timestamp    int64       `json:"timestamp"`
	Seen         bool        `json:"seen"`
	Opened       bool        `json:"opened"`
	ShowOnCardID globalid.ID `json:"showOnCardID,omitempty"`

	Type       string            `json:"type"`
	Action     string            `json:"action"`
	ActionData map[string]string `json:"actionData"`
}

func (*ExportedNotification) PlainMessage

func (eN *ExportedNotification) PlainMessage() string

type ExportedUser

type ExportedUser struct {
	ID               globalid.ID       `json:"nodeId,omitempty"`
	DisplayName      string            `json:"displayname"`
	FirstName        string            `json:"firstName,omitempty"`
	LastName         string            `json:"lastName,omitempty"`
	ProfileImagePath string            `json:"profileimg_path"`
	CoverImagePath   string            `json:"cover_image_path"`
	Bio              string            `json:"userBio"`
	Email            string            `json:"email,omitempty"`
	AllowEmail       bool              `json:"allow_email,omitempty"`
	Username         string            `json:"username"`
	Devices          map[string]Device `json:"devices,omitempty"`
	Admin            bool              `json:"admin,omitempty"`
	SearchKey        string            `json:"searchKey,omitempty"`
	BotchedSignup    bool              `json:"botchedSignup"`

	CoinBalance          int64 `json:"coinBalance,omitempty"`
	TemporaryCoinBalance int64 `json:"temporaryCoinBalance,omitempty"`
}

ExportedUser is a subset of user. This type exists in order to hide sensitive information.

func (*ExportedUser) Import

func (eu *ExportedUser) Import() *User

type FeatureSwitch

type FeatureSwitch struct {
	ID           globalid.ID  `db:"id"`
	Name         string       `db:"name"`
	State        string       `db:"state"` // off, testing, on
	TestingUsers testingusers `db:"testing_users"`
	CreatedAt    time.Time    `db:"created_at"`
	UpdatedAt    time.Time    `db:"updated_at"`
}

A link is a URI saved by a user on the client for later retrieval.

type FeaturedComment

type FeaturedComment struct {
	Card   *CardView `json:"card"`
	Author *Author   `json:"author"`
	New    bool      `json:"new"`
}

type FeaturedComments

type FeaturedComments struct {
	Comments []*FeaturedComment
}

type FeedCacheItem

type FeedCacheItem struct {
	UserID      globalid.ID `db:"user_id"`
	CardID      globalid.ID `db:"card_id"`
	FeedSession int         `db:"feed_session"`
	Position    int         `db:"position"`
	CreatedAt   time.Time   `db:"created_at"`
}

type FeedEntriesByID

type FeedEntriesByID map[globalid.ID]FeedEntry

type FeedEntry

type FeedEntry struct {
	ID               globalid.ID `db:"id"`
	UserID           globalid.ID `db:"user_id"`
	CardID           globalid.ID `db:"card_id"`
	FeedSessionIndex int         `db:"feed_session_index"`
	FeedSessionRank  int         `db:"feed_session_rank"`
	LastRankedAt     dbTime      `db:"last_ranked_at"`
	RerankedAt       dbTime      `db:"reranked_at"`
	LastNewContentAt dbTime      `db:"last_new_content_at"`
	CreatedAt        time.Time   `db:"created_at"`
	UpdatedAt        time.Time   `db:"updated_at"`
}

func ToFeedEntries

func ToFeedEntries(cacheItems []*FeedCacheItem, newCardIDs []globalid.ID) []*FeedEntry

func (FeedEntry) EarlierInFeed

func (entry FeedEntry) EarlierInFeed(than FeedEntry) bool

type IdentityMap

type IdentityMap map[globalid.ID]globalid.ID

func (*IdentityMap) Scan

func (d *IdentityMap) Scan(src interface{}) error

func (IdentityMap) Value

func (d IdentityMap) Value() (driver.Value, error)

type Image

type Image struct {
	Path string `json:"path"`
	X    int    `json:"x"`
	Y    int    `json:"y"`
}

Image is a representation of an image hosted on the static file server of the backend, i.e. card image, profile image.

func NewImage

func NewImage(path string, x, y int) *Image

type Images

type Images []Image

func (*Images) Scan

func (i *Images) Scan(src interface{}) error

func (Images) Value

func (i Images) Value() (driver.Value, error)

type Invite

type Invite struct {
	ID            globalid.ID `db:"id" json:"-"`
	NodeID        globalid.ID `db:"node_id" json:"node_id"`
	ChannelID     globalid.ID `db:"channel_id" json:"-"`
	Token         string      `db:"token" json:"token"`
	RemainingUses int         `db:"remaining_uses" json:"remaining_uses"`
	HideFromUser  bool        `db:"hide_from_user" json:"-"`
	SystemInvite  bool        `db:"system_invite" json:"-"`
	GroupID       globalid.ID `db:"group_id" json:"-"`
	CreatedAt     time.Time   `db:"created_at" json:"created_at"`
	UpdatedAt     time.Time   `db:"updated_at" json:"updated_at"`
}

func NewInvite

func NewInvite(nodeID globalid.ID) (*Invite, error)

NewInvite returns a new Invite instance.

func NewInviteWithParams

func NewInviteWithParams(id, nodeID globalid.ID, token string, createdAt, updatedAt time.Time) *Invite

type LeaderboardRank

type LeaderboardRank struct {
	UserID      globalid.ID `db:"user_id"`
	Rank        int64       `db:"rank"`
	CoinsEarned int64       `db:"coins_earned"`
	CreatedAt   time.Time   `db:"created_at"`
}
type Link struct {
	ID       globalid.ID `json:"id"`
	URL      string      `json:"url"`
	Username string      `json:"username"`
}

A link is a URI saved by a user on the client for later retrieval.

func NewLink(url, username string) *Link

NewLink returns a new link instance.

type Mention

type Mention struct {
	ID             globalid.ID `json:"id" db:"id"`
	InCard         globalid.ID `json:"inCard" db:"in_card"`
	MentionedUser  globalid.ID `json:"mentionedUser" db:"mentioned_user"`
	MentionedAlias globalid.ID `json:"mentionedAlias" db:"mentioned_alias"`

	CreatedAt time.Time `json:"createdAt" db:"created_at"`
	UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
	DeletedAt dbTime    `json:"deletedAt" db:"deleted_at"`
}

Mention is an @mention in a card's text.

type Notification

type Notification struct {
	ID            globalid.ID `db:"id"`
	UserID        globalid.ID `db:"user_id"`
	TargetID      globalid.ID `db:"target_id"`
	TargetAliasID globalid.ID `db:"target_alias_id"`
	Type          string      `db:"type"`
	SeenAt        dbTime      `db:"seen_at"`
	OpenedAt      dbTime      `db:"opened_at"`
	CreatedAt     time.Time   `db:"created_at"`
	UpdatedAt     time.Time   `db:"updated_at"`
	DeletedAt     dbTime      `db:"deleted_at"`
}

func (*Notification) MarshalJSON

func (n *Notification) MarshalJSON() ([]byte, error)

type NotificationComment

type NotificationComment struct {
	NotificationID globalid.ID `db:"notification_id"`
	CardID         globalid.ID `db:"card_id"`
	CreatedAt      time.Time   `db:"created_at"`
	UpdatedAt      time.Time   `db:"updated_at"`
}

type NotificationMention

type NotificationMention struct {
	NotificationID globalid.ID `json:"notificationID" db:"notification_id"`
	MentionID      globalid.ID `json:"mentionID" db:"mention_id"`
	CreatedAt      time.Time   `json:"createdAt" db:"created_at"`
	UpdatedAt      time.Time   `json:"updatedAt" db:"updated_at"`
}

links notifications and mentions

type OAuthAccount

type OAuthAccount struct {
	ID        globalid.ID `db:"id"`
	Provider  string      `db:"provider"`
	Subject   string      `db:"subject"`
	UserID    globalid.ID `db:"user_id"`
	CreatedAt time.Time   `db:"created_at"`
	UpdatedAt time.Time   `db:"updated_at"`
}

OAuthAccount tracks the user accounts which have been authorized via a OAuth 2.0 provider. This information is required in order to allow for subsequent authentications to identify the associated user again.

func NewOAuthAccount

func NewOAuthAccount(provider, subject string, userID globalid.ID) *OAuthAccount

NewOAuthAccount returns a new instance of OAuthAccount.

type PopularRankEntry

type PopularRankEntry struct {
	CardID                globalid.ID `db:"card_id"`
	Views                 int64       `db:"views"`
	UpvoteCount           int64       `db:"upvote_count"`
	DownvoteCount         int64       `db:"downvote_count"`
	CommentCount          int64       `db:"comment_count"`
	UniqueCommentersCount int64       `db:"unique_commenters_count"`
	ScoreMod              float64     `db:"score_mod"`

	CreatedAtTimestamp int64 `db:"created_at_timestamp"`
}

func (PopularRankEntry) Rank

func (entry PopularRankEntry) Rank() float64

type Reaction

type Reaction struct {
	ID        globalid.ID  `db:"id"            json:"id"`
	NodeID    globalid.ID  `db:"node_id"       json:"nodeID"`
	AliasID   globalid.ID  `db:"alias_id"      json:"aliasID,omitempty"`
	CardID    globalid.ID  `db:"card_id"       json:"cardID"`
	Reaction  ReactionType `db:"reaction"      json:"reaction"`
	CreatedAt time.Time    `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time    `db:"updated_at" json:"updatedAt"`
}

type ReactionType

type ReactionType string
const (
	Boost    ReactionType = "boost"
	Bury     ReactionType = "bury"
	HighFive ReactionType = "highfive"
	Pass     ReactionType = "pass"
	Seen     ReactionType = "seen"
	Comment  ReactionType = "comment"

	Like  ReactionType = "like"
	Love  ReactionType = "love"
	Haha  ReactionType = "haha"
	Wow   ReactionType = "wow"
	Sad   ReactionType = "sad"
	Angry ReactionType = "angry"

	UpVote   ReactionType = "up"
	DownVote ReactionType = "down"

	Post        ReactionType = "post"
	ScoreMod    ReactionType = "scoremod"
	Offset      ReactionType = "offset"
	UndoComment ReactionType = "undoComment"
)

func FromVote

func FromVote(vote VoteType) ReactionType

type ResetToken

type ResetToken struct {
	Token     globalid.ID `db:"-"          json:"token"`
	TokenHash string      `db:"token_hash" json:"tokenHash"`
	UserID    globalid.ID `db:"user_id"    json:"userID"`
	Expires   time.Time   `db:"expires"    json:"expires"`
	CreatedAt time.Time   `db:"created_at" json:"created_at"`
	UpdatedAt time.Time   `db:"updated_at" json:"updated_at"`
}

ResetToken represents a password reset triggered by a user.

func NewResetToken

func NewResetToken(userID globalid.ID) (*ResetToken, error)

NewResetToken returns a new instance of ResetToken.

func (*ResetToken) Valid

func (rt *ResetToken) Valid() error

Valid checks whether the reset password is still valid. A token to reset the password should only be valid for a fixed timespan.

type ScoreModification

type ScoreModification struct {
	ID        globalid.ID `db:"id"`
	CardID    globalid.ID `db:"card_id"`
	UserID    globalid.ID `db:"user_id"`
	Strength  float64     `db:"strength"`
	CreatedAt time.Time   `db:"created_at"`
	UpdatedAt time.Time   `db:"updated_at"`
}

type Session

type Session struct {
	ID        globalid.ID `db:"id"         json:"id"`
	UserID    globalid.ID `db:"user_id"    json:"userID,omitempty"`
	CreatedAt time.Time   `db:"created_at" json:"-"`
	UpdatedAt time.Time   `db:"updated_at" json:"-"`

	sync.RWMutex
	User *User `db:"user" json:"user,omitempty"`
}

Session identifies an authenticated user.

func NewSession

func NewSession(user *User) *Session

NewSession returns a new instance of session with a unique identifier.

func (*Session) Authenticated

func (s *Session) Authenticated() bool

func (*Session) GetUser

func (s *Session) GetUser() *User

User returns the user attached to the session. This method is thread-safe as it is accessed for every authenticated RPC action.

func (*Session) Identify

func (s *Session) Identify(user *User)

Identify attaches a user to the session. This method is thread-safe since the user it is accessed for every authenticated RPC actio

func (*Session) SetUser

func (s *Session) SetUser(user *User)

type Settings

type Settings struct {
	ID              int       `db:"id"               json:"-"`
	MaintenanceMode bool      `db:"maintenance_mode" json:"maintenanceMode"`
	SignupsFrozen   bool      `db:"signups_frozen"   json:"signupsFrozen"`
	CreatedAt       time.Time `db:"created_at"       json:"-"`
	UpdatedAt       time.Time `db:"updated_at"       json:"-"`
}

type Subscription

type Subscription struct {
	UserID    globalid.ID `json:"userID" db:"user_id"`
	CardID    globalid.ID `json:"cardID" db:"card_id"`
	Type      string      `json:"type" db:"type"`
	CreatedAt time.Time   `json:"createdAt" db:"created_at"`
	UpdatedAt time.Time   `json:"updatedAt" db:"updated_at"`
}

A link is a URI saved by a user on the client for later retrieval.

type TaggableUser

type TaggableUser struct {
	Username       string `json:"username"`
	DisplayName    string `json:"displayName"`
	ProfilePicture string `json:"profilePicture"`
	Anonymous      bool   `json:"anonymous"`
}

type TippingUser

type TippingUser struct {
	TipID            globalid.ID `db:"tip_id"             json:"tipID"`
	UserID           globalid.ID `db:"user_id"            json:"userID,omitempty"`
	AliasID          globalid.ID `db:"alias_id"           json:"aliasID,omitempty"`
	Anonymous        bool        `db:"anonymous"          json:"anonymous"`
	ProfileImagePath string      `db:"profile_image_path" json:"profileImagePath"`
	Username         string      `db:"username"           json:"username"`
	DisplayName      string      `db:"display_name"       json:"displayName"`
	Amount           int         `db:"amount"             json:"amount"`

	CreatedAt time.Time `db:"created_at"         json:"-"`
}

type User

type User struct {
	ID                globalid.ID `db:"id" json:"nodeId,omitempty"`
	DisplayName       string      `db:"display_name" json:"displayname"`
	FirstName         string      `db:"first_name" json:"firstName,omitempty"`
	LastName          string      `db:"last_name" json:"lastName,omitempty"`
	ProfileImagePath  string      `db:"profile_image_path" json:"profileimg_path"`
	CoverImagePath    string      `db:"cover_image_path" json:"cover_image_path"`
	Bio               string      `db:"bio" json:"userBio,omitempty"`
	Email             string      `db:"email" json:"email,omitempty"`
	PasswordHash      string      `db:"password_hash"`
	PasswordSalt      string      `db:"password_salt"`
	Username          string      `db:"username" json:"username"`
	Devices           Devices     `db:"devices" json:"devices,omitempty"`
	Admin             bool        `db:"admin" json:"admin,omitempty"`
	AllowEmail        bool        `db:"allow_email" json:"allow_email"`
	SearchKey         string      `db:"search_key" json:"searchKey,omitempty"`
	FeedUpdatedAt     dbTime      `db:"feed_updated_at"`
	JoinedFromInvite  globalid.ID `db:"joined_from_invite" json:"joinedFromInvite"`
	BotchedSignup     bool        `db:"botched_signup" json:"botchedSignup"`
	PossibleUninstall bool        `db:"possible_uninstall" json:"possibleUninstall"`
	GotDelayedInvites bool        `db:"got_delayed_invites" json:"-"`
	DisableFeed       bool        `db:"disable_feed" json:"-"`
	IsVerified        bool        `db:"is_verified" json:"-"`
	IsInternal        bool        `db:"is_internal" json:"-"`

	CoinBalance             int64  `db:"coin_balance" json:"-"`
	TemporaryCoinBalance    int64  `db:"temporary_coin_balance" json:"-"`
	CoinRewardLastUpdatedAt dbTime `db:"coin_reward_last_updated_at" json:"-"`

	IsDefault         bool      `db:"is_default" json:"-"`
	SeenIntroCards    bool      `db:"seen_intro_cards" json:"-"`
	CreatedAt         time.Time `db:"created_at"`
	UpdatedAt         time.Time `db:"updated_at" json:"updatedAt"`
	DeletedAt         dbTime    `db:"deleted_at"`
	FeedLastUpdatedAt dbTime    `db:"feed_last_updated_at"`
	ShadowbannedAt    dbTime    `db:"shadowbanned_at"`
	BlockedAt         dbTime    `db:"blocked_at" json:"blockedAt"`
}

func NewUser

func NewUser(nodeID globalid.ID, username, email, displayName string) *User

NewUser returns a new instance of User.

func (*User) Author

func (u *User) Author() *Author

func (*User) CanAffordCost

func (u *User) CanAffordCost(amount int64) bool

func (*User) Export

func (u *User) Export(id globalid.ID) *ExportedUser

Export exports the user by copying the existing fields to the target fields of ExportedUser. Based on the given user ID more or less fields are exported.

func (*User) MarshalJSON

func (u *User) MarshalJSON() ([]byte, error)

func (*User) PasswordMatches

func (u *User) PasswordMatches(password string) (bool, error)

PasswordMatches validates whether the given password is the same as the password stored in the user.

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword assigns a new password by hashing it.

func (*User) TaggableUser

func (u *User) TaggableUser() TaggableUser

type UserEngagement

type UserEngagement struct {
	UserID                 globalid.ID `json:"userID"`
	DaysActive             int         `json:"daysActive"`
	PostCount              int         `json:"postCount"`
	CommentCount           int         `json:"commentCount"`
	ReactedCount           int         `json:"reactedCount"`
	ReceivedReactionsCount int         `json:"receivedReactionsCount"`
	FollowedUsersCount     int         `json:"followedUsersCount"`
	FollowedCount          int         `json:"followedCount"`
	InvitedCount           int         `json:"invitedCount"`
	Score                  float64     `json:"score"`
}

type UserReaction

type UserReaction struct {
	UserID    globalid.ID      `db:"user_id"    json:"userID"`
	CardID    globalid.ID      `db:"card_id"    json:"cardID"`
	AliasID   globalid.ID      `db:"alias_id"   json:"aliasID,omitempty"`
	Type      UserReactionType `db:"type"       json:"type"`
	CreatedAt time.Time        `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time        `db:"updated_at" json:"updatedAt"`
}

func (*UserReaction) ToCardReaction

func (ur *UserReaction) ToCardReaction() *Reaction

func (*UserReaction) ToVoteResponse

func (ur *UserReaction) ToVoteResponse() *VoteResponse

type UserReactionType

type UserReactionType string
const (
	UserReactionsTableName = "user_reactions"

	ReactionLike    UserReactionType = "like"
	ReactionDislike UserReactionType = "dislike"
)

type UserTip

type UserTip struct {
	ID        globalid.ID `db:"id" json:"id"`
	UserID    globalid.ID `db:"user_id" json:"userID"`
	CardID    globalid.ID `db:"card_id" json:"cardID"`
	AliasID   globalid.ID `db:"alias_id" json:"aliasID"`
	Anonymous bool        `db:"anonymous" json:"anonymous"`
	Amount    int         `db:"amount"   json:"amount"`

	CreatedAt time.Time `db:"created_at" json:"-"`
	UpdatedAt time.Time `db:"updated_at" json:"-"`
}

type Viewer

type Viewer struct {
	AnonymousAlias         *AnonymousAlias `json:"alias,omitempty"`
	AnonymousAliasLastUsed bool            `json:"aliasLastUsed"`
}

type Vote

type Vote struct {
	CardID      globalid.ID `db:"card_id"        json:"cardID"`
	UserID      globalid.ID `db:"user_id"        json:"userID"`
	Strength    float64     `db:"strength"       json:"strength"`
	SentToGraph bool        `db:"sent_to_graph"  json:"sentToGraph"`
	Type        VoteType    `db:"type"           json:"type"`
	CreatedAt   time.Time   `db:"created_at"     json:"createdAt"`
}

type VoteJob

type VoteJob struct {
	ID        globalid.ID `db:"id"`
	NodeID    globalid.ID `db:"node_id"`
	CardID    globalid.ID `db:"card_id"`
	Strength  float64     `db:"strength"`
	Type      VoteType    `db:"type"`
	CreatedAt time.Time   `db:"created_at"`

	context.Context
	Cancel func()
}

func NewVoteJob

func NewVoteJob(c context.Context, nodeID, cardID globalid.ID, voteType VoteType, strength float64) *VoteJob

type VoteResponse

type VoteResponse struct {
	Type string `json:"type"`
}

type VoteType

type VoteType string
const (
	Up   VoteType = "up"
	Down VoteType = "down"
)

type WaitlistEntry

type WaitlistEntry struct {
	Email     string    `db:"email"      json:"email"`
	Name      string    `db:"name"       json:"name"`
	Comment   string    `db:"comment"    json:"comment"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
}

Jump to

Keyboard shortcuts

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