Update for 0.19.0-rc.1

This commit is contained in:
Elara 2023-10-04 16:16:36 -07:00
parent 5a7463d006
commit 2511d0dcc7
9 changed files with 1425 additions and 1483 deletions

View File

@ -14,9 +14,7 @@ type Route struct {
Method string Method string
Path string Path string
ParamsName string ParamsName string
ParamsID int64
ReturnName string ReturnName string
ReturnID int64
} }
type Struct struct { type Struct struct {
@ -36,6 +34,7 @@ type Extractor struct {
root gjson.Result root gjson.Result
} }
// New parses the file at path and returns an extractor with its contents.
func New(path string) (*Extractor, error) { func New(path string) (*Extractor, error) {
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
@ -45,13 +44,20 @@ func New(path string) (*Extractor, error) {
return &Extractor{gjson.ParseBytes(data)}, nil return &Extractor{gjson.ParseBytes(data)}, nil
} }
func (e *Extractor) Routes() []Route { // Extract reads the JSON document and extracts all the routes and structs from it.
func (e *Extractor) Extract() ([]Route, []Struct) {
structs := map[int64]Struct{}
var out []Route var out []Route
// Get all the routes in the JSON document
routes := e.root.Get("children.#.children.#(kind==2048)#|@flatten") routes := e.root.Get("children.#.children.#(kind==2048)#|@flatten")
for _, route := range routes.Array() { for _, route := range routes.Array() {
name := route.Get("name").String() name := route.Get("name").String()
signature := route.Get(`signatures.0`) signature := route.Get(`signatures.0`)
// Get the code part of the route's summary.
// This will contain the HTTP method and path.
httpInfo := signature.Get(`comment.summary.#(kind=="code").text`).String() httpInfo := signature.Get(`comment.summary.#(kind=="code").text`).String()
if !strings.HasPrefix(httpInfo, "`HTTP") { if !strings.HasPrefix(httpInfo, "`HTTP") {
continue continue
@ -63,37 +69,49 @@ func (e *Extractor) Routes() []Route {
continue continue
} }
// Get the ID and name of the type this function accepts
paramsID := signature.Get("parameters.0.type.target").Int() paramsID := signature.Get("parameters.0.type.target").Int()
paramsName := signature.Get("parameters.0.type.name").String() paramsName := signature.Get("parameters.0.type.name").String()
// Get the ID and name of the type this function returns
returnID := signature.Get("type.typeArguments.0.target").Int() returnID := signature.Get("type.typeArguments.0.target").Int()
returnName := signature.Get("type.typeArguments.0.name").String() returnName := signature.Get("type.typeArguments.0.name").String()
// Get the referenced structs from the JSON document
e.getStructs([]int64{paramsID, returnID}, structs)
// If the parameters struct contains no fields or union names
if len(structs[paramsID].Fields) == 0 && len(structs[paramsID].UnionNames) == 0 {
// Delete the params struct from the structs map
// to make sure it doesn't get generated
delete(structs, paramsID)
// Set paramsName to an empty string to signify that this route
// has no input parameters.
paramsName = ""
}
// If the return struct contains no fields or union names
if len(structs[returnID].Fields) == 0 && len(structs[returnID].UnionNames) == 0 {
// Delete the return struct from the structs map
// to make sure it doesn't get generated
delete(structs, returnID)
// Set paramsName to an empty string to signify that this route
// has no return value.
returnName = ""
}
out = append(out, Route{ out = append(out, Route{
Name: name, Name: name,
Summary: summary, Summary: summary,
Method: method, Method: method,
Path: path, Path: path,
ParamsName: paramsName, ParamsName: paramsName,
ParamsID: paramsID,
ReturnName: returnName, ReturnName: returnName,
ReturnID: returnID,
}) })
} }
return out return out, getStructSlice(structs)
}
func (e *Extractor) Structs(routes []Route) []Struct {
var ids []int64
for _, route := range routes {
ids = append(ids, route.ParamsID)
if route.ReturnID != 0 {
ids = append(ids, route.ReturnID)
}
}
structs := map[int64]Struct{}
e.getStructs(ids, structs)
return getKeys(structs)
} }
func (e *Extractor) getStructs(ids []int64, structs map[int64]Struct) { func (e *Extractor) getStructs(ids []int64, structs map[int64]Struct) {
@ -102,6 +120,7 @@ func (e *Extractor) getStructs(ids []int64, structs map[int64]Struct) {
continue continue
} }
// Get the struct with the given ID from the JSON document
jstruct := e.root.Get(fmt.Sprintf("children.#(id==%d)", id)) jstruct := e.root.Get(fmt.Sprintf("children.#(id==%d)", id))
if !jstruct.Exists() { if !jstruct.Exists() {
continue continue
@ -122,12 +141,14 @@ func (e *Extractor) getStructs(ids []int64, structs map[int64]Struct) {
Fields: fields, Fields: fields,
} }
// Recursively get any structs referenced by this one
e.getStructs(newIDs, structs) e.getStructs(newIDs, structs)
} }
} }
} }
// unionNames gets all the names of union type members
func (e *Extractor) unionNames(jstruct gjson.Result) []string { func (e *Extractor) unionNames(jstruct gjson.Result) []string {
jnames := jstruct.Get("type.types").Array() jnames := jstruct.Get("type.types").Array()
out := make([]string, len(jnames)) out := make([]string, len(jnames))
@ -137,6 +158,8 @@ func (e *Extractor) unionNames(jstruct gjson.Result) []string {
return out return out
} }
// fields gets all the fields in a given struct from the JSON document.
// It returns the fields and the IDs of any types they referenced.
func (e *Extractor) fields(jstruct gjson.Result) ([]Field, []int64) { func (e *Extractor) fields(jstruct gjson.Result) ([]Field, []int64) {
var fields []Field var fields []Field
var ids []int64 var ids []int64
@ -153,8 +176,11 @@ func (e *Extractor) fields(jstruct gjson.Result) ([]Field, []int64) {
switch jfield.Get("type.elementType.type").String() { switch jfield.Get("type.elementType.type").String() {
case "reference": case "reference":
// If this field is referencing another type, add that type's id
// to the ids slice.
ids = append(ids, jfield.Get("type.elementType.target").Int()) ids = append(ids, jfield.Get("type.elementType.target").Int())
case "union": case "union":
// Convert unions to strings
field.Type = "string" field.Type = "string"
} }
} else { } else {
@ -162,8 +188,11 @@ func (e *Extractor) fields(jstruct gjson.Result) ([]Field, []int64) {
switch jfield.Get("type.type").String() { switch jfield.Get("type.type").String() {
case "reference": case "reference":
// If this field is referencing another type, add that type's id
// to the ids slice.
ids = append(ids, jfield.Get("type.target").Int()) ids = append(ids, jfield.Get("type.target").Int())
case "union": case "union":
// Convert unions to strings
field.Type = "string" field.Type = "string"
} }
} }
@ -173,6 +202,8 @@ func (e *Extractor) fields(jstruct gjson.Result) ([]Field, []int64) {
return fields, ids return fields, ids
} }
// parseHTTPInfo parses the string from a route's summary,
// and returns the method and path it uses
func parseHTTPInfo(httpInfo string) (method, path string) { func parseHTTPInfo(httpInfo string) (method, path string) {
httpInfo = strings.Trim(httpInfo, "`") httpInfo = strings.Trim(httpInfo, "`")
method, path, _ = strings.Cut(httpInfo, " ") method, path, _ = strings.Cut(httpInfo, " ")
@ -181,7 +212,8 @@ func parseHTTPInfo(httpInfo string) (method, path string) {
return method, path return method, path
} }
func getKeys(m map[int64]Struct) []Struct { // getStructSlice returns all the structs in a map
func getStructSlice(m map[int64]Struct) []Struct {
out := make([]Struct, len(m)) out := make([]Struct, len(m))
i := 0 i := 0
for _, s := range m { for _, s := range m {

View File

@ -22,7 +22,6 @@ func (r *RoutesGenerator) Generate(routes []extractor.Route) error {
f.HeaderComment("Code generated by go.elara.ws/go-lemmy/cmd/gen (routes generator). DO NOT EDIT.") f.HeaderComment("Code generated by go.elara.ws/go-lemmy/cmd/gen (routes generator). DO NOT EDIT.")
for _, r := range routes { for _, r := range routes {
f.Comment(r.Summary) f.Comment(r.Summary)
f.Func().Params( f.Func().Params(
jen.Id("c").Id("*Client"), jen.Id("c").Id("*Client"),
@ -37,27 +36,26 @@ func (r *RoutesGenerator) Generate(routes []extractor.Route) error {
} }
g.Error() g.Error()
}).BlockFunc(func(g *jen.Group) { }).BlockFunc(func(g *jen.Group) {
data := jen.Id("data")
// If there are no parameters, set the data to nil
if r.ParamsName == "" {
data = jen.Nil()
}
returnName := r.ReturnName returnName := r.ReturnName
if returnName == "" { if returnName == "" {
returnName = "EmptyResponse" returnName = "EmptyResponse"
} }
if r.ParamsName == "" {
g.Id("data").Op(":=").Qual("go.elara.ws/go-lemmy/types", "EmptyData").Block()
}
g.Id("resData").Op(":=").Op("&").Qual("go.elara.ws/go-lemmy/types", returnName).Block() g.Id("resData").Op(":=").Op("&").Qual("go.elara.ws/go-lemmy/types", returnName).Block()
var funcName string funcName := "req"
switch r.Method { if r.Method == "GET" {
case "GET":
funcName = "getReq" funcName = "getReq"
default:
funcName = "req"
} }
g.List(jen.Id("res"), jen.Err()).Op(":=").Id("c").Dot(funcName).Params( g.List(jen.Id("res"), jen.Err()).Op(":=").Id("c").Dot(funcName).Params(
jen.Id("ctx"), jen.Lit(r.Method), jen.Lit(r.Path), jen.Id("data"), jen.Op("&").Id("resData"), jen.Id("ctx"), jen.Lit(r.Method), jen.Lit(r.Path), data, jen.Op("&").Id("resData"),
) )
g.If(jen.Err().Op("!=").Nil()).BlockFunc(func(g *jen.Group) { g.If(jen.Err().Op("!=").Nil()).BlockFunc(func(g *jen.Group) {
if returnName == "EmptyResponse" { if returnName == "EmptyResponse" {

View File

@ -35,7 +35,7 @@ func (s *StructGenerator) Generate(items []extractor.Struct) error {
} else { } else {
f.Type().Id(item.Name).StructFunc(func(g *jen.Group) { f.Type().Id(item.Name).StructFunc(func(g *jen.Group) {
for _, field := range item.Fields { for _, field := range item.Fields {
g.Id(transformFieldName(field.Name)).Id(getType(field)).Tag(map[string]string{ g.Id(transformFieldName(field.Name)).Add(getType(field)).Tag(map[string]string{
"json": field.Name, "json": field.Name,
"url": field.Name + ",omitempty", "url": field.Name + ",omitempty",
}) })
@ -51,7 +51,19 @@ func (s *StructGenerator) Generate(items []extractor.Struct) error {
return f.Render(s.w) return f.Render(s.w)
} }
func getType(f extractor.Field) string { func getType(f extractor.Field) jen.Code {
// Some time fields are strings in the JS client,
// use time.Time for those
switch f.Name {
case "published", "updated", "when_":
return jen.Qual("time", "Time")
}
// Rank types such as hot_rank and hot_rank_active may be floats.
if strings.Contains(f.Name, "rank") {
return jen.Float64()
}
t := transformType(f.Name, f.Type) t := transformType(f.Name, f.Type)
if f.IsArray { if f.IsArray {
t = "[]" + t t = "[]" + t
@ -59,17 +71,10 @@ func getType(f extractor.Field) string {
if f.IsOptional { if f.IsOptional {
t = "Optional[" + t + "]" t = "Optional[" + t + "]"
} }
return t return jen.Id(t)
} }
func transformType(name, t string) string { func transformType(name, t string) string {
// Some time fields are strings in the JS client,
// use LemmyTime for those
switch name {
case "published", "updated", "when_":
return "LemmyTime"
}
switch t { switch t {
case "number": case "number":
return "int64" return "int64"
@ -94,7 +99,6 @@ func transformFieldName(s string) string {
"Png", "PNG", "Png", "PNG",
"Uuid", "UUID", "Uuid", "UUID",
"Wav", "WAV", "Wav", "WAV",
"Ap", "AP",
).Replace(s) ).Replace(s)
return s return s
} }

View File

@ -25,8 +25,7 @@ func main() {
log.Fatal("Error creating extractor").Err(err).Send() log.Fatal("Error creating extractor").Err(err).Send()
} }
routes := e.Routes() routes, structs := e.Extract()
structs := e.Structs(routes)
err = os.MkdirAll(filepath.Join(*outDir, "types"), 0o755) err = os.MkdirAll(filepath.Join(*outDir, "types"), 0o755)
if err != nil { if err != nil {

View File

@ -7,7 +7,6 @@ import (
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
"reflect"
"github.com/google/go-querystring/query" "github.com/google/go-querystring/query"
"go.elara.ws/go-lemmy/types" "go.elara.ws/go-lemmy/types"
@ -48,8 +47,6 @@ func (c *Client) ClientLogin(ctx context.Context, l types.Login) error {
// req makes a request to the server // req makes a request to the server
func (c *Client) req(ctx context.Context, method string, path string, data, resp any) (*http.Response, error) { func (c *Client) req(ctx context.Context, method string, path string, data, resp any) (*http.Response, error) {
data = c.setAuth(data)
var r io.Reader var r io.Reader
if data != nil { if data != nil {
jsonData, err := json.Marshal(data) jsonData, err := json.Marshal(data)
@ -71,6 +68,10 @@ func (c *Client) req(ctx context.Context, method string, path string, data, resp
req.Header.Add("Content-Type", "application/json") req.Header.Add("Content-Type", "application/json")
if c.Token != "" {
req.Header.Add("Authorization", "Bearer "+c.Token)
}
res, err := c.client.Do(req) res, err := c.client.Do(req)
if err != nil { if err != nil {
return nil, err return nil, err
@ -91,14 +92,14 @@ func (c *Client) req(ctx context.Context, method string, path string, data, resp
// It's separate from req() because it uses query // It's separate from req() because it uses query
// parameters rather than a JSON request body. // parameters rather than a JSON request body.
func (c *Client) getReq(ctx context.Context, method string, path string, data, resp any) (*http.Response, error) { func (c *Client) getReq(ctx context.Context, method string, path string, data, resp any) (*http.Response, error) {
data = c.setAuth(data)
getURL := c.baseURL.JoinPath(path) getURL := c.baseURL.JoinPath(path)
vals, err := query.Values(data) if data != nil {
if err != nil { vals, err := query.Values(data)
return nil, err if err != nil {
return nil, err
}
getURL.RawQuery = vals.Encode()
} }
getURL.RawQuery = vals.Encode()
req, err := http.NewRequestWithContext( req, err := http.NewRequestWithContext(
ctx, ctx,
@ -110,6 +111,10 @@ func (c *Client) getReq(ctx context.Context, method string, path string, data, r
return nil, err return nil, err
} }
if c.Token != "" {
req.Header.Add("Authorization", "Bearer "+c.Token)
}
res, err := c.client.Do(req) res, err := c.client.Do(req)
if err != nil { if err != nil {
return nil, err return nil, err
@ -141,35 +146,3 @@ func resError(res *http.Response, lr types.LemmyResponse) error {
return nil return nil
} }
} }
// setAuth uses reflection to automatically
// set struct fields called Auth of type
// string or types.Optional[string] to the
// authentication token, then returns the
// updated struct
func (c *Client) setAuth(data any) any {
if data == nil {
return data
}
val := reflect.New(reflect.TypeOf(data))
val.Elem().Set(reflect.ValueOf(data))
authField := val.Elem().FieldByName("Auth")
if !authField.IsValid() {
return data
}
switch authField.Type().String() {
case "string":
authField.SetString(c.Token)
case "types.Optional[string]":
setMtd := authField.MethodByName("Set")
out := setMtd.Call([]reflect.Value{reflect.ValueOf(c.Token)})
authField.Set(out[0])
default:
return data
}
return val.Elem().Interface()
}

View File

@ -91,6 +91,20 @@ func (c *Client) BlockCommunity(ctx context.Context, data types.BlockCommunity)
return resData, nil return resData, nil
} }
// Block an instance.
func (c *Client) BlockInstance(ctx context.Context, data types.BlockInstance) (*types.BlockInstanceResponse, error) {
resData := &types.BlockInstanceResponse{}
res, err := c.req(ctx, "POST", "/site/block", data, &resData)
if err != nil {
return nil, err
}
err = resError(res, resData.LemmyResponse)
if err != nil {
return nil, err
}
return resData, nil
}
// Block a person. // Block a person.
func (c *Client) BlockPerson(ctx context.Context, data types.BlockPerson) (*types.BlockPersonResponse, error) { func (c *Client) BlockPerson(ctx context.Context, data types.BlockPerson) (*types.BlockPersonResponse, error) {
resData := &types.BlockPersonResponse{} resData := &types.BlockPersonResponse{}
@ -456,9 +470,9 @@ func (c *Client) FollowCommunity(ctx context.Context, data types.FollowCommunity
} }
// Get a list of banned users // Get a list of banned users
func (c *Client) BannedPersons(ctx context.Context, data types.GetBannedPersons) (*types.BannedPersonsResponse, error) { func (c *Client) BannedPersons(ctx context.Context) (*types.BannedPersonsResponse, error) {
resData := &types.BannedPersonsResponse{} resData := &types.BannedPersonsResponse{}
res, err := c.getReq(ctx, "GET", "/user/banned", data, &resData) res, err := c.getReq(ctx, "GET", "/user/banned", nil, &resData)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -470,9 +484,9 @@ func (c *Client) BannedPersons(ctx context.Context, data types.GetBannedPersons)
} }
// Fetch a Captcha. // Fetch a Captcha.
func (c *Client) Captcha(ctx context.Context, data types.GetCaptcha) (*types.GetCaptchaResponse, error) { func (c *Client) Captcha(ctx context.Context) (*types.GetCaptchaResponse, error) {
resData := &types.GetCaptchaResponse{} resData := &types.GetCaptchaResponse{}
res, err := c.getReq(ctx, "GET", "/user/get_captcha", data, &resData) res, err := c.getReq(ctx, "GET", "/user/get_captcha", nil, &resData)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -526,9 +540,9 @@ func (c *Client) Community(ctx context.Context, data types.GetCommunity) (*types
} }
// Fetch federated instances. // Fetch federated instances.
func (c *Client) FederatedInstances(ctx context.Context, data types.GetFederatedInstances) (*types.GetFederatedInstancesResponse, error) { func (c *Client) FederatedInstances(ctx context.Context) (*types.GetFederatedInstancesResponse, error) {
resData := &types.GetFederatedInstancesResponse{} resData := &types.GetFederatedInstancesResponse{}
res, err := c.getReq(ctx, "GET", "/federated_instances", data, &resData) res, err := c.getReq(ctx, "GET", "/federated_instances", nil, &resData)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -652,9 +666,9 @@ func (c *Client) ReportCount(ctx context.Context, data types.GetReportCount) (*t
} }
// Gets the site, and your user data. // Gets the site, and your user data.
func (c *Client) Site(ctx context.Context, data types.GetSite) (*types.GetSiteResponse, error) { func (c *Client) Site(ctx context.Context) (*types.GetSiteResponse, error) {
resData := &types.GetSiteResponse{} resData := &types.GetSiteResponse{}
res, err := c.getReq(ctx, "GET", "/site", data, &resData) res, err := c.getReq(ctx, "GET", "/site", nil, &resData)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -680,9 +694,9 @@ func (c *Client) SiteMetadata(ctx context.Context, data types.GetSiteMetadata) (
} }
// Get your unread counts // Get your unread counts
func (c *Client) UnreadCount(ctx context.Context, data types.GetUnreadCount) (*types.GetUnreadCountResponse, error) { func (c *Client) UnreadCount(ctx context.Context) (*types.GetUnreadCountResponse, error) {
resData := &types.GetUnreadCountResponse{} resData := &types.GetUnreadCountResponse{}
res, err := c.getReq(ctx, "GET", "/user/unread_count", data, &resData) res, err := c.getReq(ctx, "GET", "/user/unread_count", nil, &resData)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -694,9 +708,23 @@ func (c *Client) UnreadCount(ctx context.Context, data types.GetUnreadCount) (*t
} }
// Get the unread registration applications count. // Get the unread registration applications count.
func (c *Client) UnreadRegistrationApplicationCount(ctx context.Context, data types.GetUnreadRegistrationApplicationCount) (*types.GetUnreadRegistrationApplicationCountResponse, error) { func (c *Client) UnreadRegistrationApplicationCount(ctx context.Context) (*types.GetUnreadRegistrationApplicationCountResponse, error) {
resData := &types.GetUnreadRegistrationApplicationCountResponse{} resData := &types.GetUnreadRegistrationApplicationCountResponse{}
res, err := c.getReq(ctx, "GET", "/admin/registration_application/count", data, &resData) res, err := c.getReq(ctx, "GET", "/admin/registration_application/count", nil, &resData)
if err != nil {
return nil, err
}
err = resError(res, resData.LemmyResponse)
if err != nil {
return nil, err
}
return resData, nil
}
// Hide a community from public view.
func (c *Client) HideCommunity(ctx context.Context, data types.HideCommunity) (*types.CommunityResponse, error) {
resData := &types.CommunityResponse{}
res, err := c.req(ctx, "PUT", "/community/hide", data, &resData)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -708,9 +736,9 @@ func (c *Client) UnreadRegistrationApplicationCount(ctx context.Context, data ty
} }
// Leave the Site admins. // Leave the Site admins.
func (c *Client) LeaveAdmin(ctx context.Context, data types.LeaveAdmin) (*types.GetSiteResponse, error) { func (c *Client) LeaveAdmin(ctx context.Context) (*types.GetSiteResponse, error) {
resData := &types.GetSiteResponse{} resData := &types.GetSiteResponse{}
res, err := c.req(ctx, "POST", "/user/leave_admin", data, &resData) res, err := c.req(ctx, "POST", "/user/leave_admin", nil, &resData)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -848,9 +876,9 @@ func (c *Client) Login(ctx context.Context, data types.Login) (*types.LoginRespo
} }
// Mark all replies as read. // Mark all replies as read.
func (c *Client) MarkAllAsRead(ctx context.Context, data types.MarkAllAsRead) (*types.GetRepliesResponse, error) { func (c *Client) MarkAllAsRead(ctx context.Context) (*types.GetRepliesResponse, error) {
resData := &types.GetRepliesResponse{} resData := &types.GetRepliesResponse{}
res, err := c.req(ctx, "POST", "/user/mark_all_as_read", data, &resData) res, err := c.req(ctx, "POST", "/user/mark_all_as_read", nil, &resData)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1,38 +0,0 @@
package types
import (
"encoding/json"
"time"
)
// LemmyTime represents a time value returned by the Lemmy server
type LemmyTime struct {
time.Time
}
// MarshalJSON encodes the Lemmy time to its JSON value
func (lt LemmyTime) MarshalJSON() ([]byte, error) {
return json.Marshal(lt.Time.Format("2006-01-02T15:04:05"))
}
// UnmarshalJSON decodes JSON into the Lemmy time struct
func (lt *LemmyTime) UnmarshalJSON(b []byte) error {
var timeStr string
err := json.Unmarshal(b, &timeStr)
if err != nil {
return err
}
if timeStr == "" {
lt.Time = time.Unix(0, 0)
return nil
}
t, err := time.Parse("2006-01-02T15:04:05", timeStr)
if err != nil {
return err
}
lt.Time = t
return nil
}

File diff suppressed because it is too large Load Diff

View File

@ -6,12 +6,6 @@ type EmptyResponse struct {
LemmyResponse LemmyResponse
} }
// EmptyData is a request without any fields. It contains
// an Auth field so that the auth token is sent to the server.
type EmptyData struct {
Auth string `json:"auth" url:"auth,omitempty"`
}
// LemmyResponse is embedded in all response structs // LemmyResponse is embedded in all response structs
// to capture any errors sent by the Lemmy server. // to capture any errors sent by the Lemmy server.
type LemmyResponse struct { type LemmyResponse struct {