web

package
v1.7.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetActor

func GetActor(actor string, conf *util.AppConfig) (error, string)

func GetFollowersCollection added in v1.2.2

func GetFollowersCollection(actor string, conf *util.AppConfig, followerURIs []string) string

GetFollowersCollection returns an ActivityPub OrderedCollection of followers Always uses paging for compatibility with Mastodon and other servers

func GetFollowersPage added in v1.2.2

func GetFollowersPage(actor string, conf *util.AppConfig, followerURIs []string, page int) string

GetFollowersPage returns an OrderedCollectionPage for followers

func GetFollowingCollection added in v1.2.2

func GetFollowingCollection(actor string, conf *util.AppConfig, followingURIs []string) string

GetFollowingCollection returns an ActivityPub OrderedCollection of following Always uses paging for compatibility with Mastodon and other servers

func GetFollowingPage added in v1.2.2

func GetFollowingPage(actor string, conf *util.AppConfig, followingURIs []string, page int) string

GetFollowingPage returns an OrderedCollectionPage for following

func GetNodeInfo20 added in v1.2.2

func GetNodeInfo20(conf *util.AppConfig) string

GetNodeInfo20 returns a NodeInfo 2.0 JSON response

func GetNodeInfo21 added in v1.6.1

func GetNodeInfo21(conf *util.AppConfig) string

GetNodeInfo21 returns a NodeInfo 2.1 JSON response NodeInfo 2.1 adds repository and homepage fields to software

func GetNoteObject

func GetNoteObject(noteId uuid.UUID, conf *util.AppConfig) (error, string)

GetNoteObject returns a Note object as ActivityPub JSON

func GetOutbox added in v1.1.0

func GetOutbox(actor string, page int, conf *util.AppConfig) (error, string)

GetOutbox returns an ActivityPub OrderedCollection of a user's public posts This allows remote servers to discover posts without following the user

func GetRSS

func GetRSS(conf *util.AppConfig, username string) (string, error)

func GetRSSItem

func GetRSSItem(conf *util.AppConfig, id uuid.UUID) (string, error)

func GetWebFingerNotFound

func GetWebFingerNotFound() string

GetWebFingerNotFound returns a 404 response

func GetWebfinger

func GetWebfinger(user string, conf *util.AppConfig) (error, string)

GetWebfinger returns WebFinger JSON for a local user

func GetWellKnownNodeInfo added in v1.2.2

func GetWellKnownNodeInfo(conf *util.AppConfig) string

GetWellKnownNodeInfo returns the /.well-known/nodeinfo discovery document

func HandleGlobalTimeline added in v1.6.0

func HandleGlobalTimeline(c *gin.Context, conf *util.AppConfig)

func HandleIndex added in v1.1.0

func HandleIndex(c *gin.Context, conf *util.AppConfig)

func HandleProfile added in v1.1.0

func HandleProfile(c *gin.Context, conf *util.AppConfig)

func HandleSinglePost added in v1.2.3

func HandleSinglePost(c *gin.Context, conf *util.AppConfig)

func HandleTagFeed added in v1.4.0

func HandleTagFeed(c *gin.Context, conf *util.AppConfig)

func HandleUploadForm added in v1.5.0

func HandleUploadForm(c *gin.Context, conf *util.AppConfig)

HandleUploadForm shows the upload form for a valid token

func HandleUploadSubmit added in v1.5.0

func HandleUploadSubmit(c *gin.Context, conf *util.AppConfig)

HandleUploadSubmit processes the uploaded file

func IsHTMLRequest added in v1.5.0

func IsHTMLRequest(accept string) bool

IsHTMLRequest determines if an Accept header indicates a browser/HTML request rather than an ActivityPub client request. ActivityPub clients typically send:

Browsers typically send:

  • text/html
  • */* (default)
  • empty string

func MaxBytesMiddleware added in v1.1.0

func MaxBytesMiddleware(maxBytes int64) gin.HandlerFunc

MaxBytesMiddleware limits the size of request bodies

func ParsePageParam added in v1.1.0

func ParsePageParam(pageStr string) int

ParsePageParam extracts the page parameter from a query string

func RateLimitMiddleware added in v1.1.0

func RateLimitMiddleware(rl *RateLimiter) gin.HandlerFunc

RateLimitMiddleware creates a Gin middleware for rate limiting

func ResolveWebFinger

func ResolveWebFinger(username, domain string) (string, error)

ResolveWebFinger resolves a user@domain to an ActivityPub actor URI Example: ResolveWebFinger("alice", "mastodon.social") -> "https://mastodon.social/users/alice"

func Router

func Router(conf *util.AppConfig) (*gin.Engine, error)

func ServeAvatar added in v1.5.0

func ServeAvatar(c *gin.Context, conf *util.AppConfig)

ServeAvatar serves avatar images from the avatars directory

Types

type IndexPageData added in v1.1.0

type IndexPageData struct {
	Title         string
	Host          string
	SSHPort       int
	Version       string
	Posts         []PostView
	HasPrev       bool
	HasNext       bool
	PrevPage      int
	NextPage      int
	InfoBoxes     []InfoBoxView
	ServerMessage *ServerMessageView
}

type InfoBoxView added in v1.5.0

type InfoBoxView struct {
	Title       string        // Plain text title (auto-escaped by template)
	TitleHTML   template.HTML // Title rendered as markdown/HTML (for icons/formatting)
	ContentHTML template.HTML // Sanitized HTML content from markdown
}

type NodeInfo20 added in v1.2.2

type NodeInfo20 struct {
	Version           string           `json:"version"`
	Software          NodeInfoSoftware `json:"software"`
	Protocols         []string         `json:"protocols"`
	Services          NodeInfoServices `json:"services"`
	OpenRegistrations bool             `json:"openRegistrations"`
	Usage             NodeInfoUsage    `json:"usage"`
	Metadata          NodeInfoMetadata `json:"metadata"`
}

NodeInfo20 represents the NodeInfo 2.0 schema See: https://nodeinfo.diaspora.software/schema.html

type NodeInfoLink struct {
	Rel  string `json:"rel"`
	Href string `json:"href"`
}

type NodeInfoMetadata added in v1.2.2

type NodeInfoMetadata struct {
	NodeName        string `json:"nodeName"`
	NodeDescription string `json:"nodeDescription"`
}

type NodeInfoServices added in v1.2.2

type NodeInfoServices struct {
	Inbound  []string `json:"inbound"`
	Outbound []string `json:"outbound"`
}

type NodeInfoSoftware added in v1.2.2

type NodeInfoSoftware struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type NodeInfoUsage added in v1.2.2

type NodeInfoUsage struct {
	Users      NodeInfoUsers `json:"users"`
	LocalPosts int           `json:"localPosts"`
}

type NodeInfoUsers added in v1.2.2

type NodeInfoUsers struct {
	Total          int `json:"total"`
	ActiveMonth    int `json:"activeMonth"`
	ActiveHalfyear int `json:"activeHalfyear"`
}

type PostView added in v1.1.0

type PostView struct {
	NoteId       string
	Username     string
	UserDomain   string // Domain for remote users (empty for local)
	ProfileURL   string // Full profile URL
	PostURL      string // Permalink to the post (web URL for display)
	ObjectURI    string // ActivityPub canonical URI (for API calls)
	IsRemote     bool   // True if federated user
	Message      string
	MessageHTML  template.HTML // HTML-rendered message with clickable links
	TimeAgo      string
	CreatedAt    time.Time // For chronological sorting
	InReplyToURI string    // URI of parent post if this is a reply
	ReplyCount   int       // Number of replies to this post
	LikeCount    int       // Number of likes on this post
	BoostCount   int       // Number of boosts on this post
	Likers       []string  // Usernames who liked this post
	Boosters     []string  // Usernames who boosted this post
	BoostedBy    string    // If non-empty, this post was boosted by this user
}

type ProfilePageData added in v1.1.0

type ProfilePageData struct {
	Title         string
	Host          string
	SSHPort       int
	Version       string
	User          UserView
	Posts         []PostView
	TotalPosts    int
	HasPrev       bool
	HasNext       bool
	PrevPage      int
	NextPage      int
	InfoBoxes     []InfoBoxView
	ServerMessage *ServerMessageView
}

type RateLimiter added in v1.1.0

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

RateLimiter holds rate limiters for different IP addresses

func NewRateLimiter added in v1.1.0

func NewRateLimiter(r rate.Limit, b int) *RateLimiter

NewRateLimiter creates a new rate limiter r is requests per second, b is burst size

type ServerMessageView added in v1.6.1

type ServerMessageView struct {
	Message     string        // Plain text message
	MessageHTML template.HTML // Markdown-rendered HTML
	Enabled     bool
	WebEnabled  bool
}

ServerMessageView is the view model for server messages with rendered HTML

type SinglePostPageData added in v1.2.3

type SinglePostPageData struct {
	Title         string
	Host          string
	SSHPort       int
	Version       string
	Post          PostView
	User          UserView
	ParentPost    *PostView  // Parent post if this is a reply (nil if not a reply)
	Replies       []PostView // Replies to this post
	InfoBoxes     []InfoBoxView
	ServerMessage *ServerMessageView
}

type TagPageData added in v1.4.0

type TagPageData struct {
	Title         string
	Host          string
	SSHPort       int
	Version       string
	Tag           string
	Posts         []PostView
	TotalPosts    int
	HasPrev       bool
	HasNext       bool
	PrevPage      int
	NextPage      int
	InfoBoxes     []InfoBoxView
	ServerMessage *ServerMessageView
}

type UserView added in v1.1.0

type UserView struct {
	Username      string
	DisplayName   string
	Summary       string
	JoinedAgo     string
	AvatarURL     string
	AvatarVersion int64 // Unix timestamp for cache busting
}

type WebFingerResponse

type WebFingerResponse struct {
	Subject string `json:"subject"`
	Links   []struct {
		Rel  string `json:"rel"`
		Type string `json:"type"`
		Href string `json:"href"`
	} `json:"links"`
}

WebFingerResponse represents the response from a WebFinger query

type WellKnownNodeInfo added in v1.2.2

type WellKnownNodeInfo struct {
	Links []NodeInfoLink `json:"links"`
}

WellKnownNodeInfo represents the /.well-known/nodeinfo response

Jump to

Keyboard shortcuts

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