Skip to content

Commit

Permalink
feat: fcm 토큰 수정 기능 구현 (gRPC)
Browse files Browse the repository at this point in the history
- gRPC로도 토큰을 수정할 수 있습니다.
  • Loading branch information
YehyeokBang committed Feb 3, 2024
1 parent aea5d8f commit 0fb238c
Show file tree
Hide file tree
Showing 4 changed files with 287 additions and 78 deletions.
21 changes: 20 additions & 1 deletion app/user/pb/user_pb_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func NewUserPbApp(userRepository repositories.UserRepositoryInterface, userUtil
func (app *UserPbApp) Login(c context.Context, req *userpb.RequestCreateUser) (*userpb.ResponseToken, error) {
user := models.User{
Name: req.Name,
Nickname: req.Nickname,
Nickname: req.Name,
FcmToken: req.FcmToken,
Email: req.Email,
Age: int(req.Age),
Gender: req.Gender,
Expand Down Expand Up @@ -64,6 +65,24 @@ func (app *UserPbApp) GetUserInfo(c context.Context, req *userpb.Empty) (*userpb
}, nil
}

func (app *UserPbApp) UpdateFcmToken(c context.Context, req *userpb.RequestUpdateFcmToken) (*userpb.ResponseUpdateFcmToken, error) {
userID := c.Value(auth.UserIDKey).(string)

user, err := app.UserRepository.FindByID(userID)
if err != nil {
return nil, err
}

user.FcmToken = req.FcmToken

_, err = app.UserRepository.Update(&user)
if err != nil {
return nil, err
}

return &userpb.ResponseUpdateFcmToken{Message: "Fcm token updated successfully"}, nil
}

func (app *UserPbApp) UpdateUserInfo(c context.Context, req *userpb.RequestUpdateUser) (*userpb.ResponseUser, error) {
userID := c.Value(auth.UserIDKey).(string)

Expand Down
Loading

0 comments on commit 0fb238c

Please sign in to comment.