♻️ Move dealer to nexus

This commit is contained in:
LittleSheep 2024-11-02 13:23:27 +08:00
parent fce8669059
commit cef4764d8c
38 changed files with 454 additions and 550 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/uploads
/dist
/keys
.DS_Store

View File

@ -1,3 +1,3 @@
# Hydrogen.Messaging
# Hypernet.Messaging
The instant message service in Hydrogen universe.
The instant message service in Hypernet universe.

82
go.mod
View File

@ -1,33 +1,36 @@
module git.solsynth.dev/hydrogen/messaging
go 1.22
toolchain go1.22.1
go 1.23.2
require (
git.solsynth.dev/hydrogen/dealer v0.0.0-20240919131945-00c52eba6827
git.solsynth.dev/hypernet/nexus v0.0.0-20241031133156-6bb8eab3fcd8
git.solsynth.dev/hypernet/passport v0.0.0-20241102044832-40a040352174
git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e
github.com/dgraph-io/ristretto v0.1.1
github.com/eko/gocache/lib/v4 v4.1.6
github.com/eko/gocache/store/ristretto/v4 v4.2.2
github.com/go-playground/validator/v10 v10.17.0
github.com/gofiber/fiber/v2 v2.52.4
github.com/fatih/color v1.17.0
github.com/go-playground/validator/v10 v10.22.1
github.com/gofiber/fiber/v2 v2.52.5
github.com/google/uuid v1.6.0
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
github.com/json-iterator/go v1.1.12
github.com/livekit/protocol v1.14.0
github.com/livekit/server-sdk-go v1.1.8
github.com/robfig/cron/v3 v3.0.1
github.com/rs/zerolog v1.31.0
github.com/samber/lo v1.39.0
github.com/spf13/viper v1.18.2
google.golang.org/grpc v1.65.0
gorm.io/datatypes v1.2.0
gorm.io/driver/postgres v1.5.4
gorm.io/gorm v1.25.6
github.com/rs/zerolog v1.33.0
github.com/samber/lo v1.47.0
github.com/spf13/viper v1.19.0
google.golang.org/grpc v1.67.1
gorm.io/datatypes v1.2.4
gorm.io/driver/postgres v1.5.9
gorm.io/gorm v1.25.12
)
require (
github.com/andybalholm/brotli v1.1.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
@ -38,10 +41,9 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/eapache/channels v1.1.0 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/frostbyte73/core v0.0.10 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gammazero/deque v0.2.1 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-logr/logr v1.4.2 // indirect
@ -49,11 +51,13 @@ require (
github.com/go-playground/form v3.1.4+incompatible // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/glog v1.2.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/consul/api v1.29.1 // indirect
github.com/hashicorp/consul/api v1.30.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
@ -64,16 +68,16 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
github.com/jackc/pgx/v5 v5.5.1 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/jxskiss/base62 v1.1.0 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lithammer/shortuuid/v4 v4.0.0 // indirect
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 // indirect
github.com/livekit/mediatransportutil v0.0.0-20231213075826-cccbf2b93d3f // indirect
@ -82,17 +86,17 @@ require (
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // 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.16 // indirect
github.com/mbobakov/grpc-consul-resolver v1.5.3 // indirect
github.com/mitchellh/go-homedir v1.1.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/reflect2 v1.0.2 // indirect
github.com/nats-io/nats.go v1.31.0 // indirect
github.com/nats-io/nkeys v0.4.6 // indirect
github.com/nats-io/nats.go v1.37.0 // indirect
github.com/nats-io/nkeys v0.4.7 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
github.com/pion/datachannel v1.5.5 // indirect
github.com/pion/dtls/v2 v2.2.9 // indirect
github.com/pion/ice/v2 v2.3.13 // indirect
@ -118,19 +122,19 @@ require (
github.com/puzpuzpuz/xsync/v3 v3.1.0 // indirect
github.com/redis/go-redis/v9 v9.5.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/thoas/go-funk v0.9.3 // indirect
github.com/tinylib/msgp v1.1.8 // indirect
github.com/tinylib/msgp v1.2.2 // indirect
github.com/twitchtv/twirp v8.1.3+incompatible // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.52.0 // indirect
github.com/valyala/fasthttp v1.56.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
@ -139,15 +143,15 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go.uber.org/zap/exp v0.2.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/mysql v1.5.2 // indirect
gorm.io/driver/mysql v1.5.7 // indirect
)

167
go.sum
View File

@ -1,12 +1,22 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240919131945-00c52eba6827 h1:1ACMPm2ArRpVNYrND/y/R6oPiuMfKe49fP+lG3mcNug=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240919131945-00c52eba6827/go.mod h1:Q51JPkKnV0UoOT/IRmdBh5CyfSlp7s8BRGzgooYHqkI=
git.solsynth.dev/hypernet/nexus v0.0.0-20241031133156-6bb8eab3fcd8 h1:fo9WuAXcmxdGfYXZKTiAbqGLHAkeL7vf0zpwbjoUNc0=
git.solsynth.dev/hypernet/nexus v0.0.0-20241031133156-6bb8eab3fcd8/go.mod h1:fXQsHXGio+7/0U95IitKF07wS4yTdCMp5ms8wpFBwVI=
git.solsynth.dev/hypernet/passport v0.0.0-20241031144010-d1f1183beb36 h1:rzDuXRTCbWJOgfT7bG0cWFcYqbWKnI1aEfiovpXfsdM=
git.solsynth.dev/hypernet/passport v0.0.0-20241031144010-d1f1183beb36/go.mod h1:EjUDX5HdTo3J1GfAN5mfDf0JxRspzASj8uysa4V/ow0=
git.solsynth.dev/hypernet/passport v0.0.0-20241102044832-40a040352174 h1:XplLpEeQOFlZR2/A4YIeh0B/g9//pXg/TXtWrvHDops=
git.solsynth.dev/hypernet/passport v0.0.0-20241102044832-40a040352174/go.mod h1:EjUDX5HdTo3J1GfAN5mfDf0JxRspzASj8uysa4V/ow0=
git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e h1:DtHhMjgxS/spUt/KEdbRFtaVnepI6Vx8pbHdJaNH1hs=
git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e/go.mod h1:XHTqFU/vBe4JiuAjl87GUcL8+w/IizSNoqH6n3WkQFc=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA=
@ -66,8 +76,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0=
github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU=
github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k=
@ -89,17 +99,21 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.17.0 h1:SmVVlfAOtlZncTxRuinDPomC2DkXJ4E5T9gDA0AIH74=
github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA=
github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
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.5 h1:tWoP1MJQjGEe4GB5TUGOi7P2E0ZMMRx5ZTG4rT+yGMo=
github.com/gofiber/fiber/v2 v2.52.5/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
@ -137,10 +151,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/hashicorp/consul/api v1.29.1 h1:UEwOjYJrd3lG1x5w7HxDRMGiAUPrb3f103EoeKuuEcc=
github.com/hashicorp/consul/api v1.29.1/go.mod h1:lumfRkY/coLuqMICkI7Fh3ylMG31mQSRZyef2c5YvJI=
github.com/hashicorp/consul/proto-public v0.6.1 h1:+uzH3olCrksXYWAYHKqK782CtK9scfqH+Unlw3UHhCg=
github.com/hashicorp/consul/proto-public v0.6.1/go.mod h1:cXXbOg74KBNGajC+o8RlA502Esf0R9prcoJgiOX/2Tg=
github.com/hashicorp/consul/api v1.30.0 h1:ArHVMMILb1nQv8vZSGIwwQd2gtc+oSQZ6CalyiyH2XQ=
github.com/hashicorp/consul/api v1.30.0/go.mod h1:B2uGchvaXVW2JhFoS8nqTxMD5PBykr4ebY4JWHTTeLM=
github.com/hashicorp/consul/sdk v0.16.1 h1:V8TxTnImoPD5cj0U9Spl0TUxcytjcbbJeADFF07KdHg=
github.com/hashicorp/consul/sdk v0.16.1/go.mod h1:fSXvwxB2hmh1FMZCNl6PwX0Q/1wdWtHJcZ7Ea5tns0s=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@ -188,12 +200,12 @@ github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfE
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA=
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.5.1 h1:5I9etrGkLrN+2XPCsi6XLlV5DITbSL/xBZdmAxFcXPI=
github.com/jackc/pgx/v5 v5.5.1/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
@ -209,8 +221,8 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/jxskiss/base62 v1.1.0 h1:A5zbF8v8WXx2xixnAKD2w+abC+sIzYJX+nxmhA6HWFw=
github.com/jxskiss/base62 v1.1.0/go.mod h1:HhWAlUXvxKThfOlZbcuFzsqwtF5TcqS9ru3y5GfjWAc=
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
@ -222,8 +234,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/lithammer/shortuuid/v4 v4.0.0 h1:QRbbVkfgNippHOS8PXDkti4NaWeyYfcBTHtw7k08o4c=
github.com/lithammer/shortuuid/v4 v4.0.0/go.mod h1:Zs8puNcrvf2rV9rTH51ZLLcj7ZXqQI3lv67aw4KiB1Y=
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkDaKb5iXdynYrzB84ErPPO4LbRASk58=
@ -256,8 +268,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@ -282,10 +294,10 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nats-io/nats.go v1.31.0 h1:/WFBHEc/dOKBF6qf1TZhrdEfTmOZ5JzdJ+Y3m6Y/p7E=
github.com/nats-io/nats.go v1.31.0/go.mod h1:di3Bm5MLsoB4Bx61CBTsxuarI36WbhAwOm8QrW39+i8=
github.com/nats-io/nkeys v0.4.6 h1:IzVe95ru2CT6ta874rt9saQRkWfe2nFj1NtvYSLqMzY=
github.com/nats-io/nkeys v0.4.6/go.mod h1:4DxZNzenSVd1cYQoAa8948QY3QDjrHfcfVADymtkpts=
github.com/nats-io/nats.go v1.37.0 h1:07rauXbVnnJvv1gfIyghFEo6lUcYRY0WXc3x7x0vUxE=
github.com/nats-io/nats.go v1.37.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI=
github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
@ -300,10 +312,10 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw=
github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c h1:dAMKvw0MlJT1GshSTtih8C2gDs04w8dReiOGXrGLNoY=
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/pion/datachannel v1.5.5 h1:10ef4kwdjije+M9d7Xm9im2Y3O6A6ccQb0zcqZcJew8=
github.com/pion/datachannel v1.5.5/go.mod h1:iMz+lECmfdCMqFRhXhcA/219B0SQlbpoR2V118yimL0=
github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s=
@ -388,15 +400,15 @@ github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzG
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk=
github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
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/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
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=
@ -406,12 +418,12 @@ github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9yS
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
@ -428,7 +440,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
@ -437,21 +448,23 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw=
github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0=
github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw=
github.com/tinylib/msgp v1.2.2 h1:iHiBE1tJQwFI740SPEPkGE8cfhNfrqOYRlH450BnC/4=
github.com/tinylib/msgp v1.2.2/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/twitchtv/twirp v8.1.3+incompatible h1:+F4TdErPgSUbMZMwp13Q/KgDVuI7HJXP61mNV3/7iuU=
github.com/twitchtv/twirp v8.1.3+incompatible/go.mod h1:RRJoFSAmTEh2weEqWtpPE3vFK5YBhA6bqp2l1kfCC5A=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.52.0 h1:wqBQpxH71XW0e2g+Og4dzQM8pk34aFYlA1Ga8db7gU0=
github.com/valyala/fasthttp v1.52.0/go.mod h1:hf5C4QnVMkNXMspnsUlfM3WitlgYflyhHYoKol/szxQ=
github.com/valyala/fasthttp v1.56.0 h1:bEZdJev/6LCBlpdORfrLu/WOZXXxvrUQSiyniuaoW8U=
github.com/valyala/fasthttp v1.56.0/go.mod h1:sReBt3XZVnudxuLOx4J/fMrJVorWRiWY2koQKgABiVI=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
@ -480,14 +493,13 @@ golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIi
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -503,15 +515,14 @@ golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -559,7 +570,6 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@ -570,12 +580,11 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
@ -589,30 +598,28 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d h1:JU0iKnSg02Gmb5ZdV8nYsKEKsP6o/FGVWTrw4i1DA9A=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@ -621,8 +628,8 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@ -643,16 +650,16 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/datatypes v1.2.0 h1:5YT+eokWdIxhJgWHdrb2zYUimyk0+TaFth+7a0ybzco=
gorm.io/datatypes v1.2.0/go.mod h1:o1dh0ZvjIjhH/bngTpypG6lVRJ5chTBxE09FH/71k04=
gorm.io/driver/mysql v1.5.2 h1:QC2HRskSE75wBuOxe0+iCkyJZ+RqpudsQtqkp+IMuXs=
gorm.io/driver/mysql v1.5.2/go.mod h1:pQLhh1Ut/WUAySdTHwBpBv6+JKcj+ua4ZFx1QQTBzb8=
gorm.io/driver/postgres v1.5.4 h1:Iyrp9Meh3GmbSuyIAGyjkN+n9K+GHX9b9MqsTL4EJCo=
gorm.io/driver/postgres v1.5.4/go.mod h1:Bgo89+h0CRcdA33Y6frlaHHVuTdOf87pmyzwW9C/BH0=
gorm.io/datatypes v1.2.4 h1:uZmGAcK/QZ0uyfCuVg0VQY1ZmV9h1fuG0tMwKByO1z4=
gorm.io/datatypes v1.2.4/go.mod h1:f4BsLcFAX67szSv8svwLRjklArSHAvHLeE3pXAS5DZI=
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
gorm.io/driver/postgres v1.5.9 h1:DkegyItji119OlcaLjqN11kHoUgZ/j13E0jkJZgD6A8=
gorm.io/driver/postgres v1.5.9/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=
gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU=
gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI=
gorm.io/driver/sqlserver v1.4.1 h1:t4r4r6Jam5E6ejqP7N82qAJIJAht27EGT41HyPfXRw0=
gorm.io/driver/sqlserver v1.4.1/go.mod h1:DJ4P+MeZbc5rvY58PnmN1Lnyvb5gw5NPzGshHDnJLig=
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.6 h1:V92+vVda1wEISSOMtodHVRcUIOPYa2tgQtyF+DfFx+A=
gorm.io/gorm v1.25.6/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=

View File

@ -6,7 +6,6 @@ import (
)
var AutoMaintainRange = []any{
&models.Account{},
&models.Realm{},
&models.Channel{},
&models.ChannelMember{},

View File

@ -1,28 +1,31 @@
package database
import (
"fmt"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hypernet/nexus/pkg/nex/cruda"
"github.com/rs/zerolog/log"
"github.com/samber/lo"
"github.com/spf13/viper"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"gorm.io/gorm/schema"
)
var C *gorm.DB
func NewSource() error {
var err error
func NewGorm() error {
dsn, err := cruda.NewCrudaConn(gap.Nx).AllocDatabase("messaging")
if err != nil {
return fmt.Errorf("failed to alloc database from nexus: %v", err)
}
dialector := postgres.Open(viper.GetString("database.dsn"))
C, err = gorm.Open(dialector, &gorm.Config{NamingStrategy: schema.NamingStrategy{
TablePrefix: viper.GetString("database.prefix"),
}, Logger: logger.New(&log.Logger, logger.Config{
C, err = gorm.Open(postgres.Open(dsn), &gorm.Config{Logger: logger.New(&log.Logger, logger.Config{
Colorful: true,
IgnoreRecordNotFoundError: true,
LogLevel: lo.Ternary(viper.GetBool("debug.database"), logger.Info, logger.Silent),
})})
return err
}

View File

@ -1,15 +0,0 @@
package gap
import "net"
func GetOutboundIP() (net.IP, error) {
conn, err := net.Dial("udp", "1.1.1.1:80")
if err != nil {
return nil, err
} else {
defer conn.Close()
}
localAddr := conn.LocalAddr().(*net.UDPAddr)
return localAddr.IP, nil
}

View File

@ -2,42 +2,51 @@ package gap
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"git.solsynth.dev/hypernet/pusher/pkg/pushkit/pushcon"
"github.com/samber/lo"
"strings"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
)
var H *hyper.HyperConn
var Nx *nex.Conn
var Px *pushcon.Conn
func RegisterService() error {
func InitializeToNexus() error {
grpcBind := strings.SplitN(viper.GetString("grpc_bind"), ":", 2)
httpBind := strings.SplitN(viper.GetString("bind"), ":", 2)
outboundIp, _ := GetOutboundIP()
outboundIp, _ := nex.GetOutboundIP()
grpcOutbound := fmt.Sprintf("%s:%s", outboundIp, grpcBind[1])
httpOutbound := fmt.Sprintf("%s:%s", outboundIp, httpBind[1])
var err error
H, err = hyper.NewHyperConn(viper.GetString("dealer.addr"), &proto.ServiceInfo{
Nx, err = nex.NewNexusConn(viper.GetString("nexus_addr"), &proto.ServiceInfo{
Id: viper.GetString("id"),
Type: hyper.ServiceTypeMessagingProvider,
Type: "im",
Label: "Messaging",
GrpcAddr: grpcOutbound,
HttpAddr: &httpOutbound,
HttpAddr: lo.ToPtr("http://" + httpOutbound + "/api"),
})
if err == nil {
go func() {
err := H.KeepRegisterService()
err := Nx.RunRegistering()
if err != nil {
log.Error().Err(err).Msg("An error occurred while registering service...")
}
}()
}
Px, err = pushcon.NewConn(Nx)
if err != nil {
return fmt.Errorf("error during initialize pushcon: %v", err)
}
return err
}

View File

@ -3,7 +3,7 @@ package grpc
import (
"net"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"github.com/spf13/viper"
"google.golang.org/grpc"
health "google.golang.org/grpc/health/grpc_health_v1"
@ -11,27 +11,31 @@ import (
)
type Server struct {
proto.UnimplementedStreamControllerServer
proto.UnimplementedServiceDirectoryServer
proto.UnimplementedStreamServiceServer
proto.UnimplementedDirectoryServiceServer
srv *grpc.Server
}
var S *grpc.Server
func NewGrpc() *Server {
server := &Server{
srv: grpc.NewServer(),
}
func NewGRPC() {
S = grpc.NewServer()
health.RegisterHealthServer(server.srv, server)
proto.RegisterStreamServiceServer(server.srv, server)
proto.RegisterDirectoryServiceServer(server.srv, server)
health.RegisterHealthServer(S, &Server{})
proto.RegisterStreamControllerServer(S, &Server{})
proto.RegisterServiceDirectoryServer(S, &Server{})
reflection.Register(server.srv)
reflection.Register(S)
return server
}
func ListenGRPC() error {
func (v *Server) Listen() error {
listener, err := net.Listen("tcp", viper.GetString("grpc_bind"))
if err != nil {
return err
}
return S.Serve(listener)
return v.srv.Serve(listener)
}

View File

@ -2,28 +2,41 @@ package grpc
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"strconv"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
)
func (v *Server) BroadcastDeletion(ctx context.Context, request *proto.DeletionRequest) (*proto.DeletionResponse, error) {
switch request.GetResourceType() {
func (v *Server) BroadcastEvent(ctx context.Context, in *proto.EventInfo) (*proto.EventResponse, error) {
switch in.GetEvent() {
case "deletion":
data := nex.DecodeMap(in.GetData())
resType, ok := data["type"].(string)
if !ok {
break
}
switch resType {
case "account":
numericId, err := strconv.Atoi(request.GetResourceId())
id, ok := data["id"].(string)
if !ok {
break
}
numericId, err := strconv.Atoi(id)
if err != nil {
break
}
tx := database.C.Begin()
for _, model := range database.AutoMaintainRange {
switch model.(type) {
default:
database.C.Delete(model, "account_id = ?", numericId)
tx.Delete(model, "account_id = ?", numericId)
}
}
database.C.Delete(&models.Account{}, "id = ?", numericId)
tx.Commit()
}
}
return &proto.DeletionResponse{}, nil
return &proto.EventResponse{}, nil
}

View File

@ -3,43 +3,48 @@ package grpc
import (
"context"
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/http/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
jsoniter "github.com/json-iterator/go"
)
func (v *Server) EmitStreamEvent(_ context.Context, in *proto.StreamEventRequest) (*proto.StreamEventResponse, error) {
sc := proto.NewStreamControllerClient(gap.H.GetDealerGrpcConn())
func (v *Server) PushStream(_ context.Context, request *proto.PushStreamRequest) (*proto.PushStreamResponse, error) {
sc := proto.NewStreamServiceClient(gap.Nx.GetNexusGrpcConn())
switch in.GetEvent() {
var in nex.WebSocketPackage
if err := jsoniter.Unmarshal(request.GetBody(), &in); err != nil {
return nil, err
}
switch in.Action {
case "status.typing":
var data struct {
ChannelID uint `json:"channel_id" validate:"required"`
}
err := jsoniter.Unmarshal(in.GetPayload(), &data)
err := jsoniter.Unmarshal(in.RawPayload(), &data)
if err == nil {
err = exts.ValidateStruct(data)
}
if err != nil {
_, _ = sc.PushStream(context.Background(), &proto.PushStreamRequest{
ClientId: &in.ClientId,
Body: hyper.NetworkPackage{
ClientId: request.ClientId,
Body: nex.WebSocketPackage{
Action: "error",
Message: fmt.Sprintf("unable parse payload: %v", err),
}.Marshal(),
})
}
err = services.SetTypingStatus(data.ChannelID, uint(in.GetUserId()))
err = services.SetTypingStatus(data.ChannelID, uint(request.GetUserId()))
if err != nil {
_, _ = sc.PushStream(context.Background(), &proto.PushStreamRequest{
ClientId: &in.ClientId,
Body: hyper.NetworkPackage{
ClientId: request.ClientId,
Body: nex.WebSocketPackage{
Action: "error",
Message: fmt.Sprintf("unable boardcast status: %v", err),
}.Marshal(),
@ -47,5 +52,5 @@ func (v *Server) EmitStreamEvent(_ context.Context, in *proto.StreamEventRequest
}
}
return &proto.StreamEventResponse{}, nil
return &proto.PushStreamResponse{}, nil
}

View File

@ -1,12 +1,13 @@
package api
import (
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"sync"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/http/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/services"
"github.com/gofiber/fiber/v2"
"github.com/google/uuid"
@ -55,10 +56,10 @@ func getOngoingCall(c *fiber.Ctx) error {
}
func startCall(c *fiber.Ctx) error {
if err := gap.H.EnsureGrantedPerm(c, "CreateCalls", true); err != nil {
if err := sec.EnsureGrantedPerm(c, "CreateCalls", true); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var channel models.Channel
@ -105,10 +106,10 @@ func startCall(c *fiber.Ctx) error {
}
func endCall(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var channel models.Channel
@ -151,10 +152,10 @@ func endCall(c *fiber.Ctx) error {
}
func kickParticipantInCall(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var data struct {
@ -193,10 +194,10 @@ func kickParticipantInCall(c *fiber.Ctx) error {
}
func exchangeCallToken(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var channel models.Channel

View File

@ -2,10 +2,11 @@ package api
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/http/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
@ -36,10 +37,10 @@ func listChannelMembers(c *fiber.Ctx) error {
func getMyChannelMembership(c *fiber.Ctx) error {
alias := c.Params("channel")
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
var err error
var channel models.Channel
@ -60,10 +61,10 @@ func getMyChannelMembership(c *fiber.Ctx) error {
}
func addChannelMember(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var data struct {
@ -89,7 +90,7 @@ func addChannelMember(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusForbidden, "you must be a moderator of a channel to add member into it")
}
var account models.Account
var account authm.Account
if err := database.C.Where(&hyper.BaseUser{
Name: data.Target,
}).First(&account).Error; err != nil {
@ -104,10 +105,10 @@ func addChannelMember(c *fiber.Ctx) error {
}
func removeChannelMember(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var data struct {
@ -134,7 +135,7 @@ func removeChannelMember(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusForbidden, "you must be a moderator of a channel to remove member into it")
}
var account models.Account
var account authm.Account
if err := database.C.Where(&hyper.BaseUser{
Name: data.Target,
}).First(&account).Error; err != nil {
@ -149,10 +150,10 @@ func removeChannelMember(c *fiber.Ctx) error {
}
func editMyChannelMembership(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var data struct {
@ -183,11 +184,12 @@ func editMyChannelMembership(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusNotFound, err.Error())
}
membership.Name = user.Name
membership.Notify = data.NotifyLevel
if len(data.Nick) > 0 {
membership.Nick = &data.Nick
membership.Nick = data.Nick
} else {
membership.Nick = nil
membership.Nick = user.Nick
}
if membership, err := services.EditChannelMember(membership); err != nil {
@ -198,10 +200,10 @@ func editMyChannelMembership(c *fiber.Ctx) error {
}
func joinChannel(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var channel models.Channel
@ -231,10 +233,10 @@ func joinChannel(c *fiber.Ctx) error {
}
func leaveChannel(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var channel models.Channel

View File

@ -2,10 +2,11 @@ package api
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/http/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
@ -32,10 +33,10 @@ func getChannel(c *fiber.Ctx) error {
}
func getChannelIdentity(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var err error
@ -55,9 +56,9 @@ func getChannelIdentity(c *fiber.Ctx) error {
}
func listChannel(c *fiber.Ctx) error {
var user *models.Account
if err := gap.H.EnsureAuthenticated(c); err == nil {
user = lo.ToPtr(c.Locals("user").(models.Account))
var user *authm.Account
if err := sec.EnsureAuthenticated(c); err == nil {
user = lo.ToPtr(c.Locals("user").(authm.Account))
}
var err error
@ -75,10 +76,10 @@ func listChannel(c *fiber.Ctx) error {
}
func listOwnedChannel(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
var err error
var channels []models.Channel
@ -95,10 +96,10 @@ func listOwnedChannel(c *fiber.Ctx) error {
}
func listAvailableChannel(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
tx := database.C
isDirect := c.QueryBool("direct", false)
@ -123,10 +124,10 @@ func listAvailableChannel(c *fiber.Ctx) error {
}
func createChannel(c *fiber.Ctx) error {
if err := gap.H.EnsureGrantedPerm(c, "CreateChannels", true); err != nil {
if err := sec.EnsureGrantedPerm(c, "CreateChannels", true); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
var data struct {
Alias string `json:"alias" validate:"required,lowercase,min=4,max=32"`
@ -179,10 +180,10 @@ func createChannel(c *fiber.Ctx) error {
}
func editChannel(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
id, _ := c.ParamsInt("channelId", 0)
var data struct {
@ -233,10 +234,10 @@ func editChannel(c *fiber.Ctx) error {
}
func deleteChannel(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
id, _ := c.ParamsInt("channelId", 0)
tx := database.C.Where(&models.Channel{BaseModel: hyper.BaseModel{ID: uint(id)}})

View File

@ -2,9 +2,10 @@ package api
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/http/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
@ -13,10 +14,10 @@ import (
)
func createDirectChannel(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
var data struct {
Alias string `json:"alias" validate:"required,lowercase,min=4,max=32"`
@ -43,7 +44,7 @@ func createDirectChannel(c *fiber.Ctx) error {
}
}
var relatedUser models.Account
var relatedUser authm.Account
if err := database.C.
Where("external_id = ?", data.RelatedUser).
First(&relatedUser).Error; err != nil {

View File

@ -2,19 +2,20 @@ package api
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/http/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/services"
"github.com/gofiber/fiber/v2"
)
func getEvent(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
id, _ := c.ParamsInt("eventId")
@ -40,10 +41,10 @@ func getEvent(c *fiber.Ctx) error {
}
func listEvent(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
take := c.QueryInt("take", 0)
offset := c.QueryInt("offset", 0)
alias := c.Params("channel")
@ -74,10 +75,10 @@ func listEvent(c *fiber.Ctx) error {
}
func newRawEvent(c *fiber.Ctx) error {
if err := gap.H.EnsureGrantedPerm(c, "CreateMessagingRawEvent", true); err != nil {
if err := sec.EnsureGrantedPerm(c, "CreateMessagingRawEvent", true); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var data struct {

View File

@ -1,21 +1,22 @@
package api
import (
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"strings"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/http/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/services"
"github.com/gofiber/fiber/v2"
jsoniter "github.com/json-iterator/go"
)
func newMessageEvent(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
var data struct {
@ -73,10 +74,10 @@ func newMessageEvent(c *fiber.Ctx) error {
}
func editMessageEvent(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
messageId, _ := c.ParamsInt("messageId", 0)
@ -122,10 +123,10 @@ func editMessageEvent(c *fiber.Ctx) error {
}
func deleteMessageEvent(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
alias := c.Params("channel")
messageId, _ := c.ParamsInt("messageId", 0)

View File

@ -7,9 +7,6 @@ import (
func MapAPIs(app *fiber.App, baseURL string) {
api := app.Group(baseURL).Name("API")
{
api.Get("/users/me", getUserinfo)
api.Get("/users/:accountId", getOthersInfo)
channels := api.Group("/channels/:realm").Use(realmMiddleware).Name("Channels API")
{
channels.Get("/", listChannel)

View File

@ -2,18 +2,19 @@ package api
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
"github.com/gofiber/fiber/v2"
)
func getWhatsNew(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
user := c.Locals("user").(authm.Account)
pivot := c.QueryInt("pivot", 0)
if pivot < 0 {

View File

@ -1,14 +1,11 @@
package server
package http
import (
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"git.solsynth.dev/hypernet/passport/pkg/authkit"
"strings"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/api"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/http/api"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/idempotency"
@ -18,14 +15,18 @@ import (
"github.com/spf13/viper"
)
var app *fiber.App
var IReader *sec.InternalTokenReader
func NewServer() {
app = fiber.New(fiber.Config{
type App struct {
app *fiber.App
}
func NewServer() *App {
app := fiber.New(fiber.Config{
DisableStartupMessage: true,
EnableIPValidation: true,
ServerHeader: "Hydrogen.Messaging",
AppName: "Hydrogen.Messaging",
ServerHeader: "Hypernet.Messaging",
AppName: "Hypernet.Messaging",
ProxyHeader: fiber.HeaderXForwardedFor,
JSONEncoder: jsoniter.ConfigCompatibleWithStandardLibrary.Marshal,
JSONDecoder: jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal,
@ -55,23 +56,18 @@ func NewServer() {
Output: log.Logger,
}))
tablePrefix := viper.GetString("database.prefix")
app.Use(gap.H.AuthMiddleware)
app.Use(hyper.LinkAccountMiddleware(
database.C,
tablePrefix+"accounts",
func(u hyper.BaseUser) models.Account {
return models.Account{
BaseUser: u,
}
},
))
app.Use(sec.ContextMiddleware(IReader))
app.Use(authkit.ParseAccountMiddleware)
api.MapAPIs(app, "/api")
}
func Listen() {
if err := app.Listen(viper.GetString("bind")); err != nil {
log.Fatal().Err(err).Msg("An error occurred when starting server...")
return &App{
app: app,
}
}
func (v *App) Listen() {
if err := v.app.Listen(viper.GetString("bind")); err != nil {
log.Fatal().Err(err).Msg("An error occurred when starting http...")
}
}

View File

@ -1,9 +0,0 @@
package models
import "git.solsynth.dev/hydrogen/dealer/pkg/hyper"
type Account struct {
hyper.BaseUser
Channels []Channel `json:"channels"`
}

View File

@ -23,7 +23,6 @@ type Channel struct {
Messages []Event `json:"messages"`
Calls []Call `json:"calls"`
Type ChannelType `json:"type"`
Account Account `json:"account"`
AccountID uint `json:"account_id"`
IsPublic bool `json:"is_public"`
IsCommunity bool `json:"is_community"`
@ -53,11 +52,13 @@ const (
type ChannelMember struct {
hyper.BaseModel
Name string `json:"name"`
Nick string `json:"nick"`
Avatar *string `json:"avatar"`
ChannelID uint `json:"channel_id"`
AccountID uint `json:"account_id"`
Nick *string `json:"nick"`
Channel Channel `json:"channel"`
Account Account `json:"account"`
Notify NotifyLevel `json:"notify"`
PowerLevel int `json:"power_level"`

View File

@ -2,7 +2,7 @@ package models
import "git.solsynth.dev/hydrogen/dealer/pkg/hyper"
// Realm profiles basically fetched from Hydrogen.Passport
// Realm profiles basically fetched from Hypernet.Passport
// But cache at here for better usage and database relations
type Realm struct {
hyper.BaseRealm

View File

@ -1,21 +0,0 @@
package models
import jsoniter "github.com/json-iterator/go"
type UnifiedCommand struct {
Action string `json:"w"`
Message string `json:"m"`
Payload any `json:"p"`
}
func UnifiedCommandFromError(err error) UnifiedCommand {
return UnifiedCommand{
Action: "error",
Message: err.Error(),
}
}
func (v UnifiedCommand) Marshal() []byte {
data, _ := jsoniter.Marshal(v)
return data
}

View File

@ -1,38 +0,0 @@
package api
import (
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
"github.com/gofiber/fiber/v2"
)
func getUserinfo(c *fiber.Ctx) error {
if err := gap.H.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(models.Account)
var data models.Account
if err := database.C.
Where(&hyper.BaseModel{ID: user.ID}).
First(&data).Error; err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
return c.JSON(data)
}
func getOthersInfo(c *fiber.Ctx) error {
accountId := c.Params("accountId")
var data models.Account
if err := database.C.
Where(&hyper.BaseUser{Name: accountId}).
First(&data).Error; err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
return c.JSON(data)
}

View File

@ -2,80 +2,26 @@ package services
import (
"context"
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"time"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
jsoniter "github.com/json-iterator/go"
"github.com/samber/lo"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
)
func CheckUserPerm(userId, otherId uint, key string, val any) error {
var user models.Account
if err := database.C.Where("id = ?", userId).First(&user).Error; err != nil {
return fmt.Errorf("account not found: %v", err)
}
var other models.Account
if err := database.C.Where("id = ?", otherId).First(&other).Error; err != nil {
return fmt.Errorf("other not found: %v", err)
}
func NotifyAccountMessagerBatch(users []authm.Account, notification *proto.NotifyRequest) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
encodedData, _ := jsoniter.Marshal(val)
pc, err := gap.H.GetServiceGrpcConn(hyper.ServiceTypeAuthProvider)
if err != nil {
return err
}
out, err := proto.NewAuthClient(pc).EnsureUserPermGranted(ctx, &proto.CheckUserPermRequest{
UserId: uint64(user.ID),
OtherId: uint64(other.ID),
Key: key,
Value: encodedData,
})
if err != nil {
return err
} else if !out.IsValid {
return fmt.Errorf("missing permission: %v", key)
}
return nil
}
func NotifyAccountMessager(user models.Account, notification *proto.NotifyRequest) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
pc, err := gap.H.GetServiceGrpcConn(hyper.ServiceTypeAuthProvider)
if err != nil {
return err
}
_, err = proto.NewNotifierClient(pc).NotifyUser(ctx, &proto.NotifyUserRequest{
UserId: uint64(user.ID),
Notify: notification,
})
return err
}
func NotifyAccountMessagerBatch(users []models.Account, notification *proto.NotifyRequest) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
pc, err := gap.H.GetServiceGrpcConn(hyper.ServiceTypeAuthProvider)
pc, err := gap.Nx.GetClientGrpcConn(nex.ServiceTypeAuth)
if err != nil {
return err
}
_, err = proto.NewNotifierClient(pc).NotifyUserBatch(ctx, &proto.NotifyUserBatchRequest{
UserId: lo.Map(users, func(item models.Account, idx int) uint64 {
UserId: lo.Map(users, func(item authm.Account, idx int) uint64 {
return uint64(item.ID)
}),
Notify: notification,

View File

@ -4,10 +4,14 @@ import (
"context"
"errors"
"fmt"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/passport/pkg/authkit"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
"time"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
jsoniter "github.com/json-iterator/go"
@ -109,12 +113,12 @@ func NewCall(channel models.Channel, founder models.ChannelMember) (models.Call,
ChannelID: call.ChannelID,
}).Preload("Account").Find(&members).Error; err == nil {
call, _ = GetCall(call.Channel, call.ID)
var pendingUsers []models.Account
var pendingUsers []uint64
for _, member := range members {
if member.ID != call.Founder.ID {
pendingUsers = append(pendingUsers, member.Account)
pendingUsers = append(pendingUsers, uint64(member.AccountID))
}
PushCommand(member.Account.ID, models.UnifiedCommand{
PushCommand(member.AccountID, nex.WebSocketPackage{
Action: "calls.new",
Payload: call,
})
@ -122,21 +126,21 @@ func NewCall(channel models.Channel, founder models.ChannelMember) (models.Call,
channel, _ = GetChannel(channel.ID)
err = NotifyAccountMessagerBatch(
err = authkit.NotifyUserBatch(
gap.Nx,
pendingUsers,
&proto.NotifyRequest{
pushkit.Notification{
Topic: "messaging.callStart",
Title: fmt.Sprintf("Call in (%s)", channel.DisplayText()),
Body: fmt.Sprintf("%s is calling", call.Founder.Account.Name),
Avatar: &call.Founder.Account.Avatar,
Metadata: EncodeJSONBody(map[string]any{
"user_id": call.Founder.Account.ID,
"user_name": call.Founder.Account.Name,
"user_nick": call.Founder.Account.Nick,
Body: fmt.Sprintf("%s is calling", call.Founder.Name),
Metadata: map[string]any{
"avatar": call.Founder.Avatar,
"user_id": call.Founder.AccountID,
"user_name": call.Founder.Name,
"user_nick": call.Founder.Nick,
"channel_id": call.ChannelID,
}),
IsRealtime: false,
IsForcePush: true,
},
Priority: 5,
},
)
if err != nil {
@ -164,7 +168,7 @@ func EndCall(call models.Call) (models.Call, error) {
}).Preload("Account").Find(&members).Error; err == nil {
call, _ = GetCall(call.Channel, call.ID)
for _, member := range members {
PushCommand(member.Account.ID, models.UnifiedCommand{
PushCommand(member.AccountID, nex.WebSocketPackage{
Action: "calls.end",
Payload: call,
})
@ -182,7 +186,7 @@ func KickParticipantInCall(call models.Call, username string) error {
return err
}
func EncodeCallToken(user models.Account, call models.Call) (string, error) {
func EncodeCallToken(user authm.Account, call models.Call) (string, error) {
isAdmin := user.ID == call.FounderID || user.ID == call.Channel.AccountID
grant := &auth.VideoGrant{

View File

@ -4,6 +4,9 @@ import (
"context"
"fmt"
localCache "git.solsynth.dev/hydrogen/messaging/pkg/internal/cache"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hypernet/passport/pkg/authkit"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"github.com/eko/gocache/lib/v4/cache"
"github.com/eko/gocache/lib/v4/marshaler"
"github.com/eko/gocache/lib/v4/store"
@ -25,7 +28,7 @@ func ListChannelMember(channelId uint) ([]models.ChannelMember, error) {
return members, nil
}
func GetChannelMember(user models.Account, channelId uint) (models.ChannelMember, error) {
func GetChannelMember(user authm.Account, channelId uint) (models.ChannelMember, error) {
var member models.ChannelMember
if err := database.C.
@ -37,9 +40,9 @@ func GetChannelMember(user models.Account, channelId uint) (models.ChannelMember
return member, nil
}
func AddChannelMemberWithCheck(user models.Account, target models.Channel) error {
if err := CheckUserPerm(user.ID, target.AccountID, "ChannelAdd", true); err != nil {
return fmt.Errorf("unable to add user into your channel")
func AddChannelMemberWithCheck(user authm.Account, target models.Channel) error {
if err := authkit.EnsureUserPermGranted(gap.Nx, user.ID, target.AccountID, "ChannelAdd", true); err != nil {
return fmt.Errorf("unable to add user into your channel due to access denied: %v", err)
}
member := models.ChannelMember{
@ -51,7 +54,7 @@ func AddChannelMemberWithCheck(user models.Account, target models.Channel) error
return err
}
func AddChannelMember(user models.Account, target models.Channel) error {
func AddChannelMember(user authm.Account, target models.Channel) error {
member := models.ChannelMember{
ChannelID: target.ID,
AccountID: user.ID,
@ -96,7 +99,7 @@ func EditChannelMember(membership models.ChannelMember) (models.ChannelMember, e
return membership, nil
}
func RemoveChannelMember(user models.Account, target models.Channel) error {
func RemoveChannelMember(user authm.Account, target models.Channel) error {
var member models.ChannelMember
if err := database.C.Where(&models.ChannelMember{

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
localCache "git.solsynth.dev/hydrogen/messaging/pkg/internal/cache"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"github.com/eko/gocache/lib/v4/cache"
"github.com/eko/gocache/lib/v4/marshaler"
"github.com/eko/gocache/lib/v4/store"
@ -137,7 +138,7 @@ func GetAvailableChannelWithAlias(alias string, user uint, realmId ...uint) (mod
return channel, member, nil
}
func GetAvailableChannel(id uint, user models.Account) (models.Channel, models.ChannelMember, error) {
func GetAvailableChannel(id uint, user authm.Account) (models.Channel, models.ChannelMember, error) {
var err error
var member models.ChannelMember
var channel models.Channel
@ -167,7 +168,7 @@ func PreloadDirectChannelMembers(tx *gorm.DB) *gorm.DB {
}).Preload("Members.Account")
}
func ListChannel(user *models.Account, realmId ...uint) ([]models.Channel, error) {
func ListChannel(user *authm.Account, realmId ...uint) ([]models.Channel, error) {
var identities []models.ChannelMember
var idRange []uint
if user != nil {
@ -195,7 +196,7 @@ func ListChannel(user *models.Account, realmId ...uint) ([]models.Channel, error
return channels, nil
}
func ListChannelWithUser(user models.Account, realmId ...uint) ([]models.Channel, error) {
func ListChannelWithUser(user authm.Account, realmId ...uint) ([]models.Channel, error) {
var channels []models.Channel
tx := database.C.Where(&models.Channel{AccountID: user.ID}).Preload("Realm")
if len(realmId) > 0 {
@ -211,7 +212,7 @@ func ListChannelWithUser(user models.Account, realmId ...uint) ([]models.Channel
return channels, nil
}
func ListAvailableChannel(tx *gorm.DB, user models.Account, realmId ...uint) ([]models.Channel, error) {
func ListAvailableChannel(tx *gorm.DB, user authm.Account, realmId ...uint) ([]models.Channel, error) {
var channels []models.Channel
var members []models.ChannelMember
if err := database.C.Where(&models.ChannelMember{

View File

@ -2,15 +2,15 @@ package services
import (
"fmt"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
"github.com/spf13/viper"
)
func GetDirectChannelByUser(user models.Account, other models.Account) (models.Channel, error) {
memberTable := fmt.Sprintf("%schannel_members", viper.GetString("database.prefix"))
channelTable := fmt.Sprintf("%schannels", viper.GetString("database.prefix"))
func GetDirectChannelByUser(user authm.Account, other authm.Account) (models.Channel, error) {
memberTable := "channel_members"
channelTable := "channels"
var channel models.Channel
if err := database.C.Preload("Members").

View File

@ -2,10 +2,13 @@ package services
import (
"fmt"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/passport/pkg/authkit"
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
"strings"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
jsoniter "github.com/json-iterator/go"
@ -86,9 +89,9 @@ func NewEvent(event models.Event) (models.Event, error) {
event, _ = GetEvent(event.Channel, event.ID)
idxList := lo.Map(members, func(item models.ChannelMember, index int) uint64 {
return uint64(item.Account.ID)
return uint64(item.AccountID)
})
PushCommandBatch(idxList, models.UnifiedCommand{
PushCommandBatch(idxList, nex.WebSocketPackage{
Action: "events.new",
Payload: event,
})
@ -106,8 +109,8 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) {
raw, _ := jsoniter.Marshal(event.Body)
_ = jsoniter.Unmarshal(raw, &body)
var pendingUsers []models.Account
var mentionedUsers []models.Account
var pendingUsers []uint64
var mentionedUsers []uint64
for _, member := range members {
if member.ID != event.SenderID {
@ -115,31 +118,31 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) {
case models.NotifyLevelNone:
continue
case models.NotifyLevelMentioned:
if len(body.RelatedUsers) != 0 && lo.Contains(body.RelatedUsers, member.Account.ID) {
mentionedUsers = append(mentionedUsers, member.Account)
if len(body.RelatedUsers) != 0 && lo.Contains(body.RelatedUsers, member.AccountID) {
mentionedUsers = append(mentionedUsers, uint64(member.AccountID))
}
continue
default:
break
}
if lo.Contains(body.RelatedUsers, member.Account.ID) {
mentionedUsers = append(mentionedUsers, member.Account)
if lo.Contains(body.RelatedUsers, member.AccountID) {
mentionedUsers = append(mentionedUsers, uint64(member.AccountID))
} else {
pendingUsers = append(pendingUsers, member.Account)
pendingUsers = append(pendingUsers, uint64(member.AccountID))
}
}
}
var displayText string
var displaySubtitle *string
var displaySubtitle string
switch event.Type {
case models.EventMessageNew:
if body.Algorithm == "plain" {
displayText = body.Text
}
case models.EventMessageEdit:
displaySubtitle = lo.ToPtr("Edited a message")
displaySubtitle = "Edited a message"
if body.Algorithm == "plain" {
displayText = body.Text
}
@ -162,22 +165,22 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) {
}
if len(pendingUsers) > 0 {
err := NotifyAccountMessagerBatch(
err := authkit.NotifyUserBatch(
gap.Nx,
pendingUsers,
&proto.NotifyRequest{
pushkit.Notification{
Topic: "messaging.message",
Title: fmt.Sprintf("%s (%s)", event.Sender.Account.Nick, event.Channel.DisplayText()),
Title: fmt.Sprintf("%s (%s)", event.Sender.Nick, event.Channel.DisplayText()),
Subtitle: displaySubtitle,
Body: displayText,
Avatar: &event.Sender.Account.Avatar,
Metadata: EncodeJSONBody(map[string]any{
"user_id": event.Sender.Account.ID,
"user_name": event.Sender.Account.Name,
"user_nick": event.Sender.Account.Nick,
Metadata: map[string]any{
"avatar": event.Sender.Avatar,
"user_id": event.Sender.AccountID,
"user_name": event.Sender.Name,
"user_nick": event.Sender.Nick,
"channel_id": event.ChannelID,
}),
IsRealtime: true,
IsForcePush: false,
},
Priority: 5,
},
)
if err != nil {
@ -186,28 +189,28 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) {
}
if len(mentionedUsers) > 0 {
if displaySubtitle != nil && len(*displaySubtitle) > 0 {
*displaySubtitle += ", and metioned you"
if len(displaySubtitle) > 0 {
displaySubtitle += ", and mentioned you"
} else {
displaySubtitle = lo.ToPtr("Metioned you")
displaySubtitle = "Mentioned you"
}
err := NotifyAccountMessagerBatch(
err := authkit.NotifyUserBatch(
gap.Nx,
mentionedUsers,
&proto.NotifyRequest{
pushkit.Notification{
Topic: "messaging.message",
Title: fmt.Sprintf("%s (%s)", event.Sender.Account.Nick, event.Channel.DisplayText()),
Title: fmt.Sprintf("%s (%s)", event.Sender.Nick, event.Channel.DisplayText()),
Subtitle: displaySubtitle,
Body: displayText,
Avatar: &event.Sender.Account.Avatar,
Metadata: EncodeJSONBody(map[string]any{
"user_id": event.Sender.Account.ID,
"user_name": event.Sender.Account.Name,
"user_nick": event.Sender.Account.Nick,
Metadata: map[string]any{
"avatar": event.Sender.Avatar,
"user_id": event.Sender.AccountID,
"user_name": event.Sender.Name,
"user_nick": event.Sender.Nick,
"channel_id": event.ChannelID,
}),
IsRealtime: true,
IsForcePush: false,
},
Priority: 5,
},
)
if err != nil {

View File

@ -2,6 +2,7 @@ package services
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
@ -14,7 +15,7 @@ import (
func GetRealmWithExtID(id uint) (models.Realm, error) {
var realm models.Realm
pc, err := gap.H.GetServiceGrpcConn(hyper.ServiceTypeAuthProvider)
pc, err := gap.Nx.GetClientGrpcConn(nex.ServiceTypeAuth)
if err != nil {
return realm, err
}
@ -31,7 +32,7 @@ func GetRealmWithExtID(id uint) (models.Realm, error) {
func GetRealmWithAlias(alias string) (models.Realm, error) {
var realm models.Realm
pc, err := gap.H.GetServiceGrpcConn(hyper.ServiceTypeAuthProvider)
pc, err := gap.Nx.GetClientGrpcConn(nex.ServiceTypeAuth)
if err != nil {
return realm, err
}
@ -47,7 +48,7 @@ func GetRealmWithAlias(alias string) (models.Realm, error) {
}
func GetRealmMember(realmId uint, userId uint) (*proto.RealmMemberInfo, error) {
pc, err := gap.H.GetServiceGrpcConn(hyper.ServiceTypeAuthProvider)
pc, err := gap.Nx.GetClientGrpcConn(nex.ServiceTypeAuth)
if err != nil {
return nil, err
}
@ -63,7 +64,7 @@ func GetRealmMember(realmId uint, userId uint) (*proto.RealmMemberInfo, error) {
}
func ListRealmMember(realmId uint) ([]*proto.RealmMemberInfo, error) {
pc, err := gap.H.GetServiceGrpcConn(hyper.ServiceTypeAuthProvider)
pc, err := gap.Nx.GetClientGrpcConn(nex.ServiceTypeAuth)
if err != nil {
return nil, err
}

View File

@ -3,7 +3,6 @@ package services
import (
"context"
"fmt"
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
localCache "git.solsynth.dev/hydrogen/messaging/pkg/internal/cache"
@ -41,18 +40,11 @@ func SetTypingStatus(channelId uint, userId uint) error {
}
if !hitCache {
var account models.Account
if err := database.C.Where("external_id = ?", userId).First(&account).Error; err != nil {
return fmt.Errorf("account not found: %v", err)
}
var member models.ChannelMember
if err := database.C.
Where("account_id = ? AND channel_id = ?", account.ID, channelId).
Where("account_id = ? AND channel_id = ?", userId, channelId).
First(&member).Error; err != nil {
return fmt.Errorf("channel member not found: %v", err)
} else {
member.Account = account
}
var channel models.Channel
@ -65,7 +57,7 @@ func SetTypingStatus(channelId uint, userId uint) error {
}
for _, item := range channel.Members {
broadcastTarget = append(broadcastTarget, uint64(item.Account.ID))
broadcastTarget = append(broadcastTarget, uint64(item.AccountID))
}
data = map[string]any{
@ -77,11 +69,7 @@ func SetTypingStatus(channelId uint, userId uint) error {
}
// Cache queries
cacheManager := cache.New[any](localCache.S)
marshal := marshaler.New(cacheManager)
contx := context.Background()
marshal.Set(
_ = marshal.Set(
contx,
GetTypingStatusQueryCacheKey(channelId, userId),
statusQueryCacheEntry{broadcastTarget, data},
@ -89,7 +77,7 @@ func SetTypingStatus(channelId uint, userId uint) error {
)
}
sc := proto.NewStreamControllerClient(gap.H.GetDealerGrpcConn())
sc := proto.NewStreamControllerClient(gap.Nx.GetNexusGrpcConn())
_, err := sc.PushStreamBatch(context.Background(), &proto.PushStreamBatchRequest{
UserId: broadcastTarget,
Body: hyper.NetworkPackage{

View File

@ -2,31 +2,31 @@ package services
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"time"
"github.com/samber/lo"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
)
func PushCommand(userId uint, task models.UnifiedCommand) {
func PushCommand(userId uint, task nex.WebSocketPackage) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
pc := gap.H.GetDealerGrpcConn()
pc := gap.Nx.GetNexusGrpcConn()
_, _ = proto.NewStreamControllerClient(pc).PushStream(ctx, &proto.PushStreamRequest{
UserId: lo.ToPtr(uint64(userId)),
Body: task.Marshal(),
})
}
func PushCommandBatch(userId []uint64, task models.UnifiedCommand) {
func PushCommandBatch(userId []uint64, task nex.WebSocketPackage) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
pc := gap.H.GetDealerGrpcConn()
pc := gap.Nx.GetNexusGrpcConn()
_, _ = proto.NewStreamControllerClient(pc).PushStreamBatch(ctx, &proto.PushStreamBatchRequest{
UserId: userId,
Body: task.Marshal(),

View File

@ -1,6 +1,9 @@
package main
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/fatih/color"
"os"
"os/signal"
"syscall"
@ -11,7 +14,7 @@ import (
"git.solsynth.dev/hydrogen/messaging/pkg/internal/services"
"github.com/robfig/cron/v3"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/http"
pkg "git.solsynth.dev/hydrogen/messaging/pkg/internal"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/cache"
@ -27,6 +30,12 @@ func init() {
}
func main() {
// Booting screen
fmt.Println(color.YellowString(" __ __ _\n| \\/ | ___ ___ ___ __ _ __ _(_)_ __ __ _\n| |\\/| |/ _ \\/ __/ __|/ _` |/ _` | | '_ \\ / _` |\n| | | | __/\\__ \\__ \\ (_| | (_| | | | | | (_| |\n|_| |_|\\___||___/___/\\__,_|\\__, |_|_| |_|\\__, |\n |___/ |___/"))
fmt.Printf("%s v%s\n", color.New(color.FgHiYellow).Add(color.Bold).Sprintf("Hypernet.Messaging"), pkg.AppVersion)
fmt.Printf("The instant messaging service in Hypernet\n")
color.HiBlack("=====================================================\n")
// Configure settings
viper.AddConfigPath(".")
viper.AddConfigPath("..")
@ -38,8 +47,21 @@ func main() {
log.Panic().Err(err).Msg("An error occurred when loading settings.")
}
// Connect to nexus
if err := gap.InitializeToNexus(); err != nil {
log.Fatal().Err(err).Msg("An error occurred when connecting to nexus...")
}
// Load keypair
if reader, err := sec.NewInternalTokenReader(viper.GetString("security.internal_public_key")); err != nil {
log.Error().Err(err).Msg("An error occurred when reading internal public key for jwt. Authentication related features will be disabled.")
} else {
http.IReader = reader
log.Info().Msg("Internal jwt public key loaded.")
}
// Connect to database
if err := database.NewSource(); err != nil {
if err := database.NewGorm(); err != nil {
log.Fatal().Err(err).Msg("An error occurred when connect to database.")
} else if err := database.RunMigration(database.C); err != nil {
log.Fatal().Err(err).Msg("An error occurred when running database auto migration.")
@ -51,17 +73,12 @@ func main() {
}
// Connect other services
if err := gap.RegisterService(); err != nil {
log.Fatal().Err(err).Msg("An error occurred when connecting to consul...")
}
services.SetupLiveKit()
// Server
server.NewServer()
go server.Listen()
go http.NewServer().Listen()
grpc.NewGRPC()
go grpc.ListenGRPC()
go grpc.NewGrpc().Listen()
// Configure timed tasks
quartz := cron.New(cron.WithLogger(cron.VerbosePrintfLogger(&log.Logger)))
@ -69,13 +86,9 @@ func main() {
quartz.Start()
// Messages
log.Info().Msgf("Messaging v%s is started...", pkg.AppVersion)
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
log.Info().Msgf("Messaging v%s is quitting...", pkg.AppVersion)
quartz.Stop()
}

View File

@ -1,14 +1,9 @@
id = "messaging01"
frontend = "https://lian.solsynth.dev"
bind = "0.0.0.0:8447"
grpc_bind = "0.0.0.0:7447"
domain = "im.solsynth.dev"
secret = "LtTjzAGFLshwXhN4ZD4nG5KlMv1MWcsvfv03TSZYnT1VhiAnLIZFTnHUwR0XhGgi"
[dealer]
addr = "127.0.0.1:7442"
nexus_addr = "localhost:7001"
[debug]
database = false
@ -22,19 +17,5 @@ token_duration = 43200
empty_timeout_duration = 600
max_participants = 20
[mailer]
name = "Alphabot <alphabot@smartsheep.studio>"
smtp_host = "smtp.exmail.qq.com"
smtp_port = 465
username = "alphabot@smartsheep.studio"
password = "gz937Zxxzfcd9SeH"
[security]
cookie_domain = "localhost"
cookie_samesite = "Lax"
access_token_duration = 300
refresh_token_duration = 2592000
[database]
dsn = "host=localhost user=postgres password=password dbname=hy_messaging port=5432 sslmode=disable"
prefix = "messaging_"
internal_public_key = "keys/internal_public_key.pem"