Documentation ¶
Overview ¶
The very models-related package containing all the in-database-saved types and structures.
Index ¶
- Variables
- type AuthServiceInterface
- type Device
- type Devices
- type Options
- type Poll
- type PollOption
- type PollRepositoryInterface
- type PollServiceInterface
- type Post
- type PostRepositoryInterface
- type PostServiceInterface
- type Request
- type RequestRepositoryInterface
- type StatServiceInterface
- type Stub
- type SubscriptionRepositoryInterface
- type Token
- type TokenRepositoryInterface
- type TokenServiceInterface
- type User
- type UserGenericMap
- type UserOptionsMap
- type UserRepositoryInterface
- type UserServiceInterface
- type UserStat
Constants ¶
This section is empty.
Variables ¶
var DefaultUserOptionsMap = UserOptionsMap{ "active": false, "gdpr": true, "private": false, "uiDarkMode": true, "liveMode": true, "localTimeMode": true, }
DefaultUserOptionsMap can be assigned directly at the register time to a new user, or to be used in the Options migrations as a template.
Functions ¶
This section is empty.
Types ¶
type AuthServiceInterface ¶ added in v0.44.23
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 ¶
Helper struct to see how the data is stored in the database. The map key is an userID parameter.
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 int64 `json:"reaction_count"` // Experimental fields. Hidden bool `json:"hidden"` Private bool `json:"private"` Tags []string `json:"tags"` }
type PollOption ¶
type PollRepositoryInterface ¶ added in v0.44.22
type PollServiceInterface ¶ added in v0.44.22
type PollServiceInterface interface { Create(ctx context.Context, poll *Poll) error Update(ctx context.Context, poll *Poll) error Delete(ctx context.Context, pollID string) error FindAll(ctx context.Context) (*map[string]Poll, *User, error) FindByID(ctx context.Context, pollID string) (*Poll, *User, error) }
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 int64 `json:"reaction_count"` // ReplyCount hold the count of replies for such post. ReplyCount int64 `json:"reply_count"` // Data is a helper field for the actual figure upload. Data []byte `json:"data"` }
type PostRepositoryInterface ¶ added in v0.44.22
type PostServiceInterface ¶ added in v0.44.26
type PostServiceInterface interface { Create(ctx context.Context, post *Post) error Update(ctx context.Context, post *Post) error Delete(ctx context.Context, postID string) error FindAll(ctx context.Context) (*map[string]Post, *User, error) //FindPage(ctx context.Context, opts interface{}) (*map[string]Post, *map[string]User, error) FindByID(ctx context.Context, postID string) (*Post, *User, error) }
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 RequestRepositoryInterface ¶ added in v0.44.23
type StatServiceInterface ¶ added in v0.44.24
type Stub ¶ added in v0.44.39
type Stub struct{}
Stub is a stuffing structure type mainly used to patch the Swagger documentation notation for empty structs. The example usage could be a following one:
@Success 200 {object} common.APIResponse{data=models.Stub}
type SubscriptionRepositoryInterface ¶ added in v0.44.23
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 TokenRepositoryInterface ¶ added in v0.44.23
type TokenServiceInterface ¶ added in v0.44.23
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 UserOptionsMap `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 UserGenericMap `json:"flow_list,omitempty"` // ShadeList is a map of account/users to be shaded (soft-blocked) from following. ShadeList UserGenericMap `json:"shade_list,omitempty"` // RequestList is a map of account requested to add this user to their flow --- used with the Private property. RequestList UserGenericMap `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:"-"` // 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"` // AppBgMode string defines the colour mode of the app's background (light vs dark). UIDarkMode bool `json:"app_bg_mode"` // LiveMode is a feature allowing to show notifications about new posts LiveMode bool `json:"live_mode"` // 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"` // Devices array holds the subscribed devices. Devices are not exported as the subscribed devices are stored separated. Devices []Device `json"-"` // Tags is an array of possible roles and other various attributes assigned to such user. Tags []string `json:"tags"` }
type UserGenericMap ¶ added in v0.44.19
UserGenericMap is used for user lists mainly at the moment.
type UserOptionsMap ¶ added in v0.44.19
type UserRepositoryInterface ¶ added in v0.44.22
type UserServiceInterface ¶ added in v0.44.23
type UserServiceInterface interface { Create(ctx context.Context, user *User) error Activate(ctx context.Context, userID string) error Update(ctx context.Context, request interface{}) error UpdateAvatar(ctx context.Context, request interface{}) (*string, error) ProcessPassphraseRequest(ctx context.Context, request interface{}) error Delete(ctx context.Context, userID string) error FindAll(ctx context.Context) (*map[string]User, error) FindByID(ctx context.Context, userID string) (*User, error) FindPostsByID(ctx context.Context, userID string) (*map[string]Post, *map[string]User, error) }
type UserStat ¶
type UserStat struct { // PostCount is a number of posts of such user. PostCount int64 `default:0` // ReactionCount tells the number of interactions (stars given). ReactionCount int64 `default:0` // FlowerCount is basically a number of followers. FlowerCount int64 `default:0` // ShadeCount is basically a number of blockers. ShadeCount int64 `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.