Skip to content

Commit e4a241d

Browse files
authored
Merge pull request #347 from yokowu/fix-mod
fix: mod tidy
2 parents 149e6f8 + aba7485 commit e4a241d

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

backend/go.mod

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ require (
1717
github.com/pgvector/pgvector-go v0.3.0
1818
github.com/redis/go-redis/v9 v9.7.3
1919
github.com/rokku-c/go-openai v1.35.7-fix2
20+
github.com/sashabaranov/go-openai v1.41.1
21+
github.com/sirupsen/logrus v1.9.3
2022
github.com/spf13/viper v1.20.1
23+
gitlab.com/gitlab-org/api/client-go v0.142.6
2124
golang.org/x/crypto v0.41.0
2225
golang.org/x/oauth2 v0.30.0
2326
golang.org/x/text v0.28.0
@@ -76,13 +79,16 @@ require (
7679
github.com/gofiber/websocket/v2 v2.2.1 // indirect
7780
github.com/google/generative-ai-go v0.20.1 // indirect
7881
github.com/google/go-cmp v0.7.0 // indirect
82+
github.com/google/go-querystring v1.1.0 // indirect
7983
github.com/google/s2a-go v0.1.9 // indirect
8084
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
8185
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
8286
github.com/goph/emperror v0.17.2 // indirect
8387
github.com/gorilla/websocket v1.5.3 // indirect
8488
github.com/hashicorp/errwrap v1.1.0 // indirect
89+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
8590
github.com/hashicorp/go-multierror v1.1.1 // indirect
91+
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
8692
github.com/hashicorp/hcl/v2 v2.23.0 // indirect
8793
github.com/invopop/yaml v0.1.0 // indirect
8894
github.com/joho/godotenv v1.5.1 // indirect
@@ -111,13 +117,11 @@ require (
111117
github.com/rs/xid v1.6.0 // indirect
112118
github.com/sagikazarmark/locafero v0.9.0 // indirect
113119
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
114-
github.com/sirupsen/logrus v1.9.3 // indirect
115120
github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect
116121
github.com/sourcegraph/conc v0.3.0 // indirect
117122
github.com/spf13/afero v1.14.0 // indirect
118123
github.com/spf13/cast v1.7.1 // indirect
119124
github.com/spf13/pflag v1.0.6 // indirect
120-
github.com/stretchr/testify v1.11.1 // indirect
121125
github.com/subosito/gotenv v1.6.0 // indirect
122126
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
123127
github.com/valyala/bytebufferpool v1.0.0 // indirect
@@ -136,7 +140,6 @@ require (
136140
go.opentelemetry.io/otel/metric v1.37.0 // indirect
137141
go.opentelemetry.io/otel/trace v1.37.0 // indirect
138142
go.uber.org/atomic v1.11.0 // indirect
139-
go.uber.org/mock v0.6.0 // indirect
140143
go.uber.org/multierr v1.11.0 // indirect
141144
golang.org/x/arch v0.19.0 // indirect
142145
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792 // indirect

backend/go.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8
101101
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
102102
github.com/fasthttp/websocket v1.5.3 h1:TPpQuLwJYfd4LJPXvHDYPMFWbLjsT91n3GpWtCQtdek=
103103
github.com/fasthttp/websocket v1.5.3/go.mod h1:46gg/UBmTU1kUaTcwQXpUxtRwG2PvIZYeA8oL6vF3Fs=
104+
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
105+
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
104106
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
105107
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
106108
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
@@ -159,8 +161,11 @@ github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6
159161
github.com/google/generative-ai-go v0.20.1 h1:6dEIujpgN2V0PgLhr6c/M1ynRdc7ARtiIDPFzj45uNQ=
160162
github.com/google/generative-ai-go v0.20.1/go.mod h1:TjOnZJmZKzarWbjUJgy+r3Ee7HGBRVLhOIgupnwR4Bg=
161163
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
164+
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
162165
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
163166
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
167+
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
168+
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
164169
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
165170
github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=
166171
github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=
@@ -183,8 +188,14 @@ github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
183188
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
184189
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
185190
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
191+
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
192+
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
193+
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
194+
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
186195
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
187196
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
197+
github.com/hashicorp/go-retryablehttp v0.7.8 h1:ylXZWnqa7Lhqpk0L1P1LzDtGcCR0rPVUrx/c8Unxc48=
198+
github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3iS0jrZ7LvzFGFmuKbw=
188199
github.com/hashicorp/hcl/v2 v2.23.0 h1:Fphj1/gCylPxHutVSEOf2fBOh1VE4AuLV7+kbJf3qos=
189200
github.com/hashicorp/hcl/v2 v2.23.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
190201
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
@@ -309,6 +320,8 @@ github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
309320
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
310321
github.com/sagikazarmark/locafero v0.9.0 h1:GbgQGNtTrEmddYDSAH9QLRyfAHY12md+8YFTqyMTC9k=
311322
github.com/sagikazarmark/locafero v0.9.0/go.mod h1:UBUyz37V+EdMS3hDF3QWIiVr/2dPrx49OMO0Bn0hJqk=
323+
github.com/sashabaranov/go-openai v1.41.1 h1:zf5tM+GuxpyiyD9XZg8nCqu52eYFQg9OOew0gnIuDy4=
324+
github.com/sashabaranov/go-openai v1.41.1/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
312325
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee h1:8Iv5m6xEo1NR1AvpV+7XmhI4r39LGNzwUL4YpMuL5vk=
313326
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee/go.mod h1:qwtSXrKuJh/zsFQ12yEE89xfCrGKK63Rr7ctU/uCo4g=
314327
github.com/sebdah/goldie/v2 v2.5.5 h1:rx1mwF95RxZ3/83sdS4Yp7t2C5TCokvWP4TBRbAyEWY=
@@ -396,6 +409,8 @@ github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6
396409
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM=
397410
github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWBdig0=
398411
github.com/zclconf/go-cty-yaml v1.1.0/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs=
412+
gitlab.com/gitlab-org/api/client-go v0.142.6 h1:RjqPb7XxJypn9DzkSTuQUOJN7wpRGXZFH8rJCLj4Bg8=
413+
gitlab.com/gitlab-org/api/client-go v0.142.6/go.mod h1:t02B5oJWYEzalBlYIh+PmEJm2H4LPC/VFM1xks5qtG8=
399414
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
400415
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
401416
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 h1:q4XOmH/0opmeuJtPsbFNivyl7bCt7yRBbeEm2sC/XtQ=
@@ -498,6 +513,7 @@ golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps
498513
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
499514
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
500515
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
516+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
501517
google.golang.org/api v0.239.0 h1:2hZKUnFZEy81eugPs4e2XzIJ5SOwQg0G82bpXD65Puo=
502518
google.golang.org/api v0.239.0/go.mod h1:cOVEm2TpdAGHL2z+UwyS+kmlGr3bVWQQ6sYEqkKje50=
503519
google.golang.org/genai v1.13.0 h1:LRhwx5PU+bXhfnXyPEHu2kt9yc+MpvuYbajxSorOJjg=

backend/internal/user/repo/user.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ func (r *UserRepo) OAuthLogin(ctx context.Context, platform consts.UserPlatform,
423423
if ui.Edges.User.Status != consts.UserStatusActive {
424424
return nil, errcode.ErrUserLock
425425
}
426+
if ui.Nickname != req.Name {
427+
if err = entx.WithTx(ctx, r.db, func(tx *db.Tx) error {
428+
return r.updateUsername(ctx, tx, ui, req.Name)
429+
}); err != nil {
430+
return nil, err
431+
}
432+
}
426433
if ui.AvatarURL != req.AvatarURL {
427434
if err = entx.WithTx(ctx, r.db, func(tx *db.Tx) error {
428435
return r.updateAvatar(ctx, tx, ui, req.AvatarURL)
@@ -433,6 +440,13 @@ func (r *UserRepo) OAuthLogin(ctx context.Context, platform consts.UserPlatform,
433440
return ui.Edges.User, nil
434441
}
435442

443+
func (r *UserRepo) updateUsername(ctx context.Context, tx *db.Tx, ui *db.UserIdentity, name string) error {
444+
if err := tx.UserIdentity.UpdateOneID(ui.ID).SetNickname(name).Exec(ctx); err != nil {
445+
return err
446+
}
447+
return tx.User.UpdateOneID(ui.UserID).SetUsername(name).Exec(ctx)
448+
}
449+
436450
func (r *UserRepo) updateAvatar(ctx context.Context, tx *db.Tx, ui *db.UserIdentity, avatar string) error {
437451
if err := tx.UserIdentity.UpdateOneID(ui.ID).SetAvatarURL(avatar).Exec(ctx); err != nil {
438452
return err
@@ -452,6 +466,11 @@ func (r *UserRepo) SignUpOrIn(ctx context.Context, platform consts.UserPlatform,
452466
if u.Status != consts.UserStatusActive {
453467
return errcode.ErrUserLock
454468
}
469+
if ui.Nickname != req.Name {
470+
if err = r.updateUsername(ctx, tx, ui, req.Name); err != nil {
471+
return err
472+
}
473+
}
455474
if ui.AvatarURL != req.AvatarURL {
456475
if err = r.updateAvatar(ctx, tx, ui, req.AvatarURL); err != nil {
457476
return err

0 commit comments

Comments
 (0)