api

package
v0.0.0-...-9f3510a Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package api provides the Lemmy API client and data types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Error string `json:"error"`
}

APIError represents an error response from the Lemmy API.

type CertStatus

type CertStatus struct {
	// SelfSigned indicates the certificate is self-signed (not CA-signed).
	SelfSigned bool

	// Trusted indicates the certificate is trusted (CA-signed or TOFU-approved).
	Trusted bool

	// Fingerprint is the SHA-256 fingerprint of the certificate (hex with colons).
	Fingerprint string

	// ExpiresInDays is the number of days until the certificate expires.
	// A value of -1 indicates the expiry is unknown.
	ExpiresInDays int
}

CertStatus represents the security status of the current TLS connection.

func (CertStatus) HasWarning

func (c CertStatus) HasWarning() bool

HasWarning returns true if the certificate status requires a warning indicator.

func (CertStatus) IsUrgent

func (c CertStatus) IsUrgent() bool

IsUrgent returns true if the warning is urgent (expiring soon).

func (CertStatus) WarningText

func (c CertStatus) WarningText() string

WarningText returns the warning message to display in the header. Returns an empty string if no warning is needed.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an HTTP client for the Lemmy API.

func NewClient

func NewClient(instance string) *Client

NewClient creates a new Lemmy API client for the given instance. The instance should be the base URL without the API path, e.g., "https://lemmy.ml".

func NewClientWithTLS

func NewClientWithTLS(instance string, tlsCfg *TLSConfig) *Client

NewClientWithTLS creates a new Lemmy API client with custom TLS configuration.

func (*Client) CheckConnection

func (c *Client) CheckConnection(ctx context.Context) (*CertStatus, error)

CheckConnection performs a test connection to the instance and captures certificate information. Returns the certificate status and any error. This should be called before login to detect self-signed certificates.

func (*Client) CreateComment

func (c *Client) CreateComment(ctx context.Context, req CreateCommentRequest) (*CreateCommentResponse, error)

CreateComment creates a new comment on a post. If parentID is non-zero, the comment is a reply to that comment.

func (*Client) CreatePost

func (c *Client) CreatePost(ctx context.Context, req CreatePostRequest) (*CreatePostResponse, error)

CreatePost creates a new post in a community.

func (*Client) DeleteComment

func (c *Client) DeleteComment(ctx context.Context, req DeleteCommentRequest) (*DeleteCommentResponse, error)

DeleteComment marks a comment as deleted or restores it. Only the comment's creator can delete it. Setting deleted to true marks the comment as deleted; false restores it.

func (*Client) DeletePost

func (c *Client) DeletePost(ctx context.Context, req DeletePostRequest) (*DeletePostResponse, error)

DeletePost marks a post as deleted or restores it. Only the post's creator can delete it. Setting deleted to true marks the post as deleted; false restores it.

func (*Client) EditComment

func (c *Client) EditComment(ctx context.Context, req EditCommentRequest) (*EditCommentResponse, error)

EditComment updates an existing comment's content. Only the comment's creator can edit it.

func (*Client) EditPost

func (c *Client) EditPost(ctx context.Context, req EditPostRequest) (*EditPostResponse, error)

EditPost updates an existing post. Only the post's creator can edit it.

func (*Client) FollowCommunity

func (c *Client) FollowCommunity(ctx context.Context, req FollowCommunityRequest) (*FollowCommunityResponse, error)

FollowCommunity follows or unfollows a community. Set Follow to true to subscribe, false to unsubscribe.

func (*Client) GetCertStatus

func (c *Client) GetCertStatus() *CertStatus

GetCertStatus returns the certificate status from the last connection. Returns nil if no connection has been made or certificate info is unavailable.

func (*Client) GetComments

func (c *Client) GetComments(ctx context.Context, opts GetCommentsRequest) (*GetCommentsResponse, error)

GetComments retrieves comments for a post.

func (*Client) GetCommunity

func (c *Client) GetCommunity(ctx context.Context, req GetCommunityRequest) (*GetCommunityResponse, error)

GetCommunity retrieves a community by ID or name. Either ID or Name must be provided; ID takes precedence.

func (*Client) GetHostname

func (c *Client) GetHostname() string

GetHostname returns the hostname of the connected instance.

func (*Client) GetPersonDetails

func (c *Client) GetPersonDetails(ctx context.Context, req GetPersonDetailsRequest) (*GetPersonDetailsResponse, error)

GetPersonDetails retrieves details about a person including their posts and comments. Can filter to show only saved items by setting SavedOnly to true. Either PersonID or Username must be provided; PersonID takes precedence.

func (*Client) GetPost

func (c *Client) GetPost(ctx context.Context, postID int) (*GetPostResponse, error)

GetPost retrieves a single post by ID.

func (*Client) GetPosts

func (c *Client) GetPosts(ctx context.Context, opts GetPostsRequest) (*GetPostsResponse, error)

GetPosts retrieves a list of posts with the given options.

func (*Client) GetSite

func (c *Client) GetSite(ctx context.Context) (*GetSiteResponse, error)

GetSite fetches the site configuration from the Lemmy instance. This includes settings like whether downvotes are enabled.

func (*Client) IsAuthenticated

func (c *Client) IsAuthenticated() bool

IsAuthenticated returns true if the client has a JWT token set.

func (*Client) LikeComment

func (c *Client) LikeComment(ctx context.Context, commentID int, voteType VoteType) (*CommentLikeResponse, error)

LikeComment votes on a comment (upvote, downvote, or remove vote).

func (*Client) LikePost

func (c *Client) LikePost(ctx context.Context, postID int, voteType VoteType) (*PostLikeResponse, error)

LikePost votes on a post (upvote, downvote, or remove vote).

func (*Client) ListCommunities

func (c *Client) ListCommunities(ctx context.Context, opts ListCommunitiesRequest) (*ListCommunitiesResponse, error)

ListCommunities retrieves a list of communities with the given options.

func (*Client) Login

func (c *Client) Login(ctx context.Context, username, password string) error

Login authenticates the user and stores the JWT token. Returns an error if authentication fails.

func (*Client) ResolveObject

func (c *Client) ResolveObject(ctx context.Context, query string) (*ResolveObjectResponse, error)

ResolveObject resolves a federated object by URL or webfinger address. This can be used to fetch posts, comments, communities, or users from remote instances. The query can be a URL (e.g., https://lemmy.world/post/12345) or a webfinger address (e.g., [email protected] or @[email protected]).

func (*Client) SaveComment

func (c *Client) SaveComment(ctx context.Context, req SaveCommentRequest) (*SaveCommentResponse, error)

SaveComment saves or unsaves a comment (bookmark functionality). Set Save to true to save the comment, false to unsave it.

func (*Client) SavePost

func (c *Client) SavePost(ctx context.Context, req SavePostRequest) (*SavePostResponse, error)

SavePost saves or unsaves a post (bookmark functionality). Set Save to true to save the post, false to unsave it.

func (*Client) Search

func (c *Client) Search(ctx context.Context, opts SearchRequest) (*SearchResponse, error)

Search performs a search query against the Lemmy instance.

func (*Client) SetJWT

func (c *Client) SetJWT(jwt string)

SetJWT sets the authentication token for subsequent requests.

func (*Client) VerifyCertificateFingerprint

func (c *Client) VerifyCertificateFingerprint(trustedFingerprint string) bool

VerifyCertificateFingerprint checks if the current certificate matches a trusted fingerprint. Returns true if matched, false otherwise.

type Comment

type Comment struct {
	ID            int    `json:"id"`
	CreatorID     int    `json:"creator_id"`
	PostID        int    `json:"post_id"`
	Content       string `json:"content"`
	Path          string `json:"path"` // e.g., "0.123.456" for threading
	Published     string `json:"published"`
	Updated       string `json:"updated,omitempty"` // Set if comment was edited
	Deleted       bool   `json:"deleted"`
	Removed       bool   `json:"removed"`       // Removed by moderator
	Distinguished bool   `json:"distinguished"` // Pinned/distinguished by moderator
}

Comment represents a Lemmy comment.

type CommentCounts

type CommentCounts struct {
	Score      int `json:"score"`
	Upvotes    int `json:"upvotes"`
	Downvotes  int `json:"downvotes"`
	ChildCount int `json:"child_count"` // Number of direct child replies
}

CommentCounts contains aggregate counts for a comment.

type CommentLikeResponse

type CommentLikeResponse struct {
	CommentView CommentView `json:"comment_view"`
}

CommentLikeResponse represents the response from voting on a comment.

type CommentSortType

type CommentSortType string

CommentSortType represents the sort order for comments. Note: Lemmy uses different sort values for comments than for posts.

const (
	CommentSortHot CommentSortType = "Hot"
	CommentSortTop CommentSortType = "Top"
	CommentSortNew CommentSortType = "New"
	CommentSortOld CommentSortType = "Old"
)

type CommentView

type CommentView struct {
	Comment Comment       `json:"comment"`
	Creator Person        `json:"creator"`
	Counts  CommentCounts `json:"counts"`
	MyVote  *int          `json:"my_vote,omitempty"` // 1 = upvoted, -1 = downvoted, nil = no vote
	Saved   bool          `json:"saved"`             // Whether the current user has saved this comment
}

CommentView represents a comment with its related data.

type Community

type Community struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
	Icon        string `json:"icon,omitempty"`
	ActorID     string `json:"actor_id"`
	Local       bool   `json:"local"`
}

Community represents a Lemmy community.

type CommunityCounts

type CommunityCounts struct {
	Subscribers     int `json:"subscribers"`
	Posts           int `json:"posts"`
	Comments        int `json:"comments"`
	UsersActiveDay  int `json:"users_active_day"`
	UsersActiveWeek int `json:"users_active_week"`
}

CommunityCounts contains aggregate counts for a community.

type CommunitySortType

type CommunitySortType string

CommunitySortType represents the sort order for communities.

const (
	CommunitySortActive       CommunitySortType = "Active"
	CommunitySortHot          CommunitySortType = "Hot"
	CommunitySortNew          CommunitySortType = "New"
	CommunitySortOld          CommunitySortType = "Old"
	CommunitySortTopDay       CommunitySortType = "TopDay"
	CommunitySortTopWeek      CommunitySortType = "TopWeek"
	CommunitySortTopMonth     CommunitySortType = "TopMonth"
	CommunitySortTopYear      CommunitySortType = "TopYear"
	CommunitySortTopAll       CommunitySortType = "TopAll"
	CommunitySortMostComments CommunitySortType = "MostComments"
	CommunitySortNewComments  CommunitySortType = "NewComments"
)

type CommunityView

type CommunityView struct {
	Community  Community       `json:"community"`
	Subscribed SubscribedType  `json:"subscribed"`
	Blocked    bool            `json:"blocked"`
	Counts     CommunityCounts `json:"counts"`
}

CommunityView represents a community with its related data.

type CreateCommentLikeRequest

type CreateCommentLikeRequest struct {
	CommentID int `json:"comment_id"`
	Score     int `json:"score"` // 1 = upvote, -1 = downvote, 0 = remove vote
}

CreateCommentLikeRequest represents the request body for voting on a comment.

type CreateCommentRequest

type CreateCommentRequest struct {
	PostID   int    `json:"post_id"`
	ParentID int    `json:"parent_id,omitempty"`
	Content  string `json:"content"`
}

CreateCommentRequest represents the request body for creating a comment.

type CreateCommentResponse

type CreateCommentResponse struct {
	CommentView CommentView `json:"comment_view"`
}

CreateCommentResponse represents the response from creating a comment.

type CreatePostLikeRequest

type CreatePostLikeRequest struct {
	PostID int `json:"post_id"`
	Score  int `json:"score"` // 1 = upvote, -1 = downvote, 0 = remove vote
}

CreatePostLikeRequest represents the request body for voting on a post.

type CreatePostRequest

type CreatePostRequest struct {
	Name        string `json:"name"`
	CommunityID int    `json:"community_id"`
	URL         string `json:"url,omitempty"`
	Body        string `json:"body,omitempty"`
	NSFW        bool   `json:"nsfw,omitempty"`
}

CreatePostRequest represents the request body for creating a post.

type CreatePostResponse

type CreatePostResponse struct {
	PostView PostView `json:"post_view"`
}

CreatePostResponse represents the response from creating a post.

type DeleteCommentRequest

type DeleteCommentRequest struct {
	CommentID int  `json:"comment_id"`
	Deleted   bool `json:"deleted"`
}

DeleteCommentRequest represents the request body for deleting a comment. Setting Deleted to true marks the comment as deleted; false restores it.

type DeleteCommentResponse

type DeleteCommentResponse struct {
	CommentView CommentView `json:"comment_view"`
}

DeleteCommentResponse represents the response from deleting a comment.

type DeletePostRequest

type DeletePostRequest struct {
	PostID  int  `json:"post_id"`
	Deleted bool `json:"deleted"`
}

DeletePostRequest represents the request body for deleting a post. Setting Deleted to true marks the post as deleted; false restores it.

type DeletePostResponse

type DeletePostResponse struct {
	PostView PostView `json:"post_view"`
}

DeletePostResponse represents the response from deleting a post.

type EditCommentRequest

type EditCommentRequest struct {
	CommentID int    `json:"comment_id"`
	Content   string `json:"content"`
}

EditCommentRequest represents the request body for editing a comment.

type EditCommentResponse

type EditCommentResponse struct {
	CommentView CommentView `json:"comment_view"`
}

EditCommentResponse represents the response from editing a comment.

type EditPostRequest

type EditPostRequest struct {
	PostID int    `json:"post_id"`
	Name   string `json:"name,omitempty"`
	URL    string `json:"url,omitempty"`
	Body   string `json:"body,omitempty"`
	NSFW   bool   `json:"nsfw,omitempty"`
}

EditPostRequest represents the request body for editing a post.

type EditPostResponse

type EditPostResponse struct {
	PostView PostView `json:"post_view"`
}

EditPostResponse represents the response from editing a post.

type FollowCommunityRequest

type FollowCommunityRequest struct {
	CommunityID int  `json:"community_id"`
	Follow      bool `json:"follow"`
}

FollowCommunityRequest represents the request body for following/unfollowing a community.

type FollowCommunityResponse

type FollowCommunityResponse struct {
	CommunityView CommunityView `json:"community_view"`
}

FollowCommunityResponse represents the response from following/unfollowing a community.

type GetCommentsRequest

type GetCommentsRequest struct {
	PostID   int             `json:"post_id"`
	Sort     CommentSortType `json:"sort,omitempty"`
	MaxDepth int             `json:"max_depth,omitempty"`
	Limit    int             `json:"limit,omitempty"`
}

GetCommentsRequest represents the query parameters for listing comments.

type GetCommentsResponse

type GetCommentsResponse struct {
	Comments []CommentView `json:"comments"`
}

GetCommentsResponse represents the response from listing comments.

type GetCommunityRequest

type GetCommunityRequest struct {
	ID   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

GetCommunityRequest represents the query parameters for getting a community.

type GetCommunityResponse

type GetCommunityResponse struct {
	CommunityView CommunityView `json:"community_view"`
}

GetCommunityResponse represents the response from getting a community.

type GetPersonDetailsRequest

type GetPersonDetailsRequest struct {
	PersonID    int      `json:"person_id,omitempty"`
	Username    string   `json:"username,omitempty"`
	Sort        SortType `json:"sort,omitempty"`
	Page        int      `json:"page,omitempty"`
	Limit       int      `json:"limit,omitempty"`
	SavedOnly   bool     `json:"saved_only,omitempty"`
	CommunityID int      `json:"community_id,omitempty"`
}

GetPersonDetailsRequest represents the query parameters for getting a person's details.

type GetPersonDetailsResponse

type GetPersonDetailsResponse struct {
	PersonView PersonView    `json:"person_view"`
	Posts      []PostView    `json:"posts"`
	Comments   []CommentView `json:"comments"`
}

GetPersonDetailsResponse represents the response from getting a person's details.

type GetPostRequest

type GetPostRequest struct {
	ID int `json:"id"`
}

GetPostRequest represents the query parameters for getting a single post.

type GetPostResponse

type GetPostResponse struct {
	PostView PostView `json:"post_view"`
}

GetPostResponse represents the response from getting a single post.

type GetPostsRequest

type GetPostsRequest struct {
	Type        ListingType `json:"type_,omitempty"`
	Sort        SortType    `json:"sort,omitempty"`
	Page        int         `json:"page,omitempty"`
	Limit       int         `json:"limit,omitempty"`
	CommunityID int         `json:"community_id,omitempty"`
}

GetPostsRequest represents the query parameters for listing posts.

type GetPostsResponse

type GetPostsResponse struct {
	Posts []PostView `json:"posts"`
}

GetPostsResponse represents the response from listing posts.

type GetSiteResponse

type GetSiteResponse struct {
	SiteView   SiteView    `json:"site_view"`
	MyUserInfo *MyUserInfo `json:"my_user,omitempty"`
}

GetSiteResponse represents the response from fetching site configuration.

type ListCommunitiesRequest

type ListCommunitiesRequest struct {
	Type  ListingType       `json:"type_,omitempty"`
	Sort  CommunitySortType `json:"sort,omitempty"`
	Page  int               `json:"page,omitempty"`
	Limit int               `json:"limit,omitempty"`
}

ListCommunitiesRequest represents the query parameters for listing communities.

type ListCommunitiesResponse

type ListCommunitiesResponse struct {
	Communities []CommunityView `json:"communities"`
}

ListCommunitiesResponse represents the response from listing communities.

type ListingType

type ListingType string

ListingType represents the feed type filter.

const (
	ListingAll        ListingType = "All"
	ListingLocal      ListingType = "Local"
	ListingSubscribed ListingType = "Subscribed"
)

type LocalSite

type LocalSite struct {
	EnableDownvotes            bool   `json:"enable_downvotes"`
	EnableNSFW                 bool   `json:"enable_nsfw"`
	CommunityCreationAdminOnly bool   `json:"community_creation_admin_only"`
	RequireEmailVerification   bool   `json:"require_email_verification"`
	DefaultTheme               string `json:"default_theme,omitempty"`
}

LocalSite contains instance-specific settings.

type LocalUser

type LocalUser struct {
	ID       int  `json:"id"`
	PersonID int  `json:"person_id"`
	Admin    bool `json:"admin"`
}

LocalUser contains local user account settings.

type LocalUserView

type LocalUserView struct {
	LocalUser LocalUser `json:"local_user"`
	Person    Person    `json:"person"`
}

LocalUserView contains the local user and person information.

type LoginRequest

type LoginRequest struct {
	UsernameOrEmail string `json:"username_or_email"`
	Password        string `json:"password"`
}

LoginRequest represents the request body for user login.

type LoginResponse

type LoginResponse struct {
	JWT string `json:"jwt,omitempty"`
}

LoginResponse represents the response from user login.

type MyUserInfo

type MyUserInfo struct {
	LocalUserView LocalUserView `json:"local_user_view"`
}

MyUserInfo contains the current user's information when authenticated.

type Person

type Person struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	DisplayName string `json:"display_name,omitempty"`
	Avatar      string `json:"avatar,omitempty"`
	ActorID     string `json:"actor_id"`
	Local       bool   `json:"local"`
	Admin       bool   `json:"admin"`
	BotAccount  bool   `json:"bot_account"`
}

Person represents a Lemmy user.

type PersonCounts

type PersonCounts struct {
	PostCount    int `json:"post_count"`
	CommentCount int `json:"comment_count"`
}

PersonCounts contains aggregate counts for a person.

type PersonView

type PersonView struct {
	Person Person       `json:"person"`
	Counts PersonCounts `json:"counts"`
}

PersonView represents a person with their related data.

type Post

type Post struct {
	ID                int    `json:"id"`
	Name              string `json:"name"` // Post title
	URL               string `json:"url,omitempty"`
	Body              string `json:"body,omitempty"`
	CreatorID         int    `json:"creator_id"`
	CommunityID       int    `json:"community_id"`
	NSFW              bool   `json:"nsfw"`
	Published         string `json:"published"`
	ThumbnailURL      string `json:"thumbnail_url,omitempty"`
	Deleted           bool   `json:"deleted"`
	Removed           bool   `json:"removed"`            // Removed by moderator
	Locked            bool   `json:"locked"`             // Comments disabled
	FeaturedCommunity bool   `json:"featured_community"` // Pinned in community
	FeaturedLocal     bool   `json:"featured_local"`     // Pinned on instance front page
}

Post represents a Lemmy post.

type PostCounts

type PostCounts struct {
	Comments  int `json:"comments"`
	Score     int `json:"score"`
	Upvotes   int `json:"upvotes"`
	Downvotes int `json:"downvotes"`
}

PostCounts contains aggregate counts for a post.

type PostLikeResponse

type PostLikeResponse struct {
	PostView PostView `json:"post_view"`
}

PostLikeResponse represents the response from voting on a post.

type PostView

type PostView struct {
	Post               Post       `json:"post"`
	Creator            Person     `json:"creator"`
	Community          Community  `json:"community"`
	Counts             PostCounts `json:"counts"`
	MyVote             *int       `json:"my_vote,omitempty"`    // 1 = upvoted, -1 = downvoted, nil = no vote
	Saved              bool       `json:"saved"`                // Whether the current user has saved this post
	CreatorIsModerator bool       `json:"creator_is_moderator"` // Author is community moderator
	CreatorIsAdmin     bool       `json:"creator_is_admin"`     // Author is site admin (denormalised)
}

PostView represents a post with its related data.

type ResolveObjectRequest

type ResolveObjectRequest struct {
	Query string `json:"q"`
}

ResolveObjectRequest represents the query parameters for resolving a federated object. The query can be a URL, an ActivityPub ID, or a webfinger-style address (e.g., [email protected]).

type ResolveObjectResponse

type ResolveObjectResponse struct {
	Post      *PostView      `json:"post,omitempty"`
	Comment   *CommentView   `json:"comment,omitempty"`
	Community *CommunityView `json:"community,omitempty"`
	Person    *PersonView    `json:"person,omitempty"`
}

ResolveObjectResponse represents the response from resolving a federated object. Only one of the fields will be populated depending on what was resolved.

type SaveCommentRequest

type SaveCommentRequest struct {
	CommentID int  `json:"comment_id"`
	Save      bool `json:"save"`
}

SaveCommentRequest represents the request body for saving/unsaving a comment.

type SaveCommentResponse

type SaveCommentResponse struct {
	CommentView CommentView `json:"comment_view"`
}

SaveCommentResponse represents the response from saving/unsaving a comment.

type SavePostRequest

type SavePostRequest struct {
	PostID int  `json:"post_id"`
	Save   bool `json:"save"`
}

SavePostRequest represents the request body for saving/unsaving a post.

type SavePostResponse

type SavePostResponse struct {
	PostView PostView `json:"post_view"`
}

SavePostResponse represents the response from saving/unsaving a post.

type SearchRequest

type SearchRequest struct {
	Query       string      `json:"q"`
	Type        SearchType  `json:"type_,omitempty"`
	CommunityID int         `json:"community_id,omitempty"`
	Sort        SortType    `json:"sort,omitempty"`
	ListingType ListingType `json:"listing_type,omitempty"`
	Page        int         `json:"page,omitempty"`
	Limit       int         `json:"limit,omitempty"`
}

SearchRequest represents the query parameters for searching.

type SearchResponse

type SearchResponse struct {
	Type        SearchType    `json:"type_"`
	Posts       []PostView    `json:"posts"`
	Comments    []CommentView `json:"comments"`
	Communities []Community   `json:"communities"`
	Users       []Person      `json:"users"`
}

SearchResponse represents the response from a search query.

type SearchType

type SearchType string

SearchType represents the type of content to search for.

const (
	SearchTypePosts       SearchType = "Posts"
	SearchTypeComments    SearchType = "Comments"
	SearchTypeCommunities SearchType = "Communities"
	SearchTypeUsers       SearchType = "Users"
	SearchTypeAll         SearchType = "All"
)

type Site

type Site struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Icon        string `json:"icon,omitempty"`
	Banner      string `json:"banner,omitempty"`
}

Site contains basic site metadata.

type SiteView

type SiteView struct {
	LocalSite LocalSite `json:"local_site"`
	Site      Site      `json:"site"`
}

SiteView contains the site and local site configuration.

type SortType

type SortType string

SortType represents the sort order for posts.

const (
	SortHot     SortType = "Hot"
	SortNew     SortType = "New"
	SortTopDay  SortType = "TopDay"
	SortTopWeek SortType = "TopWeek"
	SortActive  SortType = "Active"
)

type SubscribedType

type SubscribedType string

SubscribedType represents a user's subscription status to a community.

const (
	SubscribedTypeSubscribed    SubscribedType = "Subscribed"
	SubscribedTypeNotSubscribed SubscribedType = "NotSubscribed"
	SubscribedTypePending       SubscribedType = "Pending"
)

type TLSConfig

type TLSConfig struct {
	// TrustedFingerprints maps hostnames to trusted certificate fingerprints (SHA-256).
	// Used for TOFU (Trust-On-First-Use) with self-signed certificates.
	TrustedFingerprints map[string]string

	// InsecureSkipVerify disables certificate verification entirely.
	// WARNING: This is insecure and should only be used for testing.
	InsecureSkipVerify bool
}

TLSConfig holds TLS-related configuration for the client.

type VoteType

type VoteType int

VoteType represents a vote direction.

const (
	// VoteNone removes an existing vote.
	VoteNone VoteType = iota
	// VoteUp represents an upvote.
	VoteUp
	// VoteDown represents a downvote.
	VoteDown
)

Jump to

Keyboard shortcuts

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