Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
Updating grpc.proto package to latest version [1.2.7]
Browse files Browse the repository at this point in the history
Removing State field from user model
  • Loading branch information
mrjosh committed Aug 17, 2020
1 parent 3a158f9 commit 9068977
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 39 deletions.
2 changes: 0 additions & 2 deletions db/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ type User struct {
TwoFactorAuthEnabled bool `bson:"two_fa_enabled, omitempty" json:"two_fa_enabled"`
TwoFactorAuthToken string `bson:"two_fa_token, omitempty" json:"_"`

State int `bson:"state, omitempty" json:"state, omitempty"`
Activity Activity `bson:"activity, omitempty" json:"activity, omitempty"`
Avatar string `bson:"avatar, omitempty" json:"avatar, omitempty"`
RoleId uint `bson:"role_id, omitempty" json:"role_id, omitempty"`
LastLogin time.Time `bson:"last_login, omitempty" json:"last_login, omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/CastyLab/grpc.server
go 1.14

require (
github.com/CastyLab/grpc.proto v0.0.0-20200814112654-f402ce5f4887
github.com/CastyLab/grpc.proto v0.0.0-20200817114812-aded2da55bf8
github.com/MrJoshLab/go-respond v0.0.0-20191125172458-25d4d18aaa1b
github.com/asticode/go-astisub v0.2.0
github.com/dgrijalva/jwt-go v3.2.0+incompatible
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ github.com/CastyLab/grpc.proto v0.0.0-20200814112303-e12591a8e370 h1:K5I1UVqUT07
github.com/CastyLab/grpc.proto v0.0.0-20200814112303-e12591a8e370/go.mod h1:5ypgijUv7rWXMsRbUZXEgTucAA+4BpHtXgGIvOyUGRU=
github.com/CastyLab/grpc.proto v0.0.0-20200814112654-f402ce5f4887 h1:N3KgjopUhEDbzxvQgDn1FtWGOEyMJu8bce4w1JFgRLE=
github.com/CastyLab/grpc.proto v0.0.0-20200814112654-f402ce5f4887/go.mod h1:5ypgijUv7rWXMsRbUZXEgTucAA+4BpHtXgGIvOyUGRU=
github.com/CastyLab/grpc.proto v0.0.0-20200817113914-fa2f219ad733 h1:nfqIDh8JTQ9n4sTQ3du4e+M1wLwknN9my5eLrsDbyqs=
github.com/CastyLab/grpc.proto v0.0.0-20200817113914-fa2f219ad733/go.mod h1:5ypgijUv7rWXMsRbUZXEgTucAA+4BpHtXgGIvOyUGRU=
github.com/CastyLab/grpc.proto v0.0.0-20200817114812-aded2da55bf8 h1:Rzx+c/bDPjvTWSO2bvelp8mGZ+Y1UWxl1uZoMP5ebFk=
github.com/CastyLab/grpc.proto v0.0.0-20200817114812-aded2da55bf8/go.mod h1:5ypgijUv7rWXMsRbUZXEgTucAA+4BpHtXgGIvOyUGRU=
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw=
github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w=
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
Expand Down
8 changes: 0 additions & 8 deletions helpers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,12 @@ func NewProtoUser(user *models.User) (*proto.User, error) {
Verified: user.Verified,
EmailVerified: user.EmailVerified,
Avatar: user.Avatar,
State: proto.PERSONAL_STATE(user.State),
TwoFaEnabled: user.TwoFactorAuthEnabled,
TwoFaToken: user.TwoFactorAuthToken,
LastLogin: lastLogin,
JoinedAt: joinedAt,
UpdatedAt: updatedAt,
}

if user.Activity.ID != nil {
protoUser.Activity = &proto.Activity{
Id: user.Activity.ID.Hex(),
Activity: user.Activity.Activity,
}
}

return protoUser, nil
}
28 changes: 0 additions & 28 deletions services/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,34 +80,6 @@ func (s *Service) UpdateActivity(ctx context.Context, req *proto.UpdateActivityR
}, nil
}

func (s *Service) UpdateState(ctx context.Context, req *proto.UpdateStateRequest) (*proto.Response, error) {

user, err := auth.Authenticate(req.AuthRequest)
if err != nil {
return nil, err
}

var (
filter = bson.M{"_id": user.ID}
update = bson.M{
"$set": bson.M{
"state": int(req.State),
},
}
)

if _, err := db.Connection.Collection("users").UpdateOne(ctx, filter, update); err != nil {
sentry.CaptureException(err)
return nil, status.Error(codes.Aborted, "The requested parameter is not updated!")
}

return &proto.Response{
Status: "success",
Code: http.StatusOK,
Message: "The requested parameter is updated successfully!",
}, nil
}

func (s *Service) GetUser(_ context.Context, req *proto.AuthenticateRequest) (*proto.GetUserResponse, error) {

user, err := auth.Authenticate(req)
Expand Down

0 comments on commit 9068977

Please sign in to comment.