♻️ 转移到 Dealer #5

Merged
LittleSheep merged 5 commits from refactor/dealer into master 2024-07-16 05:03:45 +00:00
35 changed files with 426 additions and 2559 deletions
Showing only changes of commit a8d919dc5b - Show all commits

39
.idea/workspace.xml generated
View File

@ -4,9 +4,40 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix oauth ticket need mfa"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":recycle: Refactored relation system&#10;:arrow_up: Support new realm &amp; relation api">
<change afterPath="$PROJECT_DIR$/pkg/internal/services/relationships.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/database/migrator.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/migrator.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/auth.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/grpc/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/auth.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/friendships.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/notify.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/notifier.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/realms.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/server.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/accounts.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/clients.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/clients.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/friendships.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/relationships.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/notifications.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/admin/notify_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/admin/notify_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/friendships_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/relationships_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/index.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/index.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/notifications_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/notifications_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/notify_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/notify_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/accounts.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/friendships.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/notifications.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/perms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/perms.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/realms.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/proto/friendships.pb.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/proto/friendships.proto" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/proto/friendships_grpc.pb.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/proto/notify.pb.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/proto/notify.proto" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/proto/notify_grpc.pb.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/proto/realms.pb.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/proto/realms.proto" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/proto/realms_grpc.pb.go" beforeDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -152,8 +183,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":bug: Not supposed to appear to status at the same time" />
<MESSAGE value=":ambulance: Fix getting user panic again..." />
<MESSAGE value=":bug: Fix status validation issue" /> <MESSAGE value=":bug: Fix status validation issue" />
<MESSAGE value=":bug: Fix bugs in status" /> <MESSAGE value=":bug: Fix bugs in status" />
<MESSAGE value=":bug: Fix status query condition" /> <MESSAGE value=":bug: Fix status query condition" />
@ -177,7 +206,9 @@
<MESSAGE value=":poop: Remove mis-imported cgo" /> <MESSAGE value=":poop: Remove mis-imported cgo" />
<MESSAGE value=":bug: Bug fixes" /> <MESSAGE value=":bug: Bug fixes" />
<MESSAGE value=":bug: Fix oauth ticket need mfa" /> <MESSAGE value=":bug: Fix oauth ticket need mfa" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix oauth ticket need mfa" /> <MESSAGE value=":arrow_up: Support new auth api" />
<MESSAGE value=":recycle: Refactored relation system&#10;:arrow_up: Support new realm &amp; relation api" />
<option name="LAST_COMMIT_MESSAGE" value=":recycle: Refactored relation system&#10;:arrow_up: Support new realm &amp; relation api" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

11
go.mod
View File

@ -6,16 +6,14 @@ toolchain go1.22.1
require ( require (
firebase.google.com/go v3.13.0+incompatible firebase.google.com/go v3.13.0+incompatible
git.solsynth.dev/hydrogen/dealer v0.0.0-20240715154745-ab0b491f45ff
git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745 git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745
github.com/go-playground/validator/v10 v10.17.0 github.com/go-playground/validator/v10 v10.17.0
github.com/gofiber/contrib/websocket v1.3.0
github.com/gofiber/fiber/v2 v2.52.4 github.com/gofiber/fiber/v2 v2.52.4
github.com/golang-jwt/jwt/v5 v5.2.0 github.com/golang-jwt/jwt/v5 v5.2.0
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/hashicorp/consul/api v1.29.1
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
github.com/json-iterator/go v1.1.12 github.com/json-iterator/go v1.1.12
github.com/mbobakov/grpc-consul-resolver v1.5.3
github.com/nicksnyder/go-i18n/v2 v2.4.0 github.com/nicksnyder/go-i18n/v2 v2.4.0
github.com/robfig/cron/v3 v3.0.1 github.com/robfig/cron/v3 v3.0.1
github.com/rs/zerolog v1.31.0 github.com/rs/zerolog v1.31.0
@ -24,7 +22,6 @@ require (
github.com/spf13/viper v1.18.2 github.com/spf13/viper v1.18.2
github.com/sujit-baniya/flash v0.1.8 github.com/sujit-baniya/flash v0.1.8
golang.org/x/crypto v0.24.0 golang.org/x/crypto v0.24.0
golang.org/x/text v0.16.0
google.golang.org/api v0.183.0 google.golang.org/api v0.183.0
google.golang.org/grpc v1.64.0 google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.2 google.golang.org/protobuf v1.34.2
@ -42,10 +39,8 @@ require (
cloud.google.com/go/iam v1.1.8 // indirect cloud.google.com/go/iam v1.1.8 // indirect
cloud.google.com/go/longrunning v0.5.7 // indirect cloud.google.com/go/longrunning v0.5.7 // indirect
cloud.google.com/go/storage v1.41.0 // indirect cloud.google.com/go/storage v1.41.0 // indirect
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714155615-ad83100677ab // indirect
github.com/andybalholm/brotli v1.1.0 // indirect github.com/andybalholm/brotli v1.1.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect github.com/armon/go-metrics v0.4.1 // indirect
github.com/fasthttp/websocket v1.5.8 // indirect
github.com/fatih/color v1.17.0 // indirect github.com/fatih/color v1.17.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect
@ -62,6 +57,7 @@ require (
github.com/google/s2a-go v0.1.7 // indirect github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.4 // indirect github.com/googleapis/gax-go/v2 v2.12.4 // indirect
github.com/hashicorp/consul/api v1.29.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect
@ -84,6 +80,7 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mbobakov/grpc-consul-resolver v1.5.3 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@ -94,7 +91,6 @@ require (
github.com/rivo/uniseg v0.4.7 // indirect github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/savsgio/gotils v0.0.0-20240303185622-093b76447511 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect github.com/spf13/cast v1.6.0 // indirect
@ -116,6 +112,7 @@ require (
golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240604185151-ef581f913117 // indirect google.golang.org/genproto v0.0.0-20240604185151-ef581f913117 // indirect

30
go.sum
View File

@ -17,18 +17,18 @@ cloud.google.com/go/storage v1.41.0 h1:RusiwatSu6lHeEXe3kglxakAmAbfV+rhtPqA6i8RB
cloud.google.com/go/storage v1.41.0/go.mod h1:J1WCa/Z2FcgdEDuPUY8DxT5I+d9mFKsCepp5vR6Sq80= cloud.google.com/go/storage v1.41.0/go.mod h1:J1WCa/Z2FcgdEDuPUY8DxT5I+d9mFKsCepp5vR6Sq80=
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4= firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs= firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714122530-466b240e95a6 h1:QH5FGLdU7sfQ63RsgbP5iTjWE3/2VicJfewI4s28ThU= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715120403-4e96bb2cd519 h1:HR0JxkVIeN8xyasy99a0i+Vfy46uW1KthPVamCjOTPg=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714122530-466b240e95a6/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715120403-4e96bb2cd519/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714125606-31e73c438e33 h1:Zz0SQQ6xIBhBaNnGddl9AwX+5Id9J89NohzHjvG7/WM= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715142037-d7f5053fc74b h1:7pwMvP+zfl5rn08+Wg1rtcSqq1MtEN72wEmluvhBYIA=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714125606-31e73c438e33/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715142037-d7f5053fc74b/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714135616-d371c4fbfae2 h1:95ofnv70QDsK5ZxENY8LdV04KT0SjQZN6Mz6xJfSDhg= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715153944-44861dc01ffb h1:8/dP5qj47UPD9TZFkYH1syRCHSUo16TDutcuMK13eQY=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714135616-d371c4fbfae2/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715153944-44861dc01ffb/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714154518-8f996bb69731 h1:8O1mbCnwpIt/51HUhF4fMtE6GEmBjiyJhtvBm2uwAHg= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715154151-74c9ce063b4e h1:mkV/bshMqDTA3jUwsbb3MxN0d+U0I38S/teeRMoPNsk=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714154518-8f996bb69731/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715154151-74c9ce063b4e/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714154934-7812a06cb195 h1:TuO+yRnsr9sGGpzpU58N6K1AIbTEEMtBML1lUcIp1rE= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715154526-59bda7a4117a h1:ozV2DWlcSCLfq3941W6C7vVGlgIQ9PH2TXfnHvSms4o=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714154934-7812a06cb195/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715154526-59bda7a4117a/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714155615-ad83100677ab h1:hxqJkL4Ha3Y3SfeSA9TPKBJK6mtY88Q2uialHsDbGf0= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715154745-ab0b491f45ff h1:Bzcu+n1YFD09SGoGxuFnqT56u3kK66sQ/vF8PEhbPJQ=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240714155615-ad83100677ab/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU= git.solsynth.dev/hydrogen/dealer v0.0.0-20240715154745-ab0b491f45ff/go.mod h1:eZwAwP7ahL7TO8GWBlYFYDdjlna+8zHYbDfNabnuUEU=
git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745 h1:40BUsQMNXjqHyytkyF9py1HjTAWlRgO6R57YXUrHNy4= git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745 h1:40BUsQMNXjqHyytkyF9py1HjTAWlRgO6R57YXUrHNy4=
git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745/go.mod h1:FsQGSLTl0gvo+9Jmbot02S72suyF9tFTrzDj70Xhifo= git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745/go.mod h1:FsQGSLTl0gvo+9Jmbot02S72suyF9tFTrzDj70Xhifo=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
@ -68,8 +68,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fasthttp/websocket v1.5.8 h1:k5DpirKkftIF/w1R8ZzjSgARJrs54Je9YJK37DL/Ah8=
github.com/fasthttp/websocket v1.5.8/go.mod h1:d08g8WaT6nnyvg9uMm8K9zMYyDjfKyj3170AtPRuVU0=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
@ -107,8 +105,6 @@ github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrt
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofiber/contrib/websocket v1.3.0 h1:XADFAGorer1VJ1bqC4UkCjqS37kwRTV0415+050NrMk=
github.com/gofiber/contrib/websocket v1.3.0/go.mod h1:xguaOzn2ZZ759LavtosEP+rcxIgBEE/rdumPINhR+Xo=
github.com/gofiber/fiber/v2 v2.36.0/go.mod h1:tgCr+lierLwLoVHHO/jn3Niannv34WRkQETU8wiL9fQ= github.com/gofiber/fiber/v2 v2.36.0/go.mod h1:tgCr+lierLwLoVHHO/jn3Niannv34WRkQETU8wiL9fQ=
github.com/gofiber/fiber/v2 v2.52.4 h1:P+T+4iK7VaqUsq2PALYEfBBo6bJZ4q3FP8cZ84EggTM= github.com/gofiber/fiber/v2 v2.52.4 h1:P+T+4iK7VaqUsq2PALYEfBBo6bJZ4q3FP8cZ84EggTM=
github.com/gofiber/fiber/v2 v2.52.4/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ= github.com/gofiber/fiber/v2 v2.52.4/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
@ -340,8 +336,6 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA= github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA=
github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
github.com/savsgio/gotils v0.0.0-20240303185622-093b76447511 h1:KanIMPX0QdEdB4R3CiimCAbxFrhB3j7h0/OvpYGVQa8=
github.com/savsgio/gotils v0.0.0-20240303185622-093b76447511/go.mod h1:sM7Mt7uEoCeFSCBM+qBrqvEo+/9vdmj19wzp3yzUhmg=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sideshow/apns2 v0.23.0 h1:lpkikaZ995GIcKk6AFsYzHyezCrsrfEDvUWcWkEGErY= github.com/sideshow/apns2 v0.23.0 h1:lpkikaZ995GIcKk6AFsYzHyezCrsrfEDvUWcWkEGErY=

View File

@ -10,7 +10,7 @@ var AutoMaintainRange = []any{
&models.AuthFactor{}, &models.AuthFactor{},
&models.AccountProfile{}, &models.AccountProfile{},
&models.AccountContact{}, &models.AccountContact{},
&models.AccountFriendship{}, &models.AccountRelationship{},
&models.Status{}, &models.Status{},
&models.Badge{}, &models.Badge{},
&models.Realm{}, &models.Realm{},

View File

@ -2,23 +2,24 @@ package grpc
import ( import (
"context" "context"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
exproto "git.solsynth.dev/hydrogen/dealer/pkg/proto" "git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services" "git.solsynth.dev/hydrogen/passport/pkg/internal/services"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
) )
func (v *Server) Authenticate(_ context.Context, in *exproto.AuthRequest) (*exproto.AuthReply, error) { func (v *Server) Authenticate(_ context.Context, in *proto.AuthRequest) (*proto.AuthReply, error) {
ctx, perms, atk, rtk, err := services.Authenticate(in.GetAccessToken(), in.GetRefreshToken(), 0) ctx, perms, atk, rtk, err := services.Authenticate(in.GetAccessToken(), in.GetRefreshToken(), 0)
if err != nil { if err != nil {
return &exproto.AuthReply{ return &proto.AuthReply{
IsValid: false, IsValid: false,
}, nil }, nil
} else { } else {
user := ctx.Account user := ctx.Account
rawPerms, _ := jsoniter.Marshal(perms) rawPerms, _ := jsoniter.Marshal(perms)
userinfo := &exproto.UserInfo{ userinfo := &proto.UserInfo{
Id: uint64(user.ID), Id: uint64(user.ID),
Name: user.Name, Name: user.Name,
Nick: user.Nick, Nick: user.Nick,
@ -33,9 +34,9 @@ func (v *Server) Authenticate(_ context.Context, in *exproto.AuthRequest) (*expr
userinfo.Banner = *user.GetBanner() userinfo.Banner = *user.GetBanner()
} }
return &exproto.AuthReply{ return &proto.AuthReply{
IsValid: true, IsValid: true,
Info: &exproto.AuthInfo{ Info: &proto.AuthInfo{
NewAccessToken: &atk, NewAccessToken: &atk,
NewRefreshToken: &rtk, NewRefreshToken: &rtk,
Permissions: rawPerms, Permissions: rawPerms,
@ -46,7 +47,7 @@ func (v *Server) Authenticate(_ context.Context, in *exproto.AuthRequest) (*expr
} }
} }
func (v *Server) EnsurePermGranted(_ context.Context, in *exproto.CheckPermRequest) (*exproto.CheckPermReply, error) { func (v *Server) EnsurePermGranted(_ context.Context, in *proto.CheckPermRequest) (*proto.CheckPermResponse, error) {
claims, err := services.DecodeJwt(in.GetToken()) claims, err := services.DecodeJwt(in.GetToken())
if err != nil { if err != nil {
return nil, err return nil, err
@ -65,7 +66,26 @@ func (v *Server) EnsurePermGranted(_ context.Context, in *exproto.CheckPermReque
perms := services.FilterPermNodes(heldPerms, ctx.Ticket.Claims) perms := services.FilterPermNodes(heldPerms, ctx.Ticket.Claims)
valid := services.HasPermNode(perms, in.GetKey(), value) valid := services.HasPermNode(perms, in.GetKey(), value)
return &exproto.CheckPermReply{ return &proto.CheckPermResponse{
IsValid: valid,
}, nil
}
func (v *Server) EnsureUserPermGranted(_ context.Context, in *proto.CheckUserPermRequest) (*proto.CheckUserPermResponse, error) {
relation, err := services.GetRelationWithTwoNode(uint(in.GetUserId()), uint(in.GetOtherId()))
if err != nil {
return &proto.CheckUserPermResponse{
IsValid: false,
}, nil
}
defaultPerm := relation.Status == models.RelationshipFriend
var value any
_ = jsoniter.Unmarshal(in.GetValue(), &value)
valid := services.HasPermNodeWithDefault(relation.PermNodes, in.GetKey(), value, defaultPerm)
return &proto.CheckUserPermResponse{
IsValid: valid, IsValid: valid,
}, nil }, nil
} }

View File

@ -1,46 +0,0 @@
package grpc
import (
"context"
"fmt"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hydrogen/passport/pkg/proto"
"github.com/samber/lo"
)
func (v *Server) ListFriendship(_ context.Context, request *proto.FriendshipLookupRequest) (*proto.ListFriendshipResponse, error) {
account, err := services.GetAccount(uint(request.GetAccountId()))
if err != nil {
return nil, err
}
friends, err := services.ListFriend(account, models.FriendshipStatus(request.GetStatus()))
if err != nil {
return nil, err
}
return &proto.ListFriendshipResponse{
Data: lo.Map(friends, func(item models.AccountFriendship, index int) *proto.FriendshipResponse {
return &proto.FriendshipResponse{
AccountId: uint64(item.AccountID),
RelatedId: uint64(item.RelatedID),
Status: uint32(item.Status),
}
}),
}, nil
}
func (v *Server) GetFriendship(ctx context.Context, request *proto.FriendshipTwoSideLookupRequest) (*proto.FriendshipResponse, error) {
friend, err := services.GetFriendWithTwoSides(uint(request.GetAccountId()), uint(request.GetRelatedId()))
if err != nil {
return nil, err
} else if friend.Status != models.FriendshipStatus(request.GetStatus()) {
return nil, fmt.Errorf("status mismatch")
}
return &proto.FriendshipResponse{
AccountId: uint64(friend.AccountID),
RelatedId: uint64(friend.RelatedID),
Status: uint32(friend.Status),
}, nil
}

View File

@ -0,0 +1,47 @@
package grpc
import (
"context"
"fmt"
jsoniter "github.com/json-iterator/go"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
)
func (v *Server) NotifyUser(_ context.Context, in *proto.NotifyUserRequest) (*proto.NotifyResponse, error) {
var err error
var user models.Account
if user, err = services.GetAccount(uint(in.GetUserId())); err != nil {
return nil, fmt.Errorf("unable to get account: %v", err)
}
var metadata map[string]any
_ = jsoniter.Unmarshal(in.GetNotify().GetMetadata(), &metadata)
notification := models.Notification{
Topic: in.GetNotify().GetTopic(),
Title: in.GetNotify().GetTitle(),
Subtitle: in.GetNotify().Subtitle,
Body: in.GetNotify().GetBody(),
Metadata: metadata,
IsRealtime: in.GetNotify().GetIsRealtime(),
IsForcePush: in.GetNotify().GetIsForcePush(),
UserID: user.ID,
}
if notification.IsRealtime {
if err := services.PushNotification(notification); err != nil {
return nil, err
}
} else {
if err := services.NewNotification(notification); err != nil {
return nil, err
}
}
return &proto.NotifyResponse{
IsSuccess: true,
}, nil
}

View File

@ -1,57 +0,0 @@
package grpc
import (
"context"
jsoniter "github.com/json-iterator/go"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hydrogen/passport/pkg/proto"
"github.com/samber/lo"
)
func (v *Server) NotifyUser(_ context.Context, in *proto.NotifyRequest) (*proto.NotifyReply, error) {
client, err := services.GetThirdClientWithSecret(in.GetClientId(), in.GetClientSecret())
if err != nil {
return nil, err
}
var user models.Account
if user, err = services.GetAccount(uint(in.GetRecipientId())); err != nil {
return nil, err
}
var metadata map[string]any
_ = jsoniter.Unmarshal(in.GetMetadata(), &metadata)
links := lo.Map(in.GetLinks(), func(item *proto.NotifyLink, index int) models.NotificationLink {
return models.NotificationLink{
Label: item.Label,
Url: item.Url,
}
})
notification := models.Notification{
Type: lo.Ternary(len(in.GetType()) > 0, in.GetType(), "common"),
Subject: in.GetSubject(),
Content: in.GetContent(),
Metadata: metadata,
Links: links,
IsRealtime: in.GetIsRealtime(),
IsForcePush: in.GetIsForcePush(),
RecipientID: user.ID,
SenderID: &client.ID,
}
if in.GetIsRealtime() {
if err := services.PushNotification(notification); err != nil {
return nil, err
}
} else {
if err := services.NewNotification(notification); err != nil {
return nil, err
}
}
return &proto.NotifyReply{IsSent: true}, nil
}

View File

@ -3,23 +3,22 @@ package grpc
import ( import (
"context" "context"
"fmt" "fmt"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database" "git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models" "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services" "git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hydrogen/passport/pkg/proto"
"github.com/samber/lo" "github.com/samber/lo"
"google.golang.org/protobuf/types/known/emptypb"
) )
func (v *Server) ListCommunityRealm(ctx context.Context, empty *emptypb.Empty) (*proto.ListRealmResponse, error) { func (v *Server) ListCommunityRealm(ctx context.Context, empty *proto.ListRealmRequest) (*proto.ListRealmResponse, error) {
realms, err := services.ListCommunityRealm() realms, err := services.ListCommunityRealm()
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &proto.ListRealmResponse{ return &proto.ListRealmResponse{
Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmResponse { Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo {
return &proto.RealmResponse{ return &proto.RealmInfo{
Id: uint64(item.ID), Id: uint64(item.ID),
Alias: item.Alias, Alias: item.Alias,
Name: item.Name, Name: item.Name,
@ -31,7 +30,7 @@ func (v *Server) ListCommunityRealm(ctx context.Context, empty *emptypb.Empty) (
}, nil }, nil
} }
func (v *Server) ListAvailableRealm(ctx context.Context, request *proto.RealmLookupWithUserRequest) (*proto.ListRealmResponse, error) { func (v *Server) ListAvailableRealm(ctx context.Context, request *proto.LookupUserRealmRequest) (*proto.ListRealmResponse, error) {
account, err := services.GetAccount(uint(request.GetUserId())) account, err := services.GetAccount(uint(request.GetUserId()))
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to find target account: %v", err) return nil, fmt.Errorf("unable to find target account: %v", err)
@ -42,8 +41,8 @@ func (v *Server) ListAvailableRealm(ctx context.Context, request *proto.RealmLoo
} }
return &proto.ListRealmResponse{ return &proto.ListRealmResponse{
Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmResponse { Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo {
return &proto.RealmResponse{ return &proto.RealmInfo{
Id: uint64(item.ID), Id: uint64(item.ID),
Alias: item.Alias, Alias: item.Alias,
Name: item.Name, Name: item.Name,
@ -55,7 +54,7 @@ func (v *Server) ListAvailableRealm(ctx context.Context, request *proto.RealmLoo
}, nil }, nil
} }
func (v *Server) ListOwnedRealm(ctx context.Context, request *proto.RealmLookupWithUserRequest) (*proto.ListRealmResponse, error) { func (v *Server) ListOwnedRealm(ctx context.Context, request *proto.LookupUserRealmRequest) (*proto.ListRealmResponse, error) {
account, err := services.GetAccount(uint(request.GetUserId())) account, err := services.GetAccount(uint(request.GetUserId()))
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to find target account: %v", err) return nil, fmt.Errorf("unable to find target account: %v", err)
@ -66,8 +65,8 @@ func (v *Server) ListOwnedRealm(ctx context.Context, request *proto.RealmLookupW
} }
return &proto.ListRealmResponse{ return &proto.ListRealmResponse{
Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmResponse { Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo {
return &proto.RealmResponse{ return &proto.RealmInfo{
Id: uint64(item.ID), Id: uint64(item.ID),
Alias: item.Alias, Alias: item.Alias,
Name: item.Name, Name: item.Name,
@ -79,7 +78,7 @@ func (v *Server) ListOwnedRealm(ctx context.Context, request *proto.RealmLookupW
}, nil }, nil
} }
func (v *Server) GetRealm(ctx context.Context, request *proto.RealmLookupRequest) (*proto.RealmResponse, error) { func (v *Server) GetRealm(ctx context.Context, request *proto.LookupRealmRequest) (*proto.RealmInfo, error) {
var realm models.Realm var realm models.Realm
tx := database.C.Model(&models.Realm{}) tx := database.C.Model(&models.Realm{})
@ -100,7 +99,7 @@ func (v *Server) GetRealm(ctx context.Context, request *proto.RealmLookupRequest
return nil, err return nil, err
} }
return &proto.RealmResponse{ return &proto.RealmInfo{
Id: uint64(realm.ID), Id: uint64(realm.ID),
Alias: realm.Alias, Alias: realm.Alias,
Name: realm.Name, Name: realm.Name,
@ -122,8 +121,8 @@ func (v *Server) ListRealmMember(ctx context.Context, request *proto.RealmMember
} }
return &proto.ListRealmMemberResponse{ return &proto.ListRealmMemberResponse{
Data: lo.Map(members, func(item models.RealmMember, index int) *proto.RealmMemberResponse { Data: lo.Map(members, func(item models.RealmMember, index int) *proto.MemberInfo {
return &proto.RealmMemberResponse{ return &proto.MemberInfo{
RealmId: uint64(item.RealmID), RealmId: uint64(item.RealmID),
UserId: uint64(item.AccountID), UserId: uint64(item.AccountID),
PowerLevel: int32(item.PowerLevel), PowerLevel: int32(item.PowerLevel),
@ -132,7 +131,7 @@ func (v *Server) ListRealmMember(ctx context.Context, request *proto.RealmMember
}, nil }, nil
} }
func (v *Server) GetRealmMember(ctx context.Context, request *proto.RealmMemberLookupRequest) (*proto.RealmMemberResponse, error) { func (v *Server) GetRealmMember(ctx context.Context, request *proto.RealmMemberLookupRequest) (*proto.MemberInfo, error) {
var member models.RealmMember var member models.RealmMember
tx := database.C.Where("realm_id = ?", request.GetRealmId()) tx := database.C.Where("realm_id = ?", request.GetRealmId())
if request.UserId != nil { if request.UserId != nil {
@ -143,9 +142,26 @@ func (v *Server) GetRealmMember(ctx context.Context, request *proto.RealmMemberL
return nil, err return nil, err
} }
return &proto.RealmMemberResponse{ return &proto.MemberInfo{
RealmId: uint64(member.RealmID), RealmId: uint64(member.RealmID),
UserId: uint64(member.AccountID), UserId: uint64(member.AccountID),
PowerLevel: int32(member.PowerLevel), PowerLevel: int32(member.PowerLevel),
}, nil }, nil
} }
func (v *Server) CheckRealmMemberPerm(ctx context.Context, request *proto.CheckRealmPermRequest) (*proto.CheckRealmPermResponse, error) {
var member models.RealmMember
tx := database.C.
Where("realm_id = ?", request.GetRealmId()).
Where("account_id = ?", request.GetUserId())
if err := tx.First(&member).Error; err != nil {
return &proto.CheckRealmPermResponse{
IsSuccess: false,
}, nil
}
return &proto.CheckRealmPermResponse{
IsSuccess: member.PowerLevel >= int(request.GetPowerLevel()),
}, nil
}

View File

@ -4,8 +4,7 @@ import (
"google.golang.org/grpc/reflection" "google.golang.org/grpc/reflection"
"net" "net"
exproto "git.solsynth.dev/hydrogen/dealer/pkg/proto" "git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/passport/pkg/proto"
"github.com/spf13/viper" "github.com/spf13/viper"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@ -13,10 +12,9 @@ import (
import health "google.golang.org/grpc/health/grpc_health_v1" import health "google.golang.org/grpc/health/grpc_health_v1"
type Server struct { type Server struct {
exproto.UnimplementedAuthServer proto.UnimplementedAuthServer
proto.UnimplementedNotifyServer proto.UnimplementedNotifierServer
proto.UnimplementedFriendshipsServer proto.UnimplementedRealmServer
proto.UnimplementedRealmsServer
health.UnimplementedHealthServer health.UnimplementedHealthServer
srv *grpc.Server srv *grpc.Server
@ -27,11 +25,10 @@ func NewServer() *Server {
srv: grpc.NewServer(), srv: grpc.NewServer(),
} }
exproto.RegisterAuthServer(server.srv, &Server{}) proto.RegisterAuthServer(server.srv, server)
proto.RegisterNotifyServer(server.srv, &Server{}) proto.RegisterNotifierServer(server.srv, server)
proto.RegisterFriendshipsServer(server.srv, &Server{}) proto.RegisterRealmServer(server.srv, server)
proto.RegisterRealmsServer(server.srv, &Server{}) health.RegisterHealthServer(server.srv, server)
health.RegisterHealthServer(server.srv, &Server{})
reflection.Register(server.srv) reflection.Register(server.srv)

View File

@ -22,11 +22,11 @@ type Account struct {
PermNodes datatypes.JSONMap `json:"perm_nodes"` PermNodes datatypes.JSONMap `json:"perm_nodes"`
Profile AccountProfile `json:"profile,omitempty"` Profile AccountProfile `json:"profile,omitempty"`
Contacts []AccountContact `json:"contacts,omitempty"`
Statuses []Status `json:"statuses,omitempty"` Statuses []Status `json:"statuses,omitempty"`
Badges []Badge `json:"badges,omitempty"` Badges []Badge `json:"badges,omitempty"`
Contacts []AccountContact `json:"contacts,omitempty"` Identities []RealmMember `json:"identities,omitempty"`
RealmIdentities []RealmMember `json:"realm_identities,omitempty"`
Tickets []AuthTicket `json:"tickets,omitempty"` Tickets []AuthTicket `json:"tickets,omitempty"`
Factors []AuthFactor `json:"factors,omitempty"` Factors []AuthFactor `json:"factors,omitempty"`
@ -36,11 +36,10 @@ type Account struct {
ThirdClients []ThirdClient `json:"clients,omitempty"` ThirdClients []ThirdClient `json:"clients,omitempty"`
Notifications []Notification `json:"notifications,omitempty" gorm:"foreignKey:RecipientID"` Notifications []Notification `json:"notifications,omitempty"`
NotifySubscribers []NotificationSubscriber `json:"notify_subscribers,omitempty"` NotifySubscribers []NotificationSubscriber `json:"notify_subscribers,omitempty"`
Friendships []AccountFriendship `json:"friendships,omitempty" gorm:"foreignKey:AccountID"` Relations []AccountRelationship `json:"relations,omitempty" gorm:"foreignKey:AccountID"`
RelatedFriendships []AccountFriendship `json:"related_friendships,omitempty" gorm:"foreignKey:RelatedID"`
} }
func (v Account) GetAvatar() *string { func (v Account) GetAvatar() *string {

View File

@ -11,8 +11,6 @@ type ThirdClient struct {
Secret string `json:"secret"` Secret string `json:"secret"`
Urls datatypes.JSONSlice[string] `json:"urls"` Urls datatypes.JSONSlice[string] `json:"urls"`
Callbacks datatypes.JSONSlice[string] `json:"callbacks"` Callbacks datatypes.JSONSlice[string] `json:"callbacks"`
Sessions []AuthTicket `json:"tickets" gorm:"foreignKey:ClientID"`
Notifications []Notification `json:"notifications" gorm:"foreignKey:SenderID"`
IsDraft bool `json:"is_draft"` IsDraft bool `json:"is_draft"`
AccountID *uint `json:"account_id"` AccountID *uint `json:"account_id"`
} }

View File

@ -1,20 +0,0 @@
package models
type FriendshipStatus = int8
const (
FriendshipPending = FriendshipStatus(iota)
FriendshipActive
FriendshipBlocked
)
type AccountFriendship struct {
BaseModel
AccountID uint `json:"account_id"`
RelatedID uint `json:"related_id"`
BlockedBy *uint `json:"blocked_by"`
Account Account `json:"account"`
Related Account `json:"related"`
Status FriendshipStatus `json:"status"`
}

View File

@ -7,15 +7,16 @@ import (
type Notification struct { type Notification struct {
BaseModel BaseModel
Type string `json:"type"` Topic string `json:"topic"`
Subject string `json:"subject"` Title string `json:"title"`
Content string `json:"content"` Subtitle *string `json:"subtitle"`
Body string `json:"body"`
Metadata datatypes.JSONMap `json:"metadata"` Metadata datatypes.JSONMap `json:"metadata"`
Links datatypes.JSONSlice[NotificationLink] `json:"links"` UserID uint `json:"user_id"`
SenderID *uint `json:"sender_id"`
IsRealtime bool `json:"is_realtime" gorm:"-"` IsRealtime bool `json:"is_realtime" gorm:"-"`
IsForcePush bool `json:"is_force_push" gorm:"-"` IsForcePush bool `json:"is_force_push" gorm:"-"`
SenderID *uint `json:"sender_id"`
RecipientID uint `json:"recipient_id"`
} }
// NotificationLink Used to embed into notify and render actions // NotificationLink Used to embed into notify and render actions

View File

@ -0,0 +1,22 @@
package models
import "gorm.io/datatypes"
type RelationshipStatus = int8
const (
RelationshipPending = RelationshipStatus(iota)
RelationshipFriend
RelationshipBlocked
)
type AccountRelationship struct {
BaseModel
AccountID uint `json:"account_id"`
RelatedID uint `json:"related_id"`
Account Account `json:"account"`
Related Account `json:"related"`
Status RelationshipStatus `json:"status"`
PermNodes datatypes.JSONMap `json:"perm_nodes"`
}

View File

@ -11,11 +11,11 @@ import (
func notifyAllUser(c *fiber.Ctx) error { func notifyAllUser(c *fiber.Ctx) error {
var data struct { var data struct {
Type string `json:"type" validate:"required"` Topic string `json:"type" validate:"required"`
Subject string `json:"subject" validate:"required,max=1024"` Title string `json:"subject" validate:"required,max=1024"`
Content string `json:"content" validate:"required,max=4096"` Subtitle *string `json:"subtitle" validate:"max=1024"`
Body string `json:"content" validate:"required,max=4096"`
Metadata map[string]any `json:"metadata"` Metadata map[string]any `json:"metadata"`
Links []models.NotificationLink `json:"links"`
IsForcePush bool `json:"is_force_push"` IsForcePush bool `json:"is_force_push"`
IsRealtime bool `json:"is_realtime"` IsRealtime bool `json:"is_realtime"`
} }
@ -41,13 +41,13 @@ func notifyAllUser(c *fiber.Ctx) error {
go func() { go func() {
for _, user := range users { for _, user := range users {
notification := models.Notification{ notification := models.Notification{
Type: data.Type, Topic: data.Topic,
Subject: data.Subject, Subtitle: data.Subtitle,
Content: data.Content, Title: data.Title,
Links: data.Links, Body: data.Body,
IsRealtime: data.IsRealtime, IsRealtime: data.IsRealtime,
IsForcePush: data.IsForcePush, IsForcePush: data.IsForcePush,
RecipientID: user.ID, UserID: user.ID,
} }
if data.IsRealtime { if data.IsRealtime {
@ -67,14 +67,14 @@ func notifyAllUser(c *fiber.Ctx) error {
func notifyOneUser(c *fiber.Ctx) error { func notifyOneUser(c *fiber.Ctx) error {
var data struct { var data struct {
Type string `json:"type" validate:"required"` Topic string `json:"type" validate:"required"`
Subject string `json:"subject" validate:"required,max=1024"` Title string `json:"subject" validate:"required,max=1024"`
Content string `json:"content" validate:"required,max=4096"` Subtitle *string `json:"subtitle" validate:"max=1024"`
Body string `json:"content" validate:"required,max=4096"`
Metadata map[string]any `json:"metadata"` Metadata map[string]any `json:"metadata"`
Links []models.NotificationLink `json:"links"`
IsForcePush bool `json:"is_force_push"` IsForcePush bool `json:"is_force_push"`
IsRealtime bool `json:"is_realtime"` IsRealtime bool `json:"is_realtime"`
UserID uint `json:"user_id"` UserID uint `json:"user_id" validate:"required"`
} }
if err := exts.BindAndValidate(c, &data); err != nil { if err := exts.BindAndValidate(c, &data); err != nil {
@ -97,13 +97,13 @@ func notifyOneUser(c *fiber.Ctx) error {
} }
notification := models.Notification{ notification := models.Notification{
Type: data.Type, Topic: data.Topic,
Subject: data.Subject, Subtitle: data.Subtitle,
Content: data.Content, Title: data.Title,
Links: data.Links, Body: data.Body,
IsRealtime: data.IsRealtime, IsRealtime: data.IsRealtime,
IsForcePush: data.IsForcePush, IsForcePush: data.IsForcePush,
RecipientID: user.ID, UserID: user.ID,
} }
if data.IsRealtime { if data.IsRealtime {

View File

@ -42,14 +42,14 @@ func MapAPIs(app *fiber.App) {
me.Put("/status", editStatus) me.Put("/status", editStatus)
me.Delete("/status", clearStatus) me.Delete("/status", clearStatus)
friends := me.Group("/friends").Name("Friends") friends := me.Group("/relations").Name("Relations")
{ {
friends.Get("/", listFriendship) friends.Get("/", listRelationship)
friends.Get("/:relatedId", getFriendship) friends.Get("/:relatedId", getRelationship)
friends.Post("/", makeFriendship) friends.Post("/", makeFriendship)
friends.Post("/:relatedId", makeFriendship) friends.Post("/:relatedId", makeFriendship)
friends.Put("/:relatedId", editFriendship) friends.Put("/:relatedId", editRelationship)
friends.Delete("/:relatedId", deleteFriendship) friends.Delete("/:relatedId", deleteRelationship)
} }
} }

View File

@ -17,7 +17,7 @@ func getNotifications(c *fiber.Ctx) error {
} }
user := c.Locals("user").(models.Account) user := c.Locals("user").(models.Account)
tx := database.C.Where(&models.Notification{RecipientID: user.ID}).Model(&models.Notification{}) tx := database.C.Where(&models.Notification{UserID: user.ID}).Model(&models.Notification{})
var count int64 var count int64
var notifications []models.Notification var notifications []models.Notification
@ -53,7 +53,7 @@ func markNotificationRead(c *fiber.Ctx) error {
var notify models.Notification var notify models.Notification
if err := database.C.Where(&models.Notification{ if err := database.C.Where(&models.Notification{
BaseModel: models.BaseModel{ID: uint(id)}, BaseModel: models.BaseModel{ID: uint(id)},
RecipientID: user.ID, UserID: user.ID,
}).First(&notify).Error; err != nil { }).First(&notify).Error; err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error()) return fiber.NewError(fiber.StatusNotFound, err.Error())
} }

View File

@ -11,11 +11,11 @@ func notifyUser(c *fiber.Ctx) error {
var data struct { var data struct {
ClientID string `json:"client_id" validate:"required"` ClientID string `json:"client_id" validate:"required"`
ClientSecret string `json:"client_secret" validate:"required"` ClientSecret string `json:"client_secret" validate:"required"`
Type string `json:"type" validate:"required"` Topic string `json:"type" validate:"required"`
Subject string `json:"subject" validate:"required,max=1024"` Title string `json:"subject" validate:"required,max=1024"`
Content string `json:"content" validate:"required,max=4096"` Subtitle *string `json:"subtitle" validate:"max=1024"`
Body string `json:"content" validate:"required,max=4096"`
Metadata map[string]any `json:"metadata"` Metadata map[string]any `json:"metadata"`
Links []models.NotificationLink `json:"links"`
IsForcePush bool `json:"is_force_push"` IsForcePush bool `json:"is_force_push"`
IsRealtime bool `json:"is_realtime"` IsRealtime bool `json:"is_realtime"`
UserID uint `json:"user_id" validate:"required"` UserID uint `json:"user_id" validate:"required"`
@ -36,13 +36,13 @@ func notifyUser(c *fiber.Ctx) error {
} }
notification := models.Notification{ notification := models.Notification{
Type: data.Type, Topic: data.Topic,
Subject: data.Subject, Subtitle: data.Subtitle,
Content: data.Content, Title: data.Title,
Links: data.Links, Body: data.Body,
IsRealtime: data.IsRealtime, IsRealtime: data.IsRealtime,
IsForcePush: data.IsForcePush, IsForcePush: data.IsForcePush,
RecipientID: user.ID, UserID: user.ID,
SenderID: &client.ID, SenderID: &client.ID,
} }

View File

@ -7,7 +7,7 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )
func listFriendship(c *fiber.Ctx) error { func listRelationship(c *fiber.Ctx) error {
if err := exts.EnsureAuthenticated(c); err != nil { if err := exts.EnsureAuthenticated(c); err != nil {
return err return err
} }
@ -15,13 +15,13 @@ func listFriendship(c *fiber.Ctx) error {
status := c.QueryInt("status", -1) status := c.QueryInt("status", -1)
var err error var err error
var friends []models.AccountFriendship var friends []models.AccountRelationship
if status < 0 { if status < 0 {
if friends, err = services.ListAllFriend(user); err != nil { if friends, err = services.ListAllRelationship(user); err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error()) return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} }
} else { } else {
if friends, err = services.ListFriend(user, models.FriendshipStatus(status)); err != nil { if friends, err = services.ListRelationshipWithFilter(user, models.RelationshipStatus(status)); err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error()) return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} }
} }
@ -29,7 +29,7 @@ func listFriendship(c *fiber.Ctx) error {
return c.JSON(friends) return c.JSON(friends)
} }
func getFriendship(c *fiber.Ctx) error { func getRelationship(c *fiber.Ctx) error {
if err := exts.EnsureAuthenticated(c); err != nil { if err := exts.EnsureAuthenticated(c); err != nil {
return err return err
} }
@ -41,7 +41,7 @@ func getFriendship(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusNotFound, err.Error()) return fiber.NewError(fiber.StatusNotFound, err.Error())
} }
if friend, err := services.GetFriendWithTwoSides(user.ID, related.ID); err != nil { if friend, err := services.GetRelationWithTwoNode(user.ID, related.ID); err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error()) return fiber.NewError(fiber.StatusNotFound, err.Error())
} else { } else {
return c.JSON(friend) return c.JSON(friend)
@ -72,7 +72,7 @@ func makeFriendship(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusBadRequest, "must one of username or user id") return fiber.NewError(fiber.StatusBadRequest, "must one of username or user id")
} }
friend, err := services.NewFriend(user, related, models.FriendshipPending) friend, err := services.NewFriend(user, related)
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error()) return fiber.NewError(fiber.StatusBadRequest, err.Error())
} else { } else {
@ -80,7 +80,7 @@ func makeFriendship(c *fiber.Ctx) error {
} }
} }
func editFriendship(c *fiber.Ctx) error { func editRelationship(c *fiber.Ctx) error {
if err := exts.EnsureAuthenticated(c); err != nil { if err := exts.EnsureAuthenticated(c); err != nil {
return err return err
} }
@ -89,32 +89,29 @@ func editFriendship(c *fiber.Ctx) error {
var data struct { var data struct {
Status uint8 `json:"status"` Status uint8 `json:"status"`
PermNodes map[string]any `json:"perm_nodes"`
} }
if err := exts.BindAndValidate(c, &data); err != nil { if err := exts.BindAndValidate(c, &data); err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error()) return fiber.NewError(fiber.StatusBadRequest, err.Error())
} }
related, err := services.GetAccount(uint(relatedId)) relationship, err := services.GetRelationWithTwoNode(user.ID, uint(relatedId))
if err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error())
}
friendship, err := services.GetFriendWithTwoSides(user.ID, related.ID)
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error()) return fiber.NewError(fiber.StatusNotFound, err.Error())
} }
originalStatus := friendship.Status relationship.Status = models.RelationshipStatus(data.Status)
friendship.Status = models.FriendshipStatus(data.Status) relationship.PermNodes = data.PermNodes
if friendship, err := services.EditFriendWithCheck(friendship, user, originalStatus); err != nil { if friendship, err := services.EditRelationship(relationship); err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error()) return fiber.NewError(fiber.StatusBadRequest, err.Error())
} else { } else {
return c.JSON(friendship) return c.JSON(friendship)
} }
} }
func deleteFriendship(c *fiber.Ctx) error { func deleteRelationship(c *fiber.Ctx) error {
if err := exts.EnsureAuthenticated(c); err != nil { if err := exts.EnsureAuthenticated(c); err != nil {
return err return err
} }
@ -125,14 +122,14 @@ func deleteFriendship(c *fiber.Ctx) error {
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error()) return fiber.NewError(fiber.StatusNotFound, err.Error())
} }
friendship, err := services.GetFriendWithTwoSides(user.ID, related.ID) relationship, err := services.GetRelationWithTwoNode(user.ID, related.ID)
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error()) return fiber.NewError(fiber.StatusNotFound, err.Error())
} }
if err := services.DeleteFriend(friendship); err != nil { if err := services.DeleteRelationship(relationship); err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error()) return fiber.NewError(fiber.StatusBadRequest, err.Error())
} else { } else {
return c.JSON(friendship) return c.JSON(relationship)
} }
} }

View File

@ -209,7 +209,7 @@ func DeleteAccount(id uint) error {
&models.MagicToken{}, &models.MagicToken{},
&models.ThirdClient{}, &models.ThirdClient{},
&models.NotificationSubscriber{}, &models.NotificationSubscriber{},
&models.AccountFriendship{}, &models.AccountRelationship{},
} { } {
if err := tx.Delete(model, "account_id = ?", id).Error; err != nil { if err := tx.Delete(model, "account_id = ?", id).Error; err != nil {
tx.Rollback() tx.Rollback()

View File

@ -1,125 +0,0 @@
package services
import (
"errors"
"fmt"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"gorm.io/gorm"
)
func ListAllFriend(anyside models.Account) ([]models.AccountFriendship, error) {
var relationships []models.AccountFriendship
if err := database.C.
Where("account_id = ? OR related_id = ?", anyside.ID, anyside.ID).
Preload("Account").
Preload("Related").
Find(&relationships).Error; err != nil {
return relationships, err
}
return relationships, nil
}
func ListFriend(anyside models.Account, status models.FriendshipStatus) ([]models.AccountFriendship, error) {
var relationships []models.AccountFriendship
if err := database.C.
Where("(account_id = ? OR related_id = ?) AND status = ?", anyside.ID, anyside.ID, status).
Preload("Account").
Preload("Related").
Find(&relationships).Error; err != nil {
return relationships, err
}
return relationships, nil
}
func GetFriend(anysideId uint) (models.AccountFriendship, error) {
var relationship models.AccountFriendship
if err := database.C.
Where(&models.AccountFriendship{AccountID: anysideId}).
Or(&models.AccountFriendship{RelatedID: anysideId}).
Preload("Account").
Preload("Related").
First(&relationship).Error; err != nil {
return relationship, err
}
return relationship, nil
}
func GetFriendWithTwoSides(userId, relatedId uint, noPreload ...bool) (models.AccountFriendship, error) {
var tx *gorm.DB
if len(noPreload) > 0 && noPreload[0] {
tx = database.C
} else {
tx = database.C.Preload("Account").Preload("Related")
}
var relationship models.AccountFriendship
if err := tx.
Where(&models.AccountFriendship{AccountID: userId, RelatedID: relatedId}).
Or(&models.AccountFriendship{RelatedID: userId, AccountID: relatedId}).
First(&relationship).Error; err != nil {
return relationship, err
}
return relationship, nil
}
func NewFriend(user models.Account, related models.Account, status models.FriendshipStatus) (models.AccountFriendship, error) {
relationship := models.AccountFriendship{
AccountID: user.ID,
RelatedID: related.ID,
Status: status,
}
if user.ID == related.ID {
return relationship, fmt.Errorf("you cannot make friendship with yourself")
} else if _, err := GetFriendWithTwoSides(user.ID, related.ID, true); err == nil || !errors.Is(err, gorm.ErrRecordNotFound) {
return relationship, fmt.Errorf("you already have a friendship with him or her")
}
if err := database.C.Save(&relationship).Error; err != nil {
return relationship, err
} else {
_ = NewNotification(models.Notification{
Subject: fmt.Sprintf("New friend request from %s", user.Name),
Content: fmt.Sprintf("You got a new friend request from %s. Go to your settings and decide how to deal it.", user.Nick),
RecipientID: related.ID,
})
}
return relationship, nil
}
func EditFriendWithCheck(relationship models.AccountFriendship, user models.Account, originalStatus models.FriendshipStatus) (models.AccountFriendship, error) {
if relationship.Status != originalStatus {
if originalStatus == models.FriendshipBlocked && relationship.BlockedBy != nil && user.ID != *relationship.BlockedBy {
return relationship, fmt.Errorf("the friendship has been blocked by the otherside, you cannot modify it status")
}
if relationship.Status == models.FriendshipPending && relationship.RelatedID != user.ID {
return relationship, fmt.Errorf("only related person can accept friendship")
}
}
if originalStatus != models.FriendshipBlocked && relationship.Status == models.FriendshipBlocked {
relationship.BlockedBy = &user.ID
}
return EditFriend(relationship)
}
func EditFriend(relationship models.AccountFriendship) (models.AccountFriendship, error) {
if err := database.C.Save(&relationship).Error; err != nil {
return relationship, err
}
return relationship, nil
}
func DeleteFriend(relationship models.AccountFriendship) error {
if err := database.C.Delete(&relationship).Error; err != nil {
return err
}
return nil
}

View File

@ -61,15 +61,15 @@ func NewNotification(notification models.Notification) error {
} }
// PushNotification will push the notification whatever it exists record in the // PushNotification will push the notification whatever it exists record in the
// database Recommend push another goroutine when you need to push a lot of // database Recommend pushing another goroutine when you need to push a lot of
// notifications And just use a block statement when you just push one // notifications And just use a block statement when you just push one
// notification, the time of create a new subprocess is much more than push // notification.
// notification // The time of creating a new subprocess is much more than push notification.
func PushNotification(notification models.Notification) error { func PushNotification(notification models.Notification) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() defer cancel()
_, err := proto.NewStreamControllerClient(gap.H.GetDealerGrpcConn()).PushStream(ctx, &proto.PushStreamRequest{ _, err := proto.NewStreamControllerClient(gap.H.GetDealerGrpcConn()).PushStream(ctx, &proto.PushStreamRequest{
UserId: uint64(notification.RecipientID), UserId: uint64(notification.UserID),
Body: models.UnifiedCommand{ Body: models.UnifiedCommand{
Action: "notifications.new", Action: "notifications.new",
Payload: notification, Payload: notification,
@ -80,13 +80,13 @@ func PushNotification(notification models.Notification) error {
} }
// Skip push notification // Skip push notification
if GetStatusDisturbable(notification.RecipientID) != nil { if GetStatusDisturbable(notification.UserID) != nil {
return nil return nil
} }
var subscribers []models.NotificationSubscriber var subscribers []models.NotificationSubscriber
if err := database.C.Where(&models.NotificationSubscriber{ if err := database.C.Where(&models.NotificationSubscriber{
AccountID: notification.RecipientID, AccountID: notification.UserID,
}).Find(&subscribers).Error; err != nil { }).Find(&subscribers).Error; err != nil {
return err return err
} }
@ -104,8 +104,8 @@ func PushNotification(notification models.Notification) error {
message := &messaging.Message{ message := &messaging.Message{
Notification: &messaging.Notification{ Notification: &messaging.Notification{
Title: notification.Subject, Title: notification.Title,
Body: notification.Content, Body: notification.Body,
}, },
Token: subscriber.DeviceToken, Token: subscriber.DeviceToken,
} }
@ -123,10 +123,10 @@ func PushNotification(notification models.Notification) error {
if ExtAPNS != nil { if ExtAPNS != nil {
data, err := payload2. data, err := payload2.
NewPayload(). NewPayload().
AlertTitle(notification.Subject). AlertTitle(notification.Title).
AlertBody(notification.Content). AlertBody(notification.Body).
Sound("default"). Sound("default").
Category(notification.Type). Category(notification.Topic).
MarshalJSON() MarshalJSON()
if err != nil { if err != nil {
log.Warn().Err(err).Msg("An error occurred when preparing to notify subscriber via APNs...") log.Warn().Err(err).Msg("An error occurred when preparing to notify subscriber via APNs...")

View File

@ -14,6 +14,13 @@ func HasPermNode(perms map[string]any, requiredKey string, requiredValue any) bo
return false return false
} }
func HasPermNodeWithDefault(perms map[string]any, requiredKey string, requiredValue any, defaultValue any) bool {
if heldValue, ok := perms[requiredKey]; ok {
return ComparePermNode(heldValue, requiredValue)
}
return ComparePermNode(defaultValue, requiredValue)
}
func ComparePermNode(held any, required any) bool { func ComparePermNode(held any, required any) bool {
heldValue := reflect.ValueOf(held) heldValue := reflect.ValueOf(held)
requiredValue := reflect.ValueOf(required) requiredValue := reflect.ValueOf(required)

View File

@ -97,9 +97,14 @@ func AddRealmMember(user models.Account, affected models.Account, target models.
} else if member.PowerLevel < 50 { } else if member.PowerLevel < 50 {
return fmt.Errorf("only realm moderator can add people") return fmt.Errorf("only realm moderator can add people")
} }
friendship, err := GetFriendWithTwoSides(affected.ID, user.ID) rel, err := GetRelationWithTwoNode(affected.ID, user.ID)
if err != nil || friendship.Status != models.FriendshipActive { if err != nil || HasPermNodeWithDefault(
return fmt.Errorf("you only can add your friends to your realm") rel.PermNodes,
"RealmAdd",
true,
rel.Status == models.RelationshipFriend,
) {
return fmt.Errorf("you unable to add this user to your realm")
} }
} }

View File

@ -0,0 +1,118 @@
package services
import (
"errors"
"fmt"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"gorm.io/gorm"
)
func ListAllRelationship(user models.Account) ([]models.AccountRelationship, error) {
var relationships []models.AccountRelationship
if err := database.C.
Where("account_id = ?", user.ID).
Preload("Account").
Preload("Related").
Find(&relationships).Error; err != nil {
return relationships, err
}
return relationships, nil
}
func ListRelationshipWithFilter(user models.Account, status models.RelationshipStatus) ([]models.AccountRelationship, error) {
var relationships []models.AccountRelationship
if err := database.C.
Where("account_id = ? AND status = ?", user.ID, status).
Preload("Account").
Preload("Related").
Find(&relationships).Error; err != nil {
return relationships, err
}
return relationships, nil
}
func GetRelationship(otherId uint) (models.AccountRelationship, error) {
var relationship models.AccountRelationship
if err := database.C.
Where(&models.AccountRelationship{AccountID: otherId}).
Preload("Account").
Preload("Related").
First(&relationship).Error; err != nil {
return relationship, err
}
return relationship, nil
}
func GetRelationWithTwoNode(userId, relatedId uint, noPreload ...bool) (models.AccountRelationship, error) {
var tx *gorm.DB
if len(noPreload) > 0 && noPreload[0] {
tx = database.C
} else {
tx = database.C.Preload("Account").Preload("Related")
}
var relationship models.AccountRelationship
if err := tx.
Where(&models.AccountRelationship{AccountID: userId, RelatedID: relatedId}).
First(&relationship).Error; err != nil {
return relationship, err
}
return relationship, nil
}
func NewFriend(userA models.Account, userB models.Account, skipPending ...bool) (models.AccountRelationship, error) {
relA := models.AccountRelationship{
AccountID: userA.ID,
RelatedID: userB.ID,
Status: models.RelationshipFriend,
}
relB := models.AccountRelationship{
AccountID: userB.ID,
RelatedID: userA.ID,
Status: models.RelationshipPending,
}
if len(skipPending) > 0 && skipPending[0] {
relB.Status = models.RelationshipFriend
}
if userA.ID == userB.ID {
return relA, fmt.Errorf("you cannot make friendship with yourself")
} else if _, err := GetRelationWithTwoNode(userA.ID, userB.ID, true); err == nil || !errors.Is(err, gorm.ErrRecordNotFound) {
return relA, fmt.Errorf("you already have a friendship with him or her")
}
if err := database.C.Save(&relA).Error; err != nil {
return relA, err
} else if err = database.C.Save(&relB).Error; err != nil {
return relA, err
} else {
_ = NewNotification(models.Notification{
Title: fmt.Sprintf("New friend request from %s", userA.Name),
Body: fmt.Sprintf("You got a new friend request from %s. Go to your settings and decide how to deal it.", userA.Nick),
UserID: userB.ID,
})
}
return relA, nil
}
func EditRelationship(relationship models.AccountRelationship) (models.AccountRelationship, error) {
if err := database.C.Save(&relationship).Error; err != nil {
return relationship, err
}
return relationship, nil
}
func DeleteRelationship(relationship models.AccountRelationship) error {
if err := database.C.Delete(&relationship).Error; err != nil {
return err
}
return nil
}

View File

@ -1,400 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.2
// protoc v5.27.1
// source: friendships.proto
package proto
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type FriendshipLookupRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
AccountId uint64 `protobuf:"varint,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"`
Status uint32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
}
func (x *FriendshipLookupRequest) Reset() {
*x = FriendshipLookupRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_friendships_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FriendshipLookupRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FriendshipLookupRequest) ProtoMessage() {}
func (x *FriendshipLookupRequest) ProtoReflect() protoreflect.Message {
mi := &file_friendships_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FriendshipLookupRequest.ProtoReflect.Descriptor instead.
func (*FriendshipLookupRequest) Descriptor() ([]byte, []int) {
return file_friendships_proto_rawDescGZIP(), []int{0}
}
func (x *FriendshipLookupRequest) GetAccountId() uint64 {
if x != nil {
return x.AccountId
}
return 0
}
func (x *FriendshipLookupRequest) GetStatus() uint32 {
if x != nil {
return x.Status
}
return 0
}
type FriendshipTwoSideLookupRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
AccountId uint64 `protobuf:"varint,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"`
RelatedId uint64 `protobuf:"varint,2,opt,name=related_id,json=relatedId,proto3" json:"related_id,omitempty"`
Status uint32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"`
}
func (x *FriendshipTwoSideLookupRequest) Reset() {
*x = FriendshipTwoSideLookupRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_friendships_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FriendshipTwoSideLookupRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FriendshipTwoSideLookupRequest) ProtoMessage() {}
func (x *FriendshipTwoSideLookupRequest) ProtoReflect() protoreflect.Message {
mi := &file_friendships_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FriendshipTwoSideLookupRequest.ProtoReflect.Descriptor instead.
func (*FriendshipTwoSideLookupRequest) Descriptor() ([]byte, []int) {
return file_friendships_proto_rawDescGZIP(), []int{1}
}
func (x *FriendshipTwoSideLookupRequest) GetAccountId() uint64 {
if x != nil {
return x.AccountId
}
return 0
}
func (x *FriendshipTwoSideLookupRequest) GetRelatedId() uint64 {
if x != nil {
return x.RelatedId
}
return 0
}
func (x *FriendshipTwoSideLookupRequest) GetStatus() uint32 {
if x != nil {
return x.Status
}
return 0
}
type FriendshipResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
AccountId uint64 `protobuf:"varint,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"`
RelatedId uint64 `protobuf:"varint,2,opt,name=related_id,json=relatedId,proto3" json:"related_id,omitempty"`
Status uint32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"`
}
func (x *FriendshipResponse) Reset() {
*x = FriendshipResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_friendships_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FriendshipResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FriendshipResponse) ProtoMessage() {}
func (x *FriendshipResponse) ProtoReflect() protoreflect.Message {
mi := &file_friendships_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FriendshipResponse.ProtoReflect.Descriptor instead.
func (*FriendshipResponse) Descriptor() ([]byte, []int) {
return file_friendships_proto_rawDescGZIP(), []int{2}
}
func (x *FriendshipResponse) GetAccountId() uint64 {
if x != nil {
return x.AccountId
}
return 0
}
func (x *FriendshipResponse) GetRelatedId() uint64 {
if x != nil {
return x.RelatedId
}
return 0
}
func (x *FriendshipResponse) GetStatus() uint32 {
if x != nil {
return x.Status
}
return 0
}
type ListFriendshipResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []*FriendshipResponse `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
}
func (x *ListFriendshipResponse) Reset() {
*x = ListFriendshipResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_friendships_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListFriendshipResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListFriendshipResponse) ProtoMessage() {}
func (x *ListFriendshipResponse) ProtoReflect() protoreflect.Message {
mi := &file_friendships_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListFriendshipResponse.ProtoReflect.Descriptor instead.
func (*ListFriendshipResponse) Descriptor() ([]byte, []int) {
return file_friendships_proto_rawDescGZIP(), []int{3}
}
func (x *ListFriendshipResponse) GetData() []*FriendshipResponse {
if x != nil {
return x.Data
}
return nil
}
var File_friendships_proto protoreflect.FileDescriptor
var file_friendships_proto_rawDesc = []byte{
0x0a, 0x11, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x68, 0x69, 0x70, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x50, 0x0a, 0x17, 0x46, 0x72,
0x69, 0x65, 0x6e, 0x64, 0x73, 0x68, 0x69, 0x70, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75,
0x6e, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02,
0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x76, 0x0a, 0x1e,
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x68, 0x69, 0x70, 0x54, 0x77, 0x6f, 0x53, 0x69, 0x64,
0x65, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d,
0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x04, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1d, 0x0a,
0x0a, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
0x04, 0x52, 0x09, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06,
0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x74,
0x61, 0x74, 0x75, 0x73, 0x22, 0x6a, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x68,
0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09,
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x6c,
0x61, 0x74, 0x65, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72,
0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74,
0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
0x22, 0x47, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x68,
0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x64, 0x61,
0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0xb5, 0x01, 0x0a, 0x0b, 0x46, 0x72,
0x69, 0x65, 0x6e, 0x64, 0x73, 0x68, 0x69, 0x70, 0x73, 0x12, 0x51, 0x0a, 0x0e, 0x4c, 0x69, 0x73,
0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x68, 0x69, 0x70, 0x12, 0x1e, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x68, 0x69, 0x70, 0x4c, 0x6f,
0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x68,
0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x0d,
0x47, 0x65, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x68, 0x69, 0x70, 0x12, 0x25, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x68, 0x69, 0x70,
0x54, 0x77, 0x6f, 0x53, 0x69, 0x64, 0x65, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x72, 0x69,
0x65, 0x6e, 0x64, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
file_friendships_proto_rawDescOnce sync.Once
file_friendships_proto_rawDescData = file_friendships_proto_rawDesc
)
func file_friendships_proto_rawDescGZIP() []byte {
file_friendships_proto_rawDescOnce.Do(func() {
file_friendships_proto_rawDescData = protoimpl.X.CompressGZIP(file_friendships_proto_rawDescData)
})
return file_friendships_proto_rawDescData
}
var file_friendships_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_friendships_proto_goTypes = []any{
(*FriendshipLookupRequest)(nil), // 0: proto.FriendshipLookupRequest
(*FriendshipTwoSideLookupRequest)(nil), // 1: proto.FriendshipTwoSideLookupRequest
(*FriendshipResponse)(nil), // 2: proto.FriendshipResponse
(*ListFriendshipResponse)(nil), // 3: proto.ListFriendshipResponse
}
var file_friendships_proto_depIdxs = []int32{
2, // 0: proto.ListFriendshipResponse.data:type_name -> proto.FriendshipResponse
0, // 1: proto.Friendships.ListFriendship:input_type -> proto.FriendshipLookupRequest
1, // 2: proto.Friendships.GetFriendship:input_type -> proto.FriendshipTwoSideLookupRequest
3, // 3: proto.Friendships.ListFriendship:output_type -> proto.ListFriendshipResponse
2, // 4: proto.Friendships.GetFriendship:output_type -> proto.FriendshipResponse
3, // [3:5] is the sub-list for method output_type
1, // [1:3] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_friendships_proto_init() }
func file_friendships_proto_init() {
if File_friendships_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_friendships_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*FriendshipLookupRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_friendships_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*FriendshipTwoSideLookupRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_friendships_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*FriendshipResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_friendships_proto_msgTypes[3].Exporter = func(v any, i int) any {
switch v := v.(*ListFriendshipResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_friendships_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_friendships_proto_goTypes,
DependencyIndexes: file_friendships_proto_depIdxs,
MessageInfos: file_friendships_proto_msgTypes,
}.Build()
File_friendships_proto = out.File
file_friendships_proto_rawDesc = nil
file_friendships_proto_goTypes = nil
file_friendships_proto_depIdxs = nil
}

View File

@ -1,31 +0,0 @@
syntax = "proto3";
option go_package = ".;proto";
package proto;
service Friendships {
rpc ListFriendship(FriendshipLookupRequest) returns (ListFriendshipResponse) {}
rpc GetFriendship(FriendshipTwoSideLookupRequest) returns (FriendshipResponse) {}
}
message FriendshipLookupRequest {
uint64 account_id = 1;
uint32 status = 2;
}
message FriendshipTwoSideLookupRequest {
uint64 account_id = 1;
uint64 related_id = 2;
uint32 status = 3;
}
message FriendshipResponse {
uint64 account_id = 1;
uint64 related_id = 2;
uint32 status = 3;
}
message ListFriendshipResponse {
repeated FriendshipResponse data = 1;
}

View File

@ -1,148 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.4.0
// - protoc v5.27.1
// source: friendships.proto
package proto
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.62.0 or later.
const _ = grpc.SupportPackageIsVersion8
const (
Friendships_ListFriendship_FullMethodName = "/proto.Friendships/ListFriendship"
Friendships_GetFriendship_FullMethodName = "/proto.Friendships/GetFriendship"
)
// FriendshipsClient is the client API for Friendships service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type FriendshipsClient interface {
ListFriendship(ctx context.Context, in *FriendshipLookupRequest, opts ...grpc.CallOption) (*ListFriendshipResponse, error)
GetFriendship(ctx context.Context, in *FriendshipTwoSideLookupRequest, opts ...grpc.CallOption) (*FriendshipResponse, error)
}
type friendshipsClient struct {
cc grpc.ClientConnInterface
}
func NewFriendshipsClient(cc grpc.ClientConnInterface) FriendshipsClient {
return &friendshipsClient{cc}
}
func (c *friendshipsClient) ListFriendship(ctx context.Context, in *FriendshipLookupRequest, opts ...grpc.CallOption) (*ListFriendshipResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListFriendshipResponse)
err := c.cc.Invoke(ctx, Friendships_ListFriendship_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *friendshipsClient) GetFriendship(ctx context.Context, in *FriendshipTwoSideLookupRequest, opts ...grpc.CallOption) (*FriendshipResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(FriendshipResponse)
err := c.cc.Invoke(ctx, Friendships_GetFriendship_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// FriendshipsServer is the server API for Friendships service.
// All implementations must embed UnimplementedFriendshipsServer
// for forward compatibility
type FriendshipsServer interface {
ListFriendship(context.Context, *FriendshipLookupRequest) (*ListFriendshipResponse, error)
GetFriendship(context.Context, *FriendshipTwoSideLookupRequest) (*FriendshipResponse, error)
mustEmbedUnimplementedFriendshipsServer()
}
// UnimplementedFriendshipsServer must be embedded to have forward compatible implementations.
type UnimplementedFriendshipsServer struct {
}
func (UnimplementedFriendshipsServer) ListFriendship(context.Context, *FriendshipLookupRequest) (*ListFriendshipResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListFriendship not implemented")
}
func (UnimplementedFriendshipsServer) GetFriendship(context.Context, *FriendshipTwoSideLookupRequest) (*FriendshipResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetFriendship not implemented")
}
func (UnimplementedFriendshipsServer) mustEmbedUnimplementedFriendshipsServer() {}
// UnsafeFriendshipsServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to FriendshipsServer will
// result in compilation errors.
type UnsafeFriendshipsServer interface {
mustEmbedUnimplementedFriendshipsServer()
}
func RegisterFriendshipsServer(s grpc.ServiceRegistrar, srv FriendshipsServer) {
s.RegisterService(&Friendships_ServiceDesc, srv)
}
func _Friendships_ListFriendship_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FriendshipLookupRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(FriendshipsServer).ListFriendship(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Friendships_ListFriendship_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(FriendshipsServer).ListFriendship(ctx, req.(*FriendshipLookupRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Friendships_GetFriendship_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FriendshipTwoSideLookupRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(FriendshipsServer).GetFriendship(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Friendships_GetFriendship_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(FriendshipsServer).GetFriendship(ctx, req.(*FriendshipTwoSideLookupRequest))
}
return interceptor(ctx, in, info, handler)
}
// Friendships_ServiceDesc is the grpc.ServiceDesc for Friendships service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Friendships_ServiceDesc = grpc.ServiceDesc{
ServiceName: "proto.Friendships",
HandlerType: (*FriendshipsServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ListFriendship",
Handler: _Friendships_ListFriendship_Handler,
},
{
MethodName: "GetFriendship",
Handler: _Friendships_GetFriendship_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "friendships.proto",
}

View File

@ -1,373 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.2
// protoc v5.27.1
// source: notify.proto
package proto
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type NotifyLink struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"`
Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
}
func (x *NotifyLink) Reset() {
*x = NotifyLink{}
if protoimpl.UnsafeEnabled {
mi := &file_notify_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NotifyLink) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NotifyLink) ProtoMessage() {}
func (x *NotifyLink) ProtoReflect() protoreflect.Message {
mi := &file_notify_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NotifyLink.ProtoReflect.Descriptor instead.
func (*NotifyLink) Descriptor() ([]byte, []int) {
return file_notify_proto_rawDescGZIP(), []int{0}
}
func (x *NotifyLink) GetLabel() string {
if x != nil {
return x.Label
}
return ""
}
func (x *NotifyLink) GetUrl() string {
if x != nil {
return x.Url
}
return ""
}
type NotifyRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
Subject string `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"`
Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"`
Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
Links []*NotifyLink `protobuf:"bytes,5,rep,name=links,proto3" json:"links,omitempty"`
RecipientId uint64 `protobuf:"varint,6,opt,name=recipient_id,json=recipientId,proto3" json:"recipient_id,omitempty"`
ClientId string `protobuf:"bytes,7,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
ClientSecret string `protobuf:"bytes,8,opt,name=client_secret,json=clientSecret,proto3" json:"client_secret,omitempty"`
IsRealtime bool `protobuf:"varint,9,opt,name=is_realtime,json=isRealtime,proto3" json:"is_realtime,omitempty"`
IsForcePush bool `protobuf:"varint,10,opt,name=is_force_push,json=isForcePush,proto3" json:"is_force_push,omitempty"`
}
func (x *NotifyRequest) Reset() {
*x = NotifyRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_notify_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NotifyRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NotifyRequest) ProtoMessage() {}
func (x *NotifyRequest) ProtoReflect() protoreflect.Message {
mi := &file_notify_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NotifyRequest.ProtoReflect.Descriptor instead.
func (*NotifyRequest) Descriptor() ([]byte, []int) {
return file_notify_proto_rawDescGZIP(), []int{1}
}
func (x *NotifyRequest) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *NotifyRequest) GetSubject() string {
if x != nil {
return x.Subject
}
return ""
}
func (x *NotifyRequest) GetContent() string {
if x != nil {
return x.Content
}
return ""
}
func (x *NotifyRequest) GetMetadata() []byte {
if x != nil {
return x.Metadata
}
return nil
}
func (x *NotifyRequest) GetLinks() []*NotifyLink {
if x != nil {
return x.Links
}
return nil
}
func (x *NotifyRequest) GetRecipientId() uint64 {
if x != nil {
return x.RecipientId
}
return 0
}
func (x *NotifyRequest) GetClientId() string {
if x != nil {
return x.ClientId
}
return ""
}
func (x *NotifyRequest) GetClientSecret() string {
if x != nil {
return x.ClientSecret
}
return ""
}
func (x *NotifyRequest) GetIsRealtime() bool {
if x != nil {
return x.IsRealtime
}
return false
}
func (x *NotifyRequest) GetIsForcePush() bool {
if x != nil {
return x.IsForcePush
}
return false
}
type NotifyReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsSent bool `protobuf:"varint,1,opt,name=is_sent,json=isSent,proto3" json:"is_sent,omitempty"`
}
func (x *NotifyReply) Reset() {
*x = NotifyReply{}
if protoimpl.UnsafeEnabled {
mi := &file_notify_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NotifyReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NotifyReply) ProtoMessage() {}
func (x *NotifyReply) ProtoReflect() protoreflect.Message {
mi := &file_notify_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NotifyReply.ProtoReflect.Descriptor instead.
func (*NotifyReply) Descriptor() ([]byte, []int) {
return file_notify_proto_rawDescGZIP(), []int{2}
}
func (x *NotifyReply) GetIsSent() bool {
if x != nil {
return x.IsSent
}
return false
}
var File_notify_proto protoreflect.FileDescriptor
var file_notify_proto_rawDesc = []byte{
0x0a, 0x0c, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x34, 0x0a, 0x0a, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x4c,
0x69, 0x6e, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0xc6, 0x02, 0x0a, 0x0d,
0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a,
0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70,
0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63,
0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f,
0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
0x61, 0x12, 0x27, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x4c,
0x69, 0x6e, 0x6b, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x72, 0x65,
0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04,
0x52, 0x0b, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1b, 0x0a,
0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12,
0x1f, 0x0a, 0x0b, 0x69, 0x73, 0x5f, 0x72, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x09,
0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65,
0x12, 0x22, 0x0a, 0x0d, 0x69, 0x73, 0x5f, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x75, 0x73,
0x68, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x46, 0x6f, 0x72, 0x63, 0x65,
0x50, 0x75, 0x73, 0x68, 0x22, 0x26, 0x0a, 0x0b, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65,
0x70, 0x6c, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x69, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x32, 0x42, 0x0a, 0x06,
0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x12, 0x38, 0x0a, 0x0a, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79,
0x55, 0x73, 0x65, 0x72, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74,
0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00,
0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
file_notify_proto_rawDescOnce sync.Once
file_notify_proto_rawDescData = file_notify_proto_rawDesc
)
func file_notify_proto_rawDescGZIP() []byte {
file_notify_proto_rawDescOnce.Do(func() {
file_notify_proto_rawDescData = protoimpl.X.CompressGZIP(file_notify_proto_rawDescData)
})
return file_notify_proto_rawDescData
}
var file_notify_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_notify_proto_goTypes = []any{
(*NotifyLink)(nil), // 0: proto.NotifyLink
(*NotifyRequest)(nil), // 1: proto.NotifyRequest
(*NotifyReply)(nil), // 2: proto.NotifyReply
}
var file_notify_proto_depIdxs = []int32{
0, // 0: proto.NotifyRequest.links:type_name -> proto.NotifyLink
1, // 1: proto.Notify.NotifyUser:input_type -> proto.NotifyRequest
2, // 2: proto.Notify.NotifyUser:output_type -> proto.NotifyReply
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_notify_proto_init() }
func file_notify_proto_init() {
if File_notify_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_notify_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*NotifyLink); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_notify_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*NotifyRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_notify_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*NotifyReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_notify_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_notify_proto_goTypes,
DependencyIndexes: file_notify_proto_depIdxs,
MessageInfos: file_notify_proto_msgTypes,
}.Build()
File_notify_proto = out.File
file_notify_proto_rawDesc = nil
file_notify_proto_goTypes = nil
file_notify_proto_depIdxs = nil
}

View File

@ -1,31 +0,0 @@
syntax = "proto3";
option go_package = ".;proto";
package proto;
service Notify {
rpc NotifyUser(NotifyRequest) returns (NotifyReply) {}
}
message NotifyLink {
string label = 1;
string url = 2;
}
message NotifyRequest {
string type = 1;
string subject = 2;
string content = 3;
bytes metadata = 4;
repeated NotifyLink links = 5;
uint64 recipient_id = 6;
string client_id = 7;
string client_secret = 8;
bool is_realtime = 9;
bool is_force_push = 10;
}
message NotifyReply {
bool is_sent = 1;
}

View File

@ -1,110 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.4.0
// - protoc v5.27.1
// source: notify.proto
package proto
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.62.0 or later.
const _ = grpc.SupportPackageIsVersion8
const (
Notify_NotifyUser_FullMethodName = "/proto.Notify/NotifyUser"
)
// NotifyClient is the client API for Notify service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type NotifyClient interface {
NotifyUser(ctx context.Context, in *NotifyRequest, opts ...grpc.CallOption) (*NotifyReply, error)
}
type notifyClient struct {
cc grpc.ClientConnInterface
}
func NewNotifyClient(cc grpc.ClientConnInterface) NotifyClient {
return &notifyClient{cc}
}
func (c *notifyClient) NotifyUser(ctx context.Context, in *NotifyRequest, opts ...grpc.CallOption) (*NotifyReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(NotifyReply)
err := c.cc.Invoke(ctx, Notify_NotifyUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// NotifyServer is the server API for Notify service.
// All implementations must embed UnimplementedNotifyServer
// for forward compatibility
type NotifyServer interface {
NotifyUser(context.Context, *NotifyRequest) (*NotifyReply, error)
mustEmbedUnimplementedNotifyServer()
}
// UnimplementedNotifyServer must be embedded to have forward compatible implementations.
type UnimplementedNotifyServer struct {
}
func (UnimplementedNotifyServer) NotifyUser(context.Context, *NotifyRequest) (*NotifyReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method NotifyUser not implemented")
}
func (UnimplementedNotifyServer) mustEmbedUnimplementedNotifyServer() {}
// UnsafeNotifyServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to NotifyServer will
// result in compilation errors.
type UnsafeNotifyServer interface {
mustEmbedUnimplementedNotifyServer()
}
func RegisterNotifyServer(s grpc.ServiceRegistrar, srv NotifyServer) {
s.RegisterService(&Notify_ServiceDesc, srv)
}
func _Notify_NotifyUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(NotifyRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NotifyServer).NotifyUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Notify_NotifyUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NotifyServer).NotifyUser(ctx, req.(*NotifyRequest))
}
return interceptor(ctx, in, info, handler)
}
// Notify_ServiceDesc is the grpc.ServiceDesc for Notify service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Notify_ServiceDesc = grpc.ServiceDesc{
ServiceName: "proto.Notify",
HandlerType: (*NotifyServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "NotifyUser",
Handler: _Notify_NotifyUser_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "notify.proto",
}

View File

@ -1,685 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.2
// protoc v5.27.1
// source: realms.proto
package proto
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type RealmLookupWithUserRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
}
func (x *RealmLookupWithUserRequest) Reset() {
*x = RealmLookupWithUserRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_realms_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RealmLookupWithUserRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RealmLookupWithUserRequest) ProtoMessage() {}
func (x *RealmLookupWithUserRequest) ProtoReflect() protoreflect.Message {
mi := &file_realms_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RealmLookupWithUserRequest.ProtoReflect.Descriptor instead.
func (*RealmLookupWithUserRequest) Descriptor() ([]byte, []int) {
return file_realms_proto_rawDescGZIP(), []int{0}
}
func (x *RealmLookupWithUserRequest) GetUserId() uint64 {
if x != nil {
return x.UserId
}
return 0
}
type RealmLookupRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id *uint64 `protobuf:"varint,1,opt,name=id,proto3,oneof" json:"id,omitempty"`
Alias *string `protobuf:"bytes,2,opt,name=alias,proto3,oneof" json:"alias,omitempty"`
IsPublic *bool `protobuf:"varint,3,opt,name=is_public,json=isPublic,proto3,oneof" json:"is_public,omitempty"`
IsCommunity *bool `protobuf:"varint,4,opt,name=is_community,json=isCommunity,proto3,oneof" json:"is_community,omitempty"`
}
func (x *RealmLookupRequest) Reset() {
*x = RealmLookupRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_realms_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RealmLookupRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RealmLookupRequest) ProtoMessage() {}
func (x *RealmLookupRequest) ProtoReflect() protoreflect.Message {
mi := &file_realms_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RealmLookupRequest.ProtoReflect.Descriptor instead.
func (*RealmLookupRequest) Descriptor() ([]byte, []int) {
return file_realms_proto_rawDescGZIP(), []int{1}
}
func (x *RealmLookupRequest) GetId() uint64 {
if x != nil && x.Id != nil {
return *x.Id
}
return 0
}
func (x *RealmLookupRequest) GetAlias() string {
if x != nil && x.Alias != nil {
return *x.Alias
}
return ""
}
func (x *RealmLookupRequest) GetIsPublic() bool {
if x != nil && x.IsPublic != nil {
return *x.IsPublic
}
return false
}
func (x *RealmLookupRequest) GetIsCommunity() bool {
if x != nil && x.IsCommunity != nil {
return *x.IsCommunity
}
return false
}
type RealmResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Alias string `protobuf:"bytes,2,opt,name=alias,proto3" json:"alias,omitempty"`
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
IsPublic bool `protobuf:"varint,5,opt,name=is_public,json=isPublic,proto3" json:"is_public,omitempty"`
IsCommunity bool `protobuf:"varint,6,opt,name=is_community,json=isCommunity,proto3" json:"is_community,omitempty"`
}
func (x *RealmResponse) Reset() {
*x = RealmResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_realms_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RealmResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RealmResponse) ProtoMessage() {}
func (x *RealmResponse) ProtoReflect() protoreflect.Message {
mi := &file_realms_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RealmResponse.ProtoReflect.Descriptor instead.
func (*RealmResponse) Descriptor() ([]byte, []int) {
return file_realms_proto_rawDescGZIP(), []int{2}
}
func (x *RealmResponse) GetId() uint64 {
if x != nil {
return x.Id
}
return 0
}
func (x *RealmResponse) GetAlias() string {
if x != nil {
return x.Alias
}
return ""
}
func (x *RealmResponse) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *RealmResponse) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
func (x *RealmResponse) GetIsPublic() bool {
if x != nil {
return x.IsPublic
}
return false
}
func (x *RealmResponse) GetIsCommunity() bool {
if x != nil {
return x.IsCommunity
}
return false
}
type ListRealmResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []*RealmResponse `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
}
func (x *ListRealmResponse) Reset() {
*x = ListRealmResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_realms_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListRealmResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListRealmResponse) ProtoMessage() {}
func (x *ListRealmResponse) ProtoReflect() protoreflect.Message {
mi := &file_realms_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListRealmResponse.ProtoReflect.Descriptor instead.
func (*ListRealmResponse) Descriptor() ([]byte, []int) {
return file_realms_proto_rawDescGZIP(), []int{3}
}
func (x *ListRealmResponse) GetData() []*RealmResponse {
if x != nil {
return x.Data
}
return nil
}
type RealmMemberLookupRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RealmId uint64 `protobuf:"varint,1,opt,name=realm_id,json=realmId,proto3" json:"realm_id,omitempty"`
UserId *uint64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3,oneof" json:"user_id,omitempty"`
}
func (x *RealmMemberLookupRequest) Reset() {
*x = RealmMemberLookupRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_realms_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RealmMemberLookupRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RealmMemberLookupRequest) ProtoMessage() {}
func (x *RealmMemberLookupRequest) ProtoReflect() protoreflect.Message {
mi := &file_realms_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RealmMemberLookupRequest.ProtoReflect.Descriptor instead.
func (*RealmMemberLookupRequest) Descriptor() ([]byte, []int) {
return file_realms_proto_rawDescGZIP(), []int{4}
}
func (x *RealmMemberLookupRequest) GetRealmId() uint64 {
if x != nil {
return x.RealmId
}
return 0
}
func (x *RealmMemberLookupRequest) GetUserId() uint64 {
if x != nil && x.UserId != nil {
return *x.UserId
}
return 0
}
type RealmMemberResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RealmId uint64 `protobuf:"varint,1,opt,name=realm_id,json=realmId,proto3" json:"realm_id,omitempty"`
UserId uint64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
PowerLevel int32 `protobuf:"varint,3,opt,name=power_level,json=powerLevel,proto3" json:"power_level,omitempty"`
}
func (x *RealmMemberResponse) Reset() {
*x = RealmMemberResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_realms_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RealmMemberResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RealmMemberResponse) ProtoMessage() {}
func (x *RealmMemberResponse) ProtoReflect() protoreflect.Message {
mi := &file_realms_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RealmMemberResponse.ProtoReflect.Descriptor instead.
func (*RealmMemberResponse) Descriptor() ([]byte, []int) {
return file_realms_proto_rawDescGZIP(), []int{5}
}
func (x *RealmMemberResponse) GetRealmId() uint64 {
if x != nil {
return x.RealmId
}
return 0
}
func (x *RealmMemberResponse) GetUserId() uint64 {
if x != nil {
return x.UserId
}
return 0
}
func (x *RealmMemberResponse) GetPowerLevel() int32 {
if x != nil {
return x.PowerLevel
}
return 0
}
type ListRealmMemberResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []*RealmMemberResponse `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
}
func (x *ListRealmMemberResponse) Reset() {
*x = ListRealmMemberResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_realms_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListRealmMemberResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListRealmMemberResponse) ProtoMessage() {}
func (x *ListRealmMemberResponse) ProtoReflect() protoreflect.Message {
mi := &file_realms_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListRealmMemberResponse.ProtoReflect.Descriptor instead.
func (*ListRealmMemberResponse) Descriptor() ([]byte, []int) {
return file_realms_proto_rawDescGZIP(), []int{6}
}
func (x *ListRealmMemberResponse) GetData() []*RealmMemberResponse {
if x != nil {
return x.Data
}
return nil
}
var File_realms_proto protoreflect.FileDescriptor
var file_realms_proto_rawDesc = []byte{
0x0a, 0x0c, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x22, 0x35, 0x0a, 0x1a, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75,
0x70, 0x57, 0x69, 0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0xbe, 0x01, 0x0a, 0x12, 0x52, 0x65,
0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x13, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x02,
0x69, 0x64, 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x88, 0x01, 0x01,
0x12, 0x20, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x03, 0x20,
0x01, 0x28, 0x08, 0x48, 0x02, 0x52, 0x08, 0x69, 0x73, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x88,
0x01, 0x01, 0x12, 0x26, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69,
0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, 0x03, 0x52, 0x0b, 0x69, 0x73, 0x43, 0x6f,
0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x42, 0x05, 0x0a, 0x03, 0x5f, 0x69,
0x64, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x42, 0x0c, 0x0a, 0x0a, 0x5f,
0x69, 0x73, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x69, 0x73,
0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x22, 0xab, 0x01, 0x0a, 0x0d, 0x52,
0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05,
0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x6c, 0x69,
0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69,
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73,
0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x70,
0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x50,
0x75, 0x62, 0x6c, 0x69, 0x63, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d,
0x75, 0x6e, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x43,
0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x22, 0x3d, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74,
0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x5f, 0x0a, 0x18, 0x52, 0x65, 0x61, 0x6c, 0x6d,
0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x5f, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x49, 0x64, 0x12, 0x1c,
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x48,
0x00, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08,
0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x22, 0x6a, 0x0a, 0x13, 0x52, 0x65, 0x61, 0x6c,
0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x19, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x04, 0x52, 0x07, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73,
0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65,
0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76,
0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x4c,
0x65, 0x76, 0x65, 0x6c, 0x22, 0x49, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c,
0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x2e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65,
0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32,
0xde, 0x03, 0x0a, 0x06, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x73, 0x12, 0x48, 0x0a, 0x12, 0x4c, 0x69,
0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x52, 0x65, 0x61, 0x6c, 0x6d,
0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x76, 0x61, 0x69,
0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x21, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x57, 0x69,
0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x0e, 0x4c, 0x69, 0x73,
0x74, 0x4f, 0x77, 0x6e, 0x65, 0x64, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x21, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x57,
0x69, 0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x08, 0x47, 0x65,
0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52,
0x65, 0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0f, 0x4c, 0x69, 0x73,
0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1f, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72,
0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d,
0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x4f, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65,
0x72, 0x12, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d,
0x65, 0x6d, 0x62, 0x65, 0x72, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d,
0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
file_realms_proto_rawDescOnce sync.Once
file_realms_proto_rawDescData = file_realms_proto_rawDesc
)
func file_realms_proto_rawDescGZIP() []byte {
file_realms_proto_rawDescOnce.Do(func() {
file_realms_proto_rawDescData = protoimpl.X.CompressGZIP(file_realms_proto_rawDescData)
})
return file_realms_proto_rawDescData
}
var file_realms_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_realms_proto_goTypes = []any{
(*RealmLookupWithUserRequest)(nil), // 0: proto.RealmLookupWithUserRequest
(*RealmLookupRequest)(nil), // 1: proto.RealmLookupRequest
(*RealmResponse)(nil), // 2: proto.RealmResponse
(*ListRealmResponse)(nil), // 3: proto.ListRealmResponse
(*RealmMemberLookupRequest)(nil), // 4: proto.RealmMemberLookupRequest
(*RealmMemberResponse)(nil), // 5: proto.RealmMemberResponse
(*ListRealmMemberResponse)(nil), // 6: proto.ListRealmMemberResponse
(*emptypb.Empty)(nil), // 7: google.protobuf.Empty
}
var file_realms_proto_depIdxs = []int32{
2, // 0: proto.ListRealmResponse.data:type_name -> proto.RealmResponse
5, // 1: proto.ListRealmMemberResponse.data:type_name -> proto.RealmMemberResponse
7, // 2: proto.Realms.ListCommunityRealm:input_type -> google.protobuf.Empty
0, // 3: proto.Realms.ListAvailableRealm:input_type -> proto.RealmLookupWithUserRequest
0, // 4: proto.Realms.ListOwnedRealm:input_type -> proto.RealmLookupWithUserRequest
1, // 5: proto.Realms.GetRealm:input_type -> proto.RealmLookupRequest
4, // 6: proto.Realms.ListRealmMember:input_type -> proto.RealmMemberLookupRequest
4, // 7: proto.Realms.GetRealmMember:input_type -> proto.RealmMemberLookupRequest
3, // 8: proto.Realms.ListCommunityRealm:output_type -> proto.ListRealmResponse
3, // 9: proto.Realms.ListAvailableRealm:output_type -> proto.ListRealmResponse
3, // 10: proto.Realms.ListOwnedRealm:output_type -> proto.ListRealmResponse
2, // 11: proto.Realms.GetRealm:output_type -> proto.RealmResponse
6, // 12: proto.Realms.ListRealmMember:output_type -> proto.ListRealmMemberResponse
5, // 13: proto.Realms.GetRealmMember:output_type -> proto.RealmMemberResponse
8, // [8:14] is the sub-list for method output_type
2, // [2:8] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_realms_proto_init() }
func file_realms_proto_init() {
if File_realms_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_realms_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*RealmLookupWithUserRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_realms_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*RealmLookupRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_realms_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*RealmResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_realms_proto_msgTypes[3].Exporter = func(v any, i int) any {
switch v := v.(*ListRealmResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_realms_proto_msgTypes[4].Exporter = func(v any, i int) any {
switch v := v.(*RealmMemberLookupRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_realms_proto_msgTypes[5].Exporter = func(v any, i int) any {
switch v := v.(*RealmMemberResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_realms_proto_msgTypes[6].Exporter = func(v any, i int) any {
switch v := v.(*ListRealmMemberResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_realms_proto_msgTypes[1].OneofWrappers = []any{}
file_realms_proto_msgTypes[4].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_realms_proto_rawDesc,
NumEnums: 0,
NumMessages: 7,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_realms_proto_goTypes,
DependencyIndexes: file_realms_proto_depIdxs,
MessageInfos: file_realms_proto_msgTypes,
}.Build()
File_realms_proto = out.File
file_realms_proto_rawDesc = nil
file_realms_proto_goTypes = nil
file_realms_proto_depIdxs = nil
}

View File

@ -1,55 +0,0 @@
syntax = "proto3";
import "google/protobuf/empty.proto";
option go_package = ".;proto";
package proto;
service Realms {
rpc ListCommunityRealm(google.protobuf.Empty) returns (ListRealmResponse) {}
rpc ListAvailableRealm(RealmLookupWithUserRequest) returns (ListRealmResponse) {}
rpc ListOwnedRealm(RealmLookupWithUserRequest) returns (ListRealmResponse) {}
rpc GetRealm(RealmLookupRequest) returns (RealmResponse) {}
rpc ListRealmMember(RealmMemberLookupRequest) returns (ListRealmMemberResponse) {}
rpc GetRealmMember(RealmMemberLookupRequest) returns (RealmMemberResponse) {}
}
message RealmLookupWithUserRequest {
uint64 user_id = 1;
}
message RealmLookupRequest {
optional uint64 id = 1;
optional string alias = 2;
optional bool is_public = 3;
optional bool is_community = 4;
}
message RealmResponse {
uint64 id = 1;
string alias = 2;
string name = 3;
string description = 4;
bool is_public = 5;
bool is_community = 6;
}
message ListRealmResponse {
repeated RealmResponse data = 1;
}
message RealmMemberLookupRequest {
uint64 realm_id = 1;
optional uint64 user_id = 2;
}
message RealmMemberResponse {
uint64 realm_id = 1;
uint64 user_id = 2;
int32 power_level = 3;
}
message ListRealmMemberResponse {
repeated RealmMemberResponse data = 1;
}

View File

@ -1,301 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.4.0
// - protoc v5.27.1
// source: realms.proto
package proto
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
emptypb "google.golang.org/protobuf/types/known/emptypb"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.62.0 or later.
const _ = grpc.SupportPackageIsVersion8
const (
Realms_ListCommunityRealm_FullMethodName = "/proto.Realms/ListCommunityRealm"
Realms_ListAvailableRealm_FullMethodName = "/proto.Realms/ListAvailableRealm"
Realms_ListOwnedRealm_FullMethodName = "/proto.Realms/ListOwnedRealm"
Realms_GetRealm_FullMethodName = "/proto.Realms/GetRealm"
Realms_ListRealmMember_FullMethodName = "/proto.Realms/ListRealmMember"
Realms_GetRealmMember_FullMethodName = "/proto.Realms/GetRealmMember"
)
// RealmsClient is the client API for Realms service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type RealmsClient interface {
ListCommunityRealm(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListRealmResponse, error)
ListAvailableRealm(ctx context.Context, in *RealmLookupWithUserRequest, opts ...grpc.CallOption) (*ListRealmResponse, error)
ListOwnedRealm(ctx context.Context, in *RealmLookupWithUserRequest, opts ...grpc.CallOption) (*ListRealmResponse, error)
GetRealm(ctx context.Context, in *RealmLookupRequest, opts ...grpc.CallOption) (*RealmResponse, error)
ListRealmMember(ctx context.Context, in *RealmMemberLookupRequest, opts ...grpc.CallOption) (*ListRealmMemberResponse, error)
GetRealmMember(ctx context.Context, in *RealmMemberLookupRequest, opts ...grpc.CallOption) (*RealmMemberResponse, error)
}
type realmsClient struct {
cc grpc.ClientConnInterface
}
func NewRealmsClient(cc grpc.ClientConnInterface) RealmsClient {
return &realmsClient{cc}
}
func (c *realmsClient) ListCommunityRealm(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListRealmResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListRealmResponse)
err := c.cc.Invoke(ctx, Realms_ListCommunityRealm_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *realmsClient) ListAvailableRealm(ctx context.Context, in *RealmLookupWithUserRequest, opts ...grpc.CallOption) (*ListRealmResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListRealmResponse)
err := c.cc.Invoke(ctx, Realms_ListAvailableRealm_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *realmsClient) ListOwnedRealm(ctx context.Context, in *RealmLookupWithUserRequest, opts ...grpc.CallOption) (*ListRealmResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListRealmResponse)
err := c.cc.Invoke(ctx, Realms_ListOwnedRealm_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *realmsClient) GetRealm(ctx context.Context, in *RealmLookupRequest, opts ...grpc.CallOption) (*RealmResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RealmResponse)
err := c.cc.Invoke(ctx, Realms_GetRealm_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *realmsClient) ListRealmMember(ctx context.Context, in *RealmMemberLookupRequest, opts ...grpc.CallOption) (*ListRealmMemberResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListRealmMemberResponse)
err := c.cc.Invoke(ctx, Realms_ListRealmMember_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *realmsClient) GetRealmMember(ctx context.Context, in *RealmMemberLookupRequest, opts ...grpc.CallOption) (*RealmMemberResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RealmMemberResponse)
err := c.cc.Invoke(ctx, Realms_GetRealmMember_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// RealmsServer is the server API for Realms service.
// All implementations must embed UnimplementedRealmsServer
// for forward compatibility
type RealmsServer interface {
ListCommunityRealm(context.Context, *emptypb.Empty) (*ListRealmResponse, error)
ListAvailableRealm(context.Context, *RealmLookupWithUserRequest) (*ListRealmResponse, error)
ListOwnedRealm(context.Context, *RealmLookupWithUserRequest) (*ListRealmResponse, error)
GetRealm(context.Context, *RealmLookupRequest) (*RealmResponse, error)
ListRealmMember(context.Context, *RealmMemberLookupRequest) (*ListRealmMemberResponse, error)
GetRealmMember(context.Context, *RealmMemberLookupRequest) (*RealmMemberResponse, error)
mustEmbedUnimplementedRealmsServer()
}
// UnimplementedRealmsServer must be embedded to have forward compatible implementations.
type UnimplementedRealmsServer struct {
}
func (UnimplementedRealmsServer) ListCommunityRealm(context.Context, *emptypb.Empty) (*ListRealmResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListCommunityRealm not implemented")
}
func (UnimplementedRealmsServer) ListAvailableRealm(context.Context, *RealmLookupWithUserRequest) (*ListRealmResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListAvailableRealm not implemented")
}
func (UnimplementedRealmsServer) ListOwnedRealm(context.Context, *RealmLookupWithUserRequest) (*ListRealmResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListOwnedRealm not implemented")
}
func (UnimplementedRealmsServer) GetRealm(context.Context, *RealmLookupRequest) (*RealmResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetRealm not implemented")
}
func (UnimplementedRealmsServer) ListRealmMember(context.Context, *RealmMemberLookupRequest) (*ListRealmMemberResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListRealmMember not implemented")
}
func (UnimplementedRealmsServer) GetRealmMember(context.Context, *RealmMemberLookupRequest) (*RealmMemberResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetRealmMember not implemented")
}
func (UnimplementedRealmsServer) mustEmbedUnimplementedRealmsServer() {}
// UnsafeRealmsServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to RealmsServer will
// result in compilation errors.
type UnsafeRealmsServer interface {
mustEmbedUnimplementedRealmsServer()
}
func RegisterRealmsServer(s grpc.ServiceRegistrar, srv RealmsServer) {
s.RegisterService(&Realms_ServiceDesc, srv)
}
func _Realms_ListCommunityRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RealmsServer).ListCommunityRealm(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Realms_ListCommunityRealm_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RealmsServer).ListCommunityRealm(ctx, req.(*emptypb.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _Realms_ListAvailableRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RealmLookupWithUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RealmsServer).ListAvailableRealm(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Realms_ListAvailableRealm_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RealmsServer).ListAvailableRealm(ctx, req.(*RealmLookupWithUserRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Realms_ListOwnedRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RealmLookupWithUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RealmsServer).ListOwnedRealm(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Realms_ListOwnedRealm_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RealmsServer).ListOwnedRealm(ctx, req.(*RealmLookupWithUserRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Realms_GetRealm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RealmLookupRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RealmsServer).GetRealm(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Realms_GetRealm_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RealmsServer).GetRealm(ctx, req.(*RealmLookupRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Realms_ListRealmMember_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RealmMemberLookupRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RealmsServer).ListRealmMember(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Realms_ListRealmMember_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RealmsServer).ListRealmMember(ctx, req.(*RealmMemberLookupRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Realms_GetRealmMember_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RealmMemberLookupRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RealmsServer).GetRealmMember(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Realms_GetRealmMember_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RealmsServer).GetRealmMember(ctx, req.(*RealmMemberLookupRequest))
}
return interceptor(ctx, in, info, handler)
}
// Realms_ServiceDesc is the grpc.ServiceDesc for Realms service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Realms_ServiceDesc = grpc.ServiceDesc{
ServiceName: "proto.Realms",
HandlerType: (*RealmsServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ListCommunityRealm",
Handler: _Realms_ListCommunityRealm_Handler,
},
{
MethodName: "ListAvailableRealm",
Handler: _Realms_ListAvailableRealm_Handler,
},
{
MethodName: "ListOwnedRealm",
Handler: _Realms_ListOwnedRealm_Handler,
},
{
MethodName: "GetRealm",
Handler: _Realms_GetRealm_Handler,
},
{
MethodName: "ListRealmMember",
Handler: _Realms_ListRealmMember_Handler,
},
{
MethodName: "GetRealmMember",
Handler: _Realms_GetRealmMember_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "realms.proto",
}