Skip to content

Commit b97c981

Browse files
authored
chore(handler): fix profile_data patch bug (#158)
Because - we can't successfully patch user profile_data This commit - fix profile_data patch bug
1 parent 21ad098 commit b97c981

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pkg/handler/publichandler.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,16 @@ func (h *PublicHandler) PatchAuthenticatedUser(ctx context.Context, req *mgmtPB.
249249

250250
reqUser := req.GetUser()
251251

252+
pbUpdateMask := req.GetUpdateMask()
253+
// profile_data field is type google.protobuf.Struct, which needs to be updated as a whole
254+
for idx, path := range pbUpdateMask.Paths {
255+
if strings.Contains(path, "profile_data") {
256+
pbUpdateMask.Paths[idx] = "profile_data"
257+
}
258+
}
259+
252260
// Validate the field mask
253-
if !req.GetUpdateMask().IsValid(reqUser) {
261+
if !pbUpdateMask.IsValid(reqUser) {
254262
return nil, fmt.Errorf("err")
255263
}
256264

pkg/service/service.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ type Service interface {
8484
PBToken2DBToken(ctx context.Context, pbToken *mgmtPB.ApiToken) (*datamodel.Token, error)
8585

8686
GetRedisClient() *redis.Client
87+
GetInfluxClient() repository.InfluxDB
8788
}
8889

8990
type service struct {
@@ -109,6 +110,10 @@ func (s *service) GetRedisClient() *redis.Client {
109110
return s.redisClient
110111
}
111112

113+
func (s *service) GetInfluxClient() repository.InfluxDB {
114+
return s.influxDB
115+
}
116+
112117
// GetUser returns the api user
113118
func (s *service) AuthenticateUser(ctx context.Context, allowVisitor bool) (userID string, userUID uuid.UUID, err error) {
114119
// Verify if "jwt-sub" is in the header

0 commit comments

Comments
 (0)