db

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: AGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxFields           = 25
	FieldNameMaxLength  = 100
	FieldEntriesLimit   = 100
	FieldEntryMaxLength = 100
)
View Source
const (
	MaxPrideFlags           = 500
	MaxPrideFlagTitleLength = 100
	MaxPrideFlagDescLength  = 500
)
View Source
const (
	ErrInvalidFlagID = errors.Sentinel("invalid flag ID")
	ErrFlagNotFound  = errors.Sentinel("flag not found")
)
View Source
const (
	MaxMemberCount      = 500
	MaxMemberNameLength = 100
)
View Source
const (
	ErrMemberNotFound  = errors.Sentinel("member not found")
	ErrMemberNameInUse = errors.Sentinel("member name already in use")
)
View Source
const (
	ActiveMonth = 30 * 24 * time.Hour
	ActiveWeek  = 7 * 24 * time.Hour
	ActiveDay   = 24 * time.Hour
)
View Source
const (
	ErrUserNotFound = errors.Sentinel("user not found")

	ErrUsernameTaken    = errors.Sentinel("username is already taken")
	ErrInvalidUsername  = errors.Sentinel("username contains invalid characters")
	ErrUsernameTooShort = errors.Sentinel("username is too short")
	ErrUsernameTooLong  = errors.Sentinel("username is too long")
	ErrBannedUsername   = errors.Sentinel("username is banned")
)
View Source
const (
	MaxUsernameLength    = 40
	MaxDisplayNameLength = 100
	MaxUserBioLength     = 1000
	MaxUserLinksLength   = 25
	MaxLinkLength        = 256
)
View Source
const (
	SelfDeleteAfter = 30 * 24 * time.Hour
	ModDeleteAfter  = 180 * 24 * time.Hour
)
View Source
const ErrFileTooLarge = errors.Sentinel("file to be converted exceeds maximum size")
View Source
const ErrInvalidContentType = errors.Sentinel("invalid avatar content type")
View Source
const ErrInvalidDataURI = errors.Sentinel("invalid data URI")
View Source
const ErrNoExport = errors.Sentinel("no data export exists")
View Source
const ErrNoInstanceApp = errors.Sentinel("instance doesn't have an app")
View Source
const ErrNoNotice = errors.Sentinel("no current notice")
View Source
const ErrNothingToUpdate = errors.Sentinel("nothing to update")
View Source
const ErrReportNotFound = errors.Sentinel("report not found")
View Source
const ErrTooManyInvites = errors.Sentinel("user invite limit reached")
View Source
const KeepExportTime = 7 * 24 * time.Hour
View Source
const MaxFlagInputSize = 512_000
View Source
const ReportPageSize = 100
View Source
const TokenExpiryTime = 3 * 30 * 24 * time.Hour

3 months, might be customizable later

Variables

This section is empty.

Functions

func MemberNameValid

func MemberNameValid(name string) bool

func NotNull

func NotNull[T any](slice []T) []T

NotNull is a little helper that returns an *empty slice* when the slice's length is 0. This is to prevent nil slices from being marshaled as JSON null

func UsernameValid

func UsernameValid(username string) (err error)

Types

type Badge

type Badge int32
const (
	BadgeAdmin Badge = 1 << 0
)

type CustomPreference

type CustomPreference struct {
	Icon      string         `json:"icon"`
	Tooltip   string         `json:"tooltip"`
	Size      PreferenceSize `json:"size"`
	Muted     bool           `json:"muted"`
	Favourite bool           `json:"favourite"`
}

func (CustomPreference) Validate

func (c CustomPreference) Validate() string

type CustomPreferences

type CustomPreferences = map[string]CustomPreference

type DB

type DB struct {
	*pgxpool.Pool

	Redis radix.Client

	TotalRequests prometheus.Counter
	// contains filtered or unexported fields
}

func New

func New() (*DB, error)

func (*DB) AccountFlags

func (db *DB) AccountFlags(ctx context.Context, userID xid.ID) (fs []PrideFlag, err error)

func (*DB) AckWarning

func (db *DB) AckWarning(ctx context.Context, userID xid.ID, id int64) (ok bool, err error)

func (*DB) ActiveUsers

func (db *DB) ActiveUsers(ctx context.Context, dur time.Duration) (numUsers int64, err error)

func (*DB) CleanUser

func (db *DB) CleanUser(ctx context.Context, id xid.ID) error

func (*DB) ConvertAvatar

func (db *DB) ConvertAvatar(data string) (
	webpOut *bytes.Buffer,
	jpgOut *bytes.Buffer,
	err error,
)

ConvertAvatar parses an avatar from a data URI, converts it to WebP and JPEG, and returns the results.

func (*DB) ConvertFlag

func (db *DB) ConvertFlag(data string) (webpOut *bytes.Buffer, err error)

ConvertFlag parses a flag from a data URI, converts it to WebP, and returns the result.

func (*DB) Counts added in v0.5.6

func (db *DB) Counts(ctx context.Context) (numUsers, numMembers, usersDay, usersWeek, usersMonth int64)

func (*DB) CreateExport

func (db *DB) CreateExport(ctx context.Context, userID xid.ID, filename string, file *bytes.Buffer) (de DataExport, err error)

func (*DB) CreateFediverseApp

func (db *DB) CreateFediverseApp(ctx context.Context, instance, instanceType, clientID, clientSecret string) (fa FediverseApp, err error)

func (*DB) CreateFlag

func (db *DB) CreateFlag(ctx context.Context, tx pgx.Tx, userID xid.ID, name, desc string) (f PrideFlag, err error)

func (*DB) CreateInvite

func (db *DB) CreateInvite(ctx context.Context, userID xid.ID) (i Invite, err error)

func (*DB) CreateMember

func (db *DB) CreateMember(
	ctx context.Context, tx pgx.Tx, userID xid.ID,
	name string, displayName *string, bio string, links []string,
) (m Member, err error)

CreateMember creates a member.

func (*DB) CreateNotice added in v0.6.2

func (db *DB) CreateNotice(ctx context.Context, notice string, start, end time.Time) (n Notice, err error)

func (*DB) CreateReport

func (db *DB) CreateReport(ctx context.Context, reporterID, userID xid.ID, memberID *xid.ID, reason string) (r Report, err error)

func (*DB) CreateUser

func (db *DB) CreateUser(ctx context.Context, tx pgx.Tx, username string) (u User, err error)

CreateUser creates a user with the given username.

func (*DB) CreateWarning

func (db *DB) CreateWarning(ctx context.Context, tx pgx.Tx, userID xid.ID, reason string) (w Warning, err error)

func (*DB) CurrentNotice added in v0.6.2

func (db *DB) CurrentNotice(ctx context.Context) (n Notice, err error)

func (*DB) DeleteExport

func (db *DB) DeleteExport(ctx context.Context, de DataExport) (err error)

func (*DB) DeleteFlag

func (db *DB) DeleteFlag(ctx context.Context, flagID xid.ID, hash string) error

func (*DB) DeleteMember

func (db *DB) DeleteMember(ctx context.Context, id xid.ID) (err error)

DeleteMember deletes a member by the given ID. This is irreversible.

func (*DB) DeleteMemberAvatar

func (db *DB) DeleteMemberAvatar(ctx context.Context, memberID xid.ID, hash string) error

func (*DB) DeleteUser

func (db *DB) DeleteUser(ctx context.Context, tx pgx.Tx, id xid.ID, selfDelete bool, reason string) error

func (*DB) DeleteUserAvatar

func (db *DB) DeleteUserAvatar(ctx context.Context, userID xid.ID, hash string) error

func (*DB) DeleteUserMembers

func (db *DB) DeleteUserMembers(ctx context.Context, tx pgx.Tx, id xid.ID) error

func (*DB) DiscordUser

func (db *DB) DiscordUser(ctx context.Context, discordID string) (u User, err error)

DiscordUser fetches a user by Discord user ID.

func (*DB) EditFlag

func (db *DB) EditFlag(ctx context.Context, tx pgx.Tx, flagID xid.ID, name, desc, hash *string) (f PrideFlag, err error)

func (*DB) FediverseApp

func (db *DB) FediverseApp(ctx context.Context, instance string) (fa FediverseApp, err error)

func (*DB) FediverseAppByID

func (db *DB) FediverseAppByID(ctx context.Context, id int64) (fa FediverseApp, err error)

func (*DB) FediverseUser

func (db *DB) FediverseUser(ctx context.Context, userID string, instanceAppID int64) (u User, err error)

func (*DB) FlagObject

func (db *DB) FlagObject(ctx context.Context, flagID xid.ID, hash string) (io.ReadCloser, error)

func (*DB) ForceDeleteUser

func (db *DB) ForceDeleteUser(ctx context.Context, id xid.ID) error

func (*DB) GetJSON

func (db *DB) GetJSON(ctx context.Context, key string, v any) error

GetJSON gets the given key as a JSON object.

func (*DB) GoogleUser

func (db *DB) GoogleUser(ctx context.Context, googleID string) (u User, err error)

GoogleUser fetches a user by Google user ID.

func (*DB) HasRecentExport

func (db *DB) HasRecentExport(ctx context.Context, userID xid.ID) (hasExport bool, err error)

func (*DB) InactiveUsers added in v0.6.3

func (db *DB) InactiveUsers(ctx context.Context, tx pgx.Tx) (us []User, err error)

InactiveUsers gets the list of inactive users from the database. "Inactive" is defined as: - not logged in for 30 days or more - no display name, bio, avatar, names, pronouns, profile links, or profile fields - no members

func (*DB) InvalidateAllTokens

func (db *DB) InvalidateAllTokens(ctx context.Context, tx pgx.Tx, userID xid.ID) error

func (*DB) InvalidateInvite

func (db *DB) InvalidateInvite(ctx context.Context, tx pgx.Tx, code string) (valid, alreadyUsed bool, err error)

func (*DB) InvalidateToken

func (db *DB) InvalidateToken(ctx context.Context, userID xid.ID, tokenID xid.ID) (t Token, err error)

func (*DB) Member

func (db *DB) Member(ctx context.Context, id xid.ID) (m Member, err error)

func (*DB) MemberAvatar

func (db *DB) MemberAvatar(ctx context.Context, memberID xid.ID, hash string) (io.ReadCloser, error)

func (*DB) MemberBySID

func (db *DB) MemberBySID(ctx context.Context, sid string) (u Member, err error)

MemberBySID gets a user by their short ID.

func (*DB) MemberBySnowflake added in v0.6.1

func (db *DB) MemberBySnowflake(ctx context.Context, id common.MemberID) (m Member, err error)

func (*DB) MemberCount

func (db *DB) MemberCount(ctx context.Context, userID xid.ID) (n int64, err error)

MemberCount returns the number of members that the given user has.

func (*DB) MemberFields

func (db *DB) MemberFields(ctx context.Context, id xid.ID) (fs []Field, err error)

MemberFields returns the fields associated with the given member ID.

func (*DB) MemberFlags

func (db *DB) MemberFlags(ctx context.Context, memberID xid.ID) (fs []MemberFlag, err error)

func (*DB) MultiCmd

func (db *DB) MultiCmd(ctx context.Context, cmds ...radix.Action) error

MultiCmd executes the given Redis commands in order. If any return an error, the function is aborted.

func (*DB) Notices added in v0.6.2

func (db *DB) Notices(ctx context.Context) (ns []Notice, err error)

func (*DB) Report

func (db *DB) Report(ctx context.Context, tx pgx.Tx, id int64) (r Report, err error)

func (*DB) Reports

func (db *DB) Reports(ctx context.Context, closed bool, before int) (rs []Report, err error)

func (*DB) ReportsByReporter

func (db *DB) ReportsByReporter(ctx context.Context, reporterID xid.ID, before int) (rs []Report, err error)

func (*DB) ReportsByUser

func (db *DB) ReportsByUser(ctx context.Context, userID xid.ID, before int) (rs []Report, err error)

func (*DB) RerollMemberSID

func (db *DB) RerollMemberSID(ctx context.Context, userID, memberID xid.ID) (newID string, err error)

func (*DB) RerollUserSID

func (db *DB) RerollUserSID(ctx context.Context, id xid.ID) (newID string, err error)

func (*DB) ResetUser

func (db *DB) ResetUser(ctx context.Context, tx pgx.Tx, id xid.ID) error

func (*DB) ResolveReport

func (db *DB) ResolveReport(ctx context.Context, ex Execer, id int64, adminID xid.ID, comment string) error

func (*DB) SaveToken

func (db *DB) SaveToken(ctx context.Context, userID xid.ID, tokenID xid.ID, apiOnly, readOnly bool) (t Token, err error)

SaveToken saves a token to the database.

func (*DB) SetJSON

func (db *DB) SetJSON(ctx context.Context, key string, v any, args ...string) error

SetJSON sets the given key to v marshaled as JSON.

func (*DB) SetMemberFields

func (db *DB) SetMemberFields(ctx context.Context, tx pgx.Tx, memberID xid.ID, fields []Field) (err error)

SetMemberFields updates the fields for the given member.

func (*DB) SetMemberFlags

func (db *DB) SetMemberFlags(ctx context.Context, tx pgx.Tx, memberID xid.ID, flags []xid.ID) (err error)

func (*DB) SetMemberNamesPronouns

func (db *DB) SetMemberNamesPronouns(ctx context.Context, tx pgx.Tx, memberID xid.ID, names []FieldEntry, pronouns []PronounEntry) (err error)

func (*DB) SetUserFields

func (db *DB) SetUserFields(ctx context.Context, tx pgx.Tx, userID xid.ID, fields []Field) (err error)

SetUserFields updates the fields for the given user.

func (*DB) SetUserFlags

func (db *DB) SetUserFlags(ctx context.Context, tx pgx.Tx, userID xid.ID, flags []xid.ID) (err error)

func (*DB) SetUserNamesPronouns

func (db *DB) SetUserNamesPronouns(ctx context.Context, tx pgx.Tx, userID xid.ID, names []FieldEntry, pronouns []PronounEntry) (err error)

func (*DB) TokenValid

func (db *DB) TokenValid(ctx context.Context, userID, tokenID xid.ID) (valid bool, err error)

func (*DB) Tokens

func (db *DB) Tokens(ctx context.Context, userID xid.ID) (ts []Token, err error)

func (*DB) TotalMemberCount

func (db *DB) TotalMemberCount(ctx context.Context) (numMembers int64, err error)

func (*DB) TotalUserCount

func (db *DB) TotalUserCount(ctx context.Context) (numUsers int64, err error)

func (*DB) TumblrUser

func (db *DB) TumblrUser(ctx context.Context, tumblrID string) (u User, err error)

TumblrUser fetches a user by Tumblr user ID.

func (*DB) UndoDeleteUser

func (db *DB) UndoDeleteUser(ctx context.Context, id xid.ID) error

func (*DB) UpdateActiveTime

func (db *DB) UpdateActiveTime(ctx context.Context, tx connOrTx, userID xid.ID) (err error)

UpdateActiveTime is called on create and update endpoints (PATCH /users/@me, POST/PATCH/DELETE /members)

func (*DB) UpdateMember

func (db *DB) UpdateMember(
	ctx context.Context,
	tx pgx.Tx, id xid.ID,
	name, displayName, bio *string,
	unlisted *bool,
	links *[]string,
	avatar *string,
) (m Member, err error)

func (*DB) UpdateUser

func (db *DB) UpdateUser(
	ctx context.Context,
	tx pgx.Tx, id xid.ID,
	displayName, bio *string,
	memberTitle *string, listPrivate *bool,
	links *[]string,
	avatar *string,
	timezone *string,
	customPreferences *CustomPreferences,
) (u User, err error)

func (*DB) UpdateUserSettings added in v0.6.1

func (db *DB) UpdateUserSettings(ctx context.Context, id xid.ID, us UserSettings) error

func (*DB) UpdateUsername

func (db *DB) UpdateUsername(ctx context.Context, tx pgx.Tx, id xid.ID, newName string) error

UpdateUsername validates the given username, then updates the given user's name to it if valid.

func (*DB) User

func (db *DB) User(ctx context.Context, id xid.ID) (u User, err error)

User gets a user by ID.

func (*DB) UserAvatar

func (db *DB) UserAvatar(ctx context.Context, userID xid.ID, hash string) (io.ReadCloser, error)

func (*DB) UserBySID

func (db *DB) UserBySID(ctx context.Context, sid string) (u User, err error)

UserBySID gets a user by their short ID.

func (*DB) UserBySnowflake added in v0.6.1

func (db *DB) UserBySnowflake(ctx context.Context, id common.UserID) (u User, err error)

UserBySnowflake gets a user by their snowflake ID.

func (*DB) UserExport

func (db *DB) UserExport(ctx context.Context, userID xid.ID) (de DataExport, err error)

func (*DB) UserFields

func (db *DB) UserFields(ctx context.Context, id xid.ID) (fs []Field, err error)

UserFields returns the fields associated with the given user ID.

func (*DB) UserFlag

func (db *DB) UserFlag(ctx context.Context, flagID xid.ID) (f PrideFlag, err error)

func (*DB) UserFlags

func (db *DB) UserFlags(ctx context.Context, userID xid.ID) (fs []UserFlag, err error)

func (*DB) UserInvites

func (db *DB) UserInvites(ctx context.Context, userID xid.ID) (is []Invite, err error)

func (*DB) UserMember

func (db *DB) UserMember(ctx context.Context, userID xid.ID, memberRef string) (m Member, err error)

UserMember returns a member scoped by user.

func (*DB) UserMembers

func (db *DB) UserMembers(ctx context.Context, userID xid.ID, showHidden bool) (ms []Member, err error)

UserMembers returns all of a user's members, sorted by name.

func (*DB) Username

func (db *DB) Username(ctx context.Context, name string) (u User, err error)

Username gets a user by username.

func (*DB) UsernameTaken

func (db *DB) UsernameTaken(ctx context.Context, username string) (valid, taken bool, err error)

UsernameTaken checks if the given username is already taken.

func (*DB) Warnings

func (db *DB) Warnings(ctx context.Context, userID xid.ID, unread bool) (ws []Warning, err error)

func (*DB) WriteFlag

func (db *DB) WriteFlag(ctx context.Context, flagID xid.ID, flag *bytes.Buffer) (hash string, err error)

func (*DB) WriteMemberAvatar

func (db *DB) WriteMemberAvatar(ctx context.Context,
	memberID xid.ID, webp *bytes.Buffer, jpeg *bytes.Buffer,
) (
	hash string, err error,
)

func (*DB) WriteUserAvatar

func (db *DB) WriteUserAvatar(ctx context.Context,
	userID xid.ID, webp *bytes.Buffer, jpeg *bytes.Buffer,
) (
	hash string, err error,
)

type DataExport

type DataExport struct {
	ID        int64
	UserID    xid.ID
	Filename  string
	CreatedAt time.Time
}

func (DataExport) Path

func (de DataExport) Path() string

type Execer

type Execer interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error)
}

type FediverseApp

type FediverseApp struct {
	ID int64
	// Instance is the instance's base API url, excluding schema
	Instance     string
	ClientID     string
	ClientSecret string
	InstanceType string
}

func (FediverseApp) ClientConfig

func (f FediverseApp) ClientConfig() *oauth2.Config

func (FediverseApp) MastodonCompatible

func (f FediverseApp) MastodonCompatible() bool

func (FediverseApp) Misskey

func (f FediverseApp) Misskey() bool

type Field

type Field struct {
	ID      int64        `json:"-"`
	Name    string       `json:"name"`
	Entries []FieldEntry `json:"entries"`
}

func (Field) Validate

func (f Field) Validate(custom CustomPreferences) string

Validate validates this field. If it is invalid, a non-empty string is returned as error message.

type FieldEntry

type FieldEntry struct {
	Value  string     `json:"value"`
	Status WordStatus `json:"status"`
}

func (FieldEntry) Validate

func (fe FieldEntry) Validate(custom CustomPreferences) string

type Invite

type Invite struct {
	UserID  xid.ID
	Code    string
	Created time.Time
	Used    bool
}

type Member

type Member struct {
	ID          xid.ID
	UserID      xid.ID
	SnowflakeID common.MemberID
	SID         string `db:"sid"`
	Name        string
	DisplayName *string
	Bio         *string
	Avatar      *string
	Links       []string
	Names       []FieldEntry
	Pronouns    []PronounEntry
	Unlisted    bool
}

type MemberFlag

type MemberFlag struct {
	ID       int64  `json:"-"`
	MemberID xid.ID `json:"-"`
	FlagID   xid.ID `json:"id"`

	Hash        string  `json:"hash"`
	Name        string  `json:"name"`
	Description *string `json:"description"`
}

type Notice added in v0.6.2

type Notice struct {
	ID        int
	Notice    string
	StartTime time.Time
	EndTime   time.Time
}

type PreferenceSize

type PreferenceSize string
const (
	PreferenceSizeLarge  PreferenceSize = "large"
	PreferenceSizeNormal PreferenceSize = "normal"
	PreferenceSizeSmall  PreferenceSize = "small"
)

type PrideFlag

type PrideFlag struct {
	ID          xid.ID        `json:"id"`
	SnowflakeID common.FlagID `json:"id_new"`
	UserID      xid.ID        `json:"-"`
	Hash        string        `json:"hash"`
	Name        string        `json:"name"`
	Description *string       `json:"description"`
}

type PronounEntry

type PronounEntry struct {
	Pronouns    string     `json:"pronouns"`
	DisplayText *string    `json:"display_text"`
	Status      WordStatus `json:"status"`
}

func (PronounEntry) String

func (p PronounEntry) String() string

func (PronounEntry) Validate

func (p PronounEntry) Validate(custom CustomPreferences) string

type Report

type Report struct {
	ID         int64   `json:"id"`
	UserID     xid.ID  `json:"user_id"`
	UserName   string  `json:"user_name"`
	MemberID   xid.ID  `json:"member_id"`
	MemberName *string `json:"member_name"`
	Reason     string  `json:"reason"`
	ReporterID xid.ID  `json:"reporter_id"`

	CreatedAt    time.Time  `json:"created_at"`
	ResolvedAt   *time.Time `json:"resolved_at"`
	AdminID      xid.ID     `json:"admin_id"`
	AdminComment *string    `json:"admin_comment"`
}

type Token

type Token struct {
	UserID      xid.ID
	TokenID     xid.ID
	Invalidated bool
	APIOnly     bool `db:"api_only"`
	ReadOnly    bool
	Created     time.Time
	Expires     time.Time
}

type User

type User struct {
	ID          xid.ID
	SnowflakeID common.UserID
	SID         string `db:"sid"`
	Username    string
	DisplayName *string
	Bio         *string
	MemberTitle *string
	LastActive  time.Time

	Avatar *string
	Links  []string

	Names    []FieldEntry
	Pronouns []PronounEntry

	Discord         *string
	DiscordUsername *string

	Fediverse         *string
	FediverseUsername *string
	FediverseAppID    *int64
	FediverseInstance *string

	Tumblr         *string
	TumblrUsername *string

	Google         *string
	GoogleUsername *string

	MaxInvites    int
	IsAdmin       bool
	ListPrivate   bool
	LastSIDReroll time.Time `db:"last_sid_reroll"`
	Timezone      *string
	Settings      UserSettings

	DeletedAt    *time.Time
	SelfDelete   *bool
	DeleteReason *string

	CustomPreferences CustomPreferences
}

func (User) NumProviders

func (u User) NumProviders() (numProviders int)

func (User) UTCOffset added in v0.5.8

func (u User) UTCOffset() (offset int, ok bool)

UTCOffset returns the user's UTC offset in seconds. If the user does not have a timezone set, `ok` is false.

func (*User) UnlinkDiscord

func (u *User) UnlinkDiscord(ctx context.Context, ex Execer) error

func (*User) UnlinkFedi

func (u *User) UnlinkFedi(ctx context.Context, ex Execer) error

func (*User) UnlinkGoogle

func (u *User) UnlinkGoogle(ctx context.Context, ex Execer) error

func (*User) UnlinkTumblr

func (u *User) UnlinkTumblr(ctx context.Context, ex Execer) error

func (*User) UpdateFromDiscord

func (u *User) UpdateFromDiscord(ctx context.Context, ex Execer, du *discordgo.User) error

func (*User) UpdateFromFedi

func (u *User) UpdateFromFedi(ctx context.Context, ex Execer, userID, username string, appID int64) error

func (*User) UpdateFromGoogle

func (u *User) UpdateFromGoogle(ctx context.Context, ex Execer, googleID, googleUsername string) error

func (*User) UpdateFromTumblr

func (u *User) UpdateFromTumblr(ctx context.Context, ex Execer, tumblrID, tumblrUsername string) error

type UserFlag

type UserFlag struct {
	ID     int64  `json:"-"`
	UserID xid.ID `json:"-"`
	FlagID xid.ID `json:"id"`

	Hash        string  `json:"hash"`
	Name        string  `json:"name"`
	Description *string `json:"description"`
}

type UserSettings added in v0.6.1

type UserSettings struct {
	ReadChangelog      string `json:"read_changelog"`
	ReadSettingsNotice string `json:"read_settings_notice"`
	ReadGlobalNotice   int    `json:"read_global_notice"`
}

type Warning

type Warning struct {
	ID        int64      `json:"id"`
	UserID    xid.ID     `json:"-"`
	Reason    string     `json:"reason"`
	CreatedAt time.Time  `json:"created_at"`
	ReadAt    *time.Time `json:"-"`
}

type WordStatus

type WordStatus string

func (*WordStatus) UnmarshalJSON

func (w *WordStatus) UnmarshalJSON(src []byte) error

func (WordStatus) Valid

func (w WordStatus) Valid(extra CustomPreferences) bool

Jump to

Keyboard shortcuts

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