Compare commits
4 Commits
2e4f4281de
...
v0.16.7
| Author | SHA1 | Date | |
|---|---|---|---|
| d4c5776790 | |||
| 6465ee25bc | |||
| 9788468c0a | |||
| 6f5a84c24b |
30
README.md
30
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://pkg.go.dev/go.arsenm.dev/go-lemmy)
|
||||
|
||||
Go bindings to the [Lemmy](https://join-lemmy.org) API
|
||||
Go bindings to the [Lemmy](https://join-lemmy.org) API, automatically generated directly from Lemmy's source code using the generator in [cmd/gen](cmd/gen).
|
||||
|
||||
Example:
|
||||
|
||||
@@ -29,3 +29,31 @@ if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
### How to generate
|
||||
|
||||
First, build the generator:
|
||||
|
||||
```bash
|
||||
go build ./cmd/gen
|
||||
```
|
||||
|
||||
Clone Lemmy's source code at whatever version you need:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/LemmyNet/lemmy -b 0.16.7
|
||||
```
|
||||
|
||||
Remove all the existing generated code:
|
||||
|
||||
```bash
|
||||
rm **/*.gen.go
|
||||
```
|
||||
|
||||
Execute the generator:
|
||||
|
||||
```bash
|
||||
./gen -out-dir .
|
||||
```
|
||||
|
||||
And that's it! Your generated code should be ready for use.
|
||||
@@ -10,8 +10,14 @@ import (
|
||||
|
||||
"go.arsenm.dev/go-lemmy/cmd/gen/generator"
|
||||
"go.arsenm.dev/go-lemmy/cmd/gen/parser"
|
||||
"go.arsenm.dev/logger"
|
||||
"go.arsenm.dev/logger/log"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.Logger = logger.NewPretty(os.Stderr)
|
||||
}
|
||||
|
||||
var implDirs = [...]string{
|
||||
"crates/api_crud/src",
|
||||
"crates/apub/src/api",
|
||||
@@ -89,10 +95,15 @@ func main() {
|
||||
}
|
||||
defer outFl.Close()
|
||||
|
||||
_, err = outFl.WriteString("// Source: " + path + "\n")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return generator.NewStruct(outFl, "types").Generate(fileStructs)
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal("Error walking directory while parsing structs").Err(err).Str("dir", dir).Send()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,30 +142,36 @@ func main() {
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal("Error walking directory while parsing impls").Err(err).Str("dir", dir).Send()
|
||||
}
|
||||
}
|
||||
|
||||
rf, err := os.Open(filepath.Join(*lemmyDir, routesFile))
|
||||
routesPath := filepath.Join(*lemmyDir, routesFile)
|
||||
rf, err := os.Open(routesPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal("Error opening routes file").Err(err).Send()
|
||||
}
|
||||
defer rf.Close()
|
||||
|
||||
rp := parser.NewRoutes(rf)
|
||||
routes, err := rp.Parse()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal("Error parsing routes file").Err(err).Send()
|
||||
}
|
||||
|
||||
orf, err := os.Create(filepath.Join(*outDir, "routes.gen.go"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal("Error creating routes output file").Err(err).Send()
|
||||
}
|
||||
defer orf.Close()
|
||||
|
||||
_, err = orf.WriteString("// Source: " + routesPath + "\n")
|
||||
if err != nil {
|
||||
log.Fatal("Error writing source string to routes file").Err(err).Send()
|
||||
}
|
||||
|
||||
err = generator.NewRoutes(orf, "lemmy").Generate(routes, impls)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal("Error generating output routes file").Err(err).Send()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ func (s *StructParser) Parse() ([]Item, error) {
|
||||
if slices.Contains(s.Skip, structName) {
|
||||
continue
|
||||
}
|
||||
structName = s.TransformName(structName)
|
||||
|
||||
// If the line ends with "}", this is a struct with no fields
|
||||
if strings.HasSuffix(line, "}\n") {
|
||||
@@ -97,8 +98,9 @@ func (s *StructParser) Parse() ([]Item, error) {
|
||||
enumName := enumRegex.FindStringSubmatch(line)[1]
|
||||
if slices.Contains(s.Skip, enumName) {
|
||||
continue
|
||||
|
||||
}
|
||||
enumName = s.TransformName(enumName)
|
||||
|
||||
members, err := s.parseEnumMemebers()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -233,6 +235,8 @@ func TransformTypeGo(t string) string {
|
||||
func TransformNameGo(s string) string {
|
||||
out := ""
|
||||
|
||||
s = strings.ReplaceAll(s, "Crud", "CRUD")
|
||||
|
||||
splitName := strings.Split(s, "_")
|
||||
for _, segment := range splitName {
|
||||
switch segment {
|
||||
|
||||
8
go.mod
8
go.mod
@@ -8,5 +8,13 @@ require (
|
||||
github.com/dave/jennifer v1.6.0
|
||||
github.com/google/go-querystring v1.1.0
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
go.arsenm.dev/logger v0.0.0-20230104225304-d706171ea6df
|
||||
golang.org/x/exp v0.0.0-20230105000112-eab7a2c85304
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/gookit/color v1.5.1 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
||||
golang.org/x/sys v0.1.0 // indirect
|
||||
)
|
||||
|
||||
22
go.sum
22
go.sum
@@ -1,11 +1,33 @@
|
||||
github.com/dave/jennifer v1.6.0 h1:MQ/6emI2xM7wt0tJzJzyUik2Q3Tcn2eE0vtYgh4GPVI=
|
||||
github.com/dave/jennifer v1.6.0/go.mod h1:AxTG893FiZKqxy3FP1kL80VMshSMuz2G+EgvszgGRnk=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/gookit/color v1.5.1 h1:Vjg2VEcdHpwq+oY63s/ksHrgJYCTo0bwWvmmYWdE9fQ=
|
||||
github.com/gookit/color v1.5.1/go.mod h1:wZFzea4X8qN6vHOSP2apMb4/+w/orMznEzYsIHPaqKM=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
|
||||
go.arsenm.dev/logger v0.0.0-20230104225304-d706171ea6df h1:8mBHvEe7BJmpOeKSMA5YLqrGo9dCpePocTeR0C1+/2w=
|
||||
go.arsenm.dev/logger v0.0.0-20230104225304-d706171ea6df/go.mod h1:RV2qydKDdoyaRkhAq8JEGvojR8eJ6bjq5WnSIlH7gYw=
|
||||
golang.org/x/exp v0.0.0-20230105000112-eab7a2c85304 h1:YUqj+XKtfrn3kXjFIiZ8jwKROD7ioAOOHUuo3ZZ2opc=
|
||||
golang.org/x/exp v0.0.0-20230105000112-eab7a2c85304/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/src/api_routes.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (routes generator). DO NOT EDIT.
|
||||
|
||||
package lemmy
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/activity.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/comment.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/api_common/src/comment.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/comment_report.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/community.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/api_common/src/community.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/community_block.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/email_verification.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/lib.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/websocket/src/lib.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
@@ -58,35 +59,35 @@ const (
|
||||
UserOperationBlockPerson UserOperation = "BlockPerson"
|
||||
)
|
||||
|
||||
type UserOperationCrud string
|
||||
type UserOperationCRUD string
|
||||
|
||||
const (
|
||||
UserOperationCrudCreateSite UserOperationCrud = "CreateSite"
|
||||
UserOperationCrudGetSite UserOperationCrud = "GetSite"
|
||||
UserOperationCrudEditSite UserOperationCrud = "EditSite"
|
||||
UserOperationCrudCreateCommunity UserOperationCrud = "CreateCommunity"
|
||||
UserOperationCrudListCommunities UserOperationCrud = "ListCommunities"
|
||||
UserOperationCrudGetCommunity UserOperationCrud = "GetCommunity"
|
||||
UserOperationCrudEditCommunity UserOperationCrud = "EditCommunity"
|
||||
UserOperationCrudDeleteCommunity UserOperationCrud = "DeleteCommunity"
|
||||
UserOperationCrudRemoveCommunity UserOperationCrud = "RemoveCommunity"
|
||||
UserOperationCrudCreatePost UserOperationCrud = "CreatePost"
|
||||
UserOperationCrudGetPost UserOperationCrud = "GetPost"
|
||||
UserOperationCrudGetPosts UserOperationCrud = "GetPosts"
|
||||
UserOperationCrudEditPost UserOperationCrud = "EditPost"
|
||||
UserOperationCrudDeletePost UserOperationCrud = "DeletePost"
|
||||
UserOperationCrudRemovePost UserOperationCrud = "RemovePost"
|
||||
UserOperationCrudCreateComment UserOperationCrud = "CreateComment"
|
||||
UserOperationCrudGetComment UserOperationCrud = "GetComment"
|
||||
UserOperationCrudGetComments UserOperationCrud = "GetComments"
|
||||
UserOperationCrudEditComment UserOperationCrud = "EditComment"
|
||||
UserOperationCrudDeleteComment UserOperationCrud = "DeleteComment"
|
||||
UserOperationCrudRemoveComment UserOperationCrud = "RemoveComment"
|
||||
UserOperationCrudRegister UserOperationCrud = "Register"
|
||||
UserOperationCrudGetPersonDetails UserOperationCrud = "GetPersonDetails"
|
||||
UserOperationCrudDeleteAccount UserOperationCrud = "DeleteAccount"
|
||||
UserOperationCrudCreatePrivateMessage UserOperationCrud = "CreatePrivateMessage"
|
||||
UserOperationCrudGetPrivateMessages UserOperationCrud = "GetPrivateMessages"
|
||||
UserOperationCrudEditPrivateMessage UserOperationCrud = "EditPrivateMessage"
|
||||
UserOperationCrudDeletePrivateMessage UserOperationCrud = "DeletePrivateMessage"
|
||||
UserOperationCRUDCreateSite UserOperationCRUD = "CreateSite"
|
||||
UserOperationCRUDGetSite UserOperationCRUD = "GetSite"
|
||||
UserOperationCRUDEditSite UserOperationCRUD = "EditSite"
|
||||
UserOperationCRUDCreateCommunity UserOperationCRUD = "CreateCommunity"
|
||||
UserOperationCRUDListCommunities UserOperationCRUD = "ListCommunities"
|
||||
UserOperationCRUDGetCommunity UserOperationCRUD = "GetCommunity"
|
||||
UserOperationCRUDEditCommunity UserOperationCRUD = "EditCommunity"
|
||||
UserOperationCRUDDeleteCommunity UserOperationCRUD = "DeleteCommunity"
|
||||
UserOperationCRUDRemoveCommunity UserOperationCRUD = "RemoveCommunity"
|
||||
UserOperationCRUDCreatePost UserOperationCRUD = "CreatePost"
|
||||
UserOperationCRUDGetPost UserOperationCRUD = "GetPost"
|
||||
UserOperationCRUDGetPosts UserOperationCRUD = "GetPosts"
|
||||
UserOperationCRUDEditPost UserOperationCRUD = "EditPost"
|
||||
UserOperationCRUDDeletePost UserOperationCRUD = "DeletePost"
|
||||
UserOperationCRUDRemovePost UserOperationCRUD = "RemovePost"
|
||||
UserOperationCRUDCreateComment UserOperationCRUD = "CreateComment"
|
||||
UserOperationCRUDGetComment UserOperationCRUD = "GetComment"
|
||||
UserOperationCRUDGetComments UserOperationCRUD = "GetComments"
|
||||
UserOperationCRUDEditComment UserOperationCRUD = "EditComment"
|
||||
UserOperationCRUDDeleteComment UserOperationCRUD = "DeleteComment"
|
||||
UserOperationCRUDRemoveComment UserOperationCRUD = "RemoveComment"
|
||||
UserOperationCRUDRegister UserOperationCRUD = "Register"
|
||||
UserOperationCRUDGetPersonDetails UserOperationCRUD = "GetPersonDetails"
|
||||
UserOperationCRUDDeleteAccount UserOperationCRUD = "DeleteAccount"
|
||||
UserOperationCRUDCreatePrivateMessage UserOperationCRUD = "CreatePrivateMessage"
|
||||
UserOperationCRUDGetPrivateMessages UserOperationCRUD = "GetPrivateMessages"
|
||||
UserOperationCRUDEditPrivateMessage UserOperationCRUD = "EditPrivateMessage"
|
||||
UserOperationCRUDDeletePrivateMessage UserOperationCRUD = "DeletePrivateMessage"
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/api_common/src/lib.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/local_user.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/mod.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/moderator.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/password_reset_request.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/person.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/api_common/src/person.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/person_block.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/person_mention.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/post.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/api_common/src/post.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/post_report.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/private_message.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/registration_application.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/api_common/src/request.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/secret.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/api_common/src/sensitive.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/source/site.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/api_common/src/site.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_views/src/structs.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_views_moderator/src/structs.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_schema/src/aggregates/structs.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/db_views_actor/src/structs.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -61,15 +61,8 @@ type LemmyWebSocketMsg struct {
|
||||
// IsOneOf checks if the message is one of the given operations.
|
||||
func (msg LemmyWebSocketMsg) IsOneOf(ops ...Operation) bool {
|
||||
for _, op := range ops {
|
||||
switch op := op.(type) {
|
||||
case UserOperation:
|
||||
if string(op) == msg.Op {
|
||||
return true
|
||||
}
|
||||
case UserOperationCrud:
|
||||
if string(op) == msg.Op {
|
||||
return true
|
||||
}
|
||||
if op.Operation() == msg.Op {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
@@ -83,6 +76,6 @@ func (u UserOperation) Operation() string {
|
||||
return string(u)
|
||||
}
|
||||
|
||||
func (u UserOperationCrud) Operation() string {
|
||||
func (u UserOperationCRUD) Operation() string {
|
||||
return string(u)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/api_common/src/utils.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Source: lemmy/crates/api_common/src/websocket.rs
|
||||
// Code generated by go.arsenm.dev/go-lemmy/cmd/gen (struct generator). DO NOT EDIT.
|
||||
|
||||
package types
|
||||
|
||||
Reference in New Issue
Block a user