models

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package models defines the shared entity and API types used by the Uncord server and clients. Both Go and TypeScript implementations import these types as the single source of truth for API request and response shapes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthResponse

type AuthResponse struct {
	User         User   `json:"user"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

AuthResponse is the response body for register and login endpoints.

type Category added in v0.2.3

type Category struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Position  int    `json:"position"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

Category represents a channel category returned by the API.

type Channel added in v0.2.3

type Channel struct {
	ID              string  `json:"id"`
	CategoryID      *string `json:"category_id"`
	Name            string  `json:"name"`
	Type            string  `json:"type"`
	Topic           string  `json:"topic"`
	Position        int     `json:"position"`
	SlowmodeSeconds int     `json:"slowmode_seconds"`
	NSFW            bool    `json:"nsfw"`
	CreatedAt       string  `json:"created_at"`
	UpdatedAt       string  `json:"updated_at"`
}

Channel represents a channel returned by the API.

type CreateCategoryRequest added in v0.2.3

type CreateCategoryRequest struct {
	Name string `json:"name"`
}

CreateCategoryRequest is the body for POST /api/v1/server/categories.

type CreateChannelRequest added in v0.2.3

type CreateChannelRequest struct {
	Name            string  `json:"name"`
	Type            *string `json:"type"`
	CategoryID      *string `json:"category_id"`
	Topic           *string `json:"topic"`
	SlowmodeSeconds *int    `json:"slowmode_seconds"`
	NSFW            *bool   `json:"nsfw"`
}

CreateChannelRequest is the body for POST /api/v1/server/channels.

type CreateRoleRequest added in v0.2.6

type CreateRoleRequest struct {
	Name        string `json:"name"`
	Colour      *int   `json:"colour"`
	Permissions *int64 `json:"permissions"`
	Hoist       *bool  `json:"hoist"`
}

CreateRoleRequest is the body for POST /api/v1/server/roles.

type DeleteAccountRequest added in v0.2.5

type DeleteAccountRequest struct {
	Password string `json:"password"`
}

DeleteAccountRequest is the JSON body for DELETE /api/v1/users/@me. The authenticated user's password is required to confirm the irreversible account deletion.

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

LoginRequest is the JSON body for POST /api/v1/auth/login.

type MFAConfirmRequest added in v0.2.4

type MFAConfirmRequest struct {
	Code string `json:"code"`
}

MFAConfirmRequest is the JSON body for POST /api/v1/users/@me/mfa/confirm. The code is a six-digit TOTP code from the user's authenticator app, proving they successfully saved the secret.

type MFAConfirmResponse added in v0.2.4

type MFAConfirmResponse struct {
	RecoveryCodes []string `json:"recovery_codes"`
}

MFAConfirmResponse is the response for the MFA confirm endpoint, containing the one-time-use recovery codes that the user must store securely.

type MFADisableRequest added in v0.2.4

type MFADisableRequest struct {
	Password string `json:"password"`
	Code     string `json:"code"`
}

MFADisableRequest is the JSON body for POST /api/v1/users/@me/mfa/disable. Both password and a valid TOTP code are required to disable MFA.

type MFAEnableRequest added in v0.2.4

type MFAEnableRequest struct {
	Password string `json:"password"`
}

MFAEnableRequest is the JSON body for POST /api/v1/users/@me/mfa/enable. The password field confirms the user's identity before generating TOTP credentials.

type MFARegenerateCodesRequest added in v0.2.4

type MFARegenerateCodesRequest struct {
	Password string `json:"password"`
}

MFARegenerateCodesRequest is the JSON body for POST /api/v1/users/@me/mfa/recovery-codes.

type MFARegenerateCodesResponse added in v0.2.4

type MFARegenerateCodesResponse struct {
	RecoveryCodes []string `json:"recovery_codes"`
}

MFARegenerateCodesResponse is the response for the recovery code regeneration endpoint.

type MFARequiredResponse added in v0.2.4

type MFARequiredResponse struct {
	MFARequired bool   `json:"mfa_required"`
	Ticket      string `json:"ticket"`
}

MFARequiredResponse is the response when login succeeds but MFA verification is needed. The ticket is a single-use opaque token that the client must present to the MFA verify endpoint.

type MFASetupResponse added in v0.2.4

type MFASetupResponse struct {
	Secret string `json:"secret"`
	URI    string `json:"uri"`
}

MFASetupResponse is the response for the MFA enable endpoint, containing the TOTP secret and provisioning URI for authenticator app registration.

type MFAVerifyRequest added in v0.2.4

type MFAVerifyRequest struct {
	Ticket string `json:"ticket"`
	Code   string `json:"code"`
}

MFAVerifyRequest is the JSON body for POST /api/v1/auth/mfa/verify.

type MessageResponse

type MessageResponse struct {
	Message string `json:"message"`
}

MessageResponse is a generic response containing a status message.

type RefreshRequest

type RefreshRequest struct {
	RefreshToken string `json:"refresh_token"`
}

RefreshRequest is the JSON body for POST /api/v1/auth/refresh.

type RegisterRequest

type RegisterRequest struct {
	Email    string `json:"email"`
	Username string `json:"username"`
	Password string `json:"password"`
}

RegisterRequest is the JSON body for POST /api/v1/auth/register.

type Role added in v0.2.6

type Role struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Colour      int    `json:"colour"`
	Position    int    `json:"position"`
	Hoist       bool   `json:"hoist"`
	Permissions int64  `json:"permissions"`
	IsEveryone  bool   `json:"is_everyone"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at"`
}

Role represents a server role returned by the API.

type ServerConfig added in v0.2.2

type ServerConfig struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	IconKey     *string `json:"icon_key"`
	BannerKey   *string `json:"banner_key"`
	OwnerID     string  `json:"owner_id"`
	CreatedAt   string  `json:"created_at"`
	UpdatedAt   string  `json:"updated_at"`
}

ServerConfig represents the server configuration returned by the API.

type TokenPairResponse

type TokenPairResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

TokenPairResponse is the response body for the refresh endpoint.

type UpdateCategoryRequest added in v0.2.3

type UpdateCategoryRequest struct {
	Name     *string `json:"name"`
	Position *int    `json:"position"`
}

UpdateCategoryRequest is the body for PATCH /api/v1/categories/:categoryID.

type UpdateChannelRequest added in v0.2.3

type UpdateChannelRequest struct {
	Name            *string `json:"name"`
	CategoryID      *string `json:"category_id"`
	Topic           *string `json:"topic"`
	Position        *int    `json:"position"`
	SlowmodeSeconds *int    `json:"slowmode_seconds"`
	NSFW            *bool   `json:"nsfw"`
}

UpdateChannelRequest is the body for PATCH /api/v1/channels/:channelID.

type UpdateRoleRequest added in v0.2.6

type UpdateRoleRequest struct {
	Name        *string `json:"name"`
	Colour      *int    `json:"colour"`
	Position    *int    `json:"position"`
	Permissions *int64  `json:"permissions"`
	Hoist       *bool   `json:"hoist"`
}

UpdateRoleRequest is the body for PATCH /api/v1/server/roles/:roleID.

type UpdateServerConfigRequest added in v0.2.2

type UpdateServerConfigRequest struct {
	Name        *string `json:"name"`
	Description *string `json:"description"`
	IconKey     *string `json:"icon_key"`
	BannerKey   *string `json:"banner_key"`
}

UpdateServerConfigRequest is the body for PATCH /api/v1/server.

type UpdateUserRequest added in v0.2.2

type UpdateUserRequest struct {
	DisplayName          *string `json:"display_name"`
	AvatarKey            *string `json:"avatar_key"`
	Pronouns             *string `json:"pronouns"`
	BannerKey            *string `json:"banner_key"`
	About                *string `json:"about"`
	ThemeColourPrimary   *int    `json:"theme_colour_primary"`
	ThemeColourSecondary *int    `json:"theme_colour_secondary"`
}

UpdateUserRequest is the body for PATCH /api/v1/users/@me.

type User

type User struct {
	ID                   string  `json:"id"`
	Email                string  `json:"email"`
	Username             string  `json:"username"`
	DisplayName          *string `json:"display_name"`
	AvatarKey            *string `json:"avatar_key"`
	Pronouns             *string `json:"pronouns"`
	BannerKey            *string `json:"banner_key"`
	About                *string `json:"about"`
	ThemeColourPrimary   *int    `json:"theme_colour_primary"`
	ThemeColourSecondary *int    `json:"theme_colour_secondary"`
	MFAEnabled           bool    `json:"mfa_enabled"`
	EmailVerified        bool    `json:"email_verified"`
}

User represents the public user profile returned by the API.

type VerifyEmailRequest

type VerifyEmailRequest struct {
	Token string `json:"token"`
}

VerifyEmailRequest is the JSON body for POST /api/v1/auth/verify-email.

type VerifyPasswordRequest added in v0.2.4

type VerifyPasswordRequest struct {
	Password string `json:"password"`
}

VerifyPasswordRequest is the JSON body for POST /api/v1/auth/verify-password. The authenticated user's password is verified without performing any other action, allowing clients to gate sensitive workflows behind a password prompt.

Jump to

Keyboard shortcuts

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