models

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	// Unique identification of the app on the current device.
	// https://go-app.dev/reference#Context
	UUID string `json:"uuid"`

	// Timestamp of the subscription creation.
	TimeCreated time.Time `json:"time_created"`

	// Timestamp of the last notification sent through this device.
	TimeLastUsed time.Time `json:"time_last_used"`

	// List of labels for such device.
	Tags []string `json:"tags,omitempty"`

	// The very subscription struct/details.
	//Subscription app.NotificationSubscription `json:"subscription"`
	Subscription webpush.Subscription `json:"subscription"`
}

SubscriptionDevice

type Devices

type Devices struct {
	//Devices map[string]Device `json:"items"`
	Devices []Device `json:"items"`
}

Helper struct to see how the data is stored in the database.

type Options added in v0.43.0

type Options struct {
	// Active boolean indicates an activated user's account.
	// Map equivalent: active
	Active bool `json:"active" default:"true"`

	// GDPR consent, set to true because it is noted on the registration page so. No user data should
	// be saved if the boolean is false.
	// Map equivalent: gdpr
	GDPR bool `json:"gdpr" default:"true"`

	// Private boolean indicates a private user's account.
	// Map equivalent: private
	Private bool `json:"private" default:"false"`

	// AppBgMode string defines the colour mode of the app's background (light vs dark).
	// Map equivalent: uiDarkMode
	UIDarkMode bool `json:"app_bg_mode" default:"true"`

	// LiveMode is a feature allowing to show notifications about new posts
	// Map equivalent: liveMode
	LiveMode bool `json:"live_mode" default:"true"`

	// LocalTimeMode is a feature to show any post's datetime in the local time according to the client's/user's device setting.
	// Map equivalent: localTimeMode
	LocalTimeMode bool `json:"local_time_mode" default:"true"`
}

Options is an umbrella struct to hold all the booleans in one place.

type Poll

type Poll struct {
	// ID is an unique poll's identifier.
	ID string `json:"id"`

	// Question is to describe the main purpose of such poll.
	Question string `json:"question"`

	// OptionOne is the answer numero uno.
	OptionOne PollOption `json:"option_one"`

	// OptionTwo is the answer numero dos.
	OptionTwo PollOption `json:"option_two"`

	// OptionThree is the answer numero tres.
	OptionThree PollOption `json:"option_three"`

	// VodeList is the list of user nicknames voted on such poll already.
	Voted []string `json:"voted_list"`

	// Timestamp is an UNIX timestamp indication the poll's creation time; should be identical to the upstream post's Timestamp.
	Timestamp time.Time `json:"timestamp"`

	// Author is the back key to the user originally posting that poll.
	Author string `json:"author"`

	// ReactionCount counts the number of item's reactions.
	ReactionCount int `json:"reaction_count"`

	// Experimental fields.
	Hidden  bool     `json:"hidden"`
	Private bool     `json:"private"`
	Tags    []string `json:"tags"`
}

type PollOption

type PollOption struct {
	// Content describes the very content of such poll's option/answer.
	Content string `json:"content"`

	// Counter hold a number of votes being committed to such option.
	Counter int `json:"counter"`
}

type Post

type Post struct {
	// ID is an unique post's identificator.
	ID string `json:"id"`

	// Type describes the post's type --- post, poll, reply, img.
	Type string `json:"type"`

	// Nickname is a name of the post's author's name.
	Nickname string `json:"nickname"`

	// Content contains the very post's data to be shown as a text typed in by the author when created.
	Content string `json:"content"`

	// Figure hold the filename of the uploaded figure to post with some provided text.
	Figure string `json:"figure"`

	// Timestamp is an UNIX timestamp, indicates the creation time.
	Timestamp time.Time `json:"timestamp"`

	// PollID is an identification of the Poll structure/object.
	PollID string `json:"poll_id"`

	// ReplyTo is a reference key to another post, that is being replied to.
	ReplyTo   int    `json:"reply_to"`
	ReplyToID string `json:"reply_to_id"`

	// ReactionCount counts the number of item's reactions.
	ReactionCount int `json:"reaction_count"`

	// ReplyCount hold the count of replies for such post.
	ReplyCount int `json:"reply_count"`

	// Data is a helper field for the actual figure upload.
	Data []byte `json:"data"`
}

type Request

type Request struct {
	// Unique UUID.
	ID string `json:"id"`

	// User's name to easily fetch user's data from the database.
	Nickname string `json:"nickname"`

	// Requesting user's e-mail address.
	Email string `json:"email"`

	// Timestamp of the request generation, should expire in 24 hours after creation.
	CreatedAt time.Time `json:"created_at"`

	// Type is a helper field to differentiate the request's processor target.
	Type string `json:"type"`
}

type Token added in v0.43.0

type Token struct {
	// Unique hash = sha512 sum of refresh token's data.
	Hash string `json:"hash"`

	// User's name to easily fetch user's data from the database.
	Nickname string `json:"nickname"`

	// Timestamp of the refresh token's generation, should expire in 4 weeks after the initialization.
	CreatedAt time.Time `json:"created_at"`

	// Time to live, period of validity since the token creation.
	TTL time.Duration `json:"ttl"`
}

Token is a model structure which is to hold refresh token's properties.

type User

type User struct {
	// Nickname is a login name of such user.
	Nickname string `json:"nickname" binding:"required"`

	// FullName is the "genuine" name of such user.
	FullName string `json:"full_name"`

	// Passphrase is a hashed pass phrase string (binary form).
	Passphrase string `json:"passphrase,omitempty"`

	// PassphraseHex is a hashed pass phrase string (hexadecimal alphanumberic form).
	PassphraseHex string `json:"passphrase_hex,omitempty"`

	// Email is a primary user's e-mail address.
	Email string `json:"email,omitempty"`

	// Web is user's personal homepage.
	Web string `json:"web"`

	// AvatarURL is an URL to the user's custom profile picture.
	AvatarURL string `json:"avatar_url,omitempty"`

	// About is a description string of such user.
	About string `json:"about" default:"newbie"`

	// Options is an umbrella struct/map for the booleans.
	Options map[string]bool `json:"options"`

	// Active boolean indicates an activated user's account.
	Active bool `json:"active"`

	// Private boolean indicates a private user's account.
	Private bool `json:"private"`

	// FlowList is a string map of users, which posts should be added to one's flow page.
	FlowList map[string]bool `json:"flow_list,omitempty"`

	// ShadeList is a map of account/users to be shaded (soft-blocked) from following.
	ShadeList map[string]bool `json:"shade_list,omitempty"`

	// RequestList is a map of account requested to add this user to their flow --- used with the Private property.
	RequestList map[string]bool `json:"request_list,omitempty"`

	// FlowToggle is a single implementation of FlowList.
	FlowToggle string `json:"flow_toggle"`

	// Color is the user's UI color scheme.
	Color string `json:"color" default:"#000000"`

	// AppBgMode string defines the colour mode of the app's background (light vs dark).
	AppBgMode string `json:"app_bg_mode" default:"dark"`

	// RegisteredTime is an UNIX timestamp of the user's registration.
	RegisteredTime time.Time `json:"registered_time"`

	// LastLoginTime is an UNIX timestamp of the last user's successful log-in.
	LastLoginTime time.Time `json:"last_login_time"`

	// LastLoginTime is an UNIX timestamp of the last action performed by such user.
	LastActiveTime time.Time `json:"last_active_time"`

	// searched is a bool indicating a status for the search engine.
	Searched bool `json:"-" default:"true"`

	// GDPR consent, set to true because it is noted on the registration page so. No user data should
	// be saved if the boolean is false.
	GDPR bool `json:"gdpr" default:"true"`

	// AppBgMode string defines the colour mode of the app's background (light vs dark).
	UIDarkMode bool `json:"app_bg_mode" default:"true"`

	// LiveMode is a feature allowing to show notifications about new posts
	LiveMode bool `json:"live_mode" default:"true"`

	// LocalTimeMode is a feature to show any post's datetime in the local time according to the client's/user's device setting.
	LocalTimeMode bool `json:"local_time_mode" default:"true"`

	// Tags is an array of possible roles and other various attributes assigned to such user.
	Tags []string `json:"tags"`
}

type UserStat

type UserStat struct {
	// PostCount is a number of posts of such user.
	PostCount int `default:0`

	// ReactionCount tells the number of interactions (stars given).
	ReactionCount int `default:0`

	// FlowerCount is basically a number of followers.
	FlowerCount int `default:0`

	// ShadeCount is basically a number of blockers.
	ShadeCount int `default:0`

	// Searched is a special boolean used by the search engine to mark who is to be shown in search results.
	Searched bool `default:true`
}

UserStat is a helper struct to hold statistics about the whole app.

Jump to

Keyboard shortcuts

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