Skip to content

Commit

Permalink
update to adjust more type
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewZuo01 committed Dec 15, 2023
1 parent f20ec27 commit 0a18e14
Show file tree
Hide file tree
Showing 8 changed files with 578 additions and 572 deletions.
9 changes: 6 additions & 3 deletions internal/rpc/chat/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ func (o *chatSvr) RegisterUser(ctx context.Context, req *chat.RegisterUserReq) (
return nil, err
}
}
var registerType int32
if req.User.PhoneNumber != "" {
if req.User.AreaCode[0] != '+' {
req.User.AreaCode = "+" + req.User.AreaCode
Expand All @@ -337,7 +338,9 @@ func (o *chatSvr) RegisterUser(ctx context.Context, req *chat.RegisterUserReq) (
} else if !o.Database.IsNotFound(err) {
return nil, err
}
registerType = constant.PhoneRegister
}

if req.User.Account != "" {
_, err := o.Database.TakeAttributeByAccount(ctx, req.User.Account)
if err == nil {
Expand All @@ -346,10 +349,10 @@ func (o *chatSvr) RegisterUser(ctx context.Context, req *chat.RegisterUserReq) (
return nil, err
}
}
var emailRegister bool

if req.User.Email != "" {
_, err := o.Database.TakeAttributeByEmail(ctx, req.User.Email)
emailRegister = true
registerType = constant.EmailRegister
if err == nil {
return nil, eerrs.ErrEmailAlreadyRegister.Wrap()
} else if !o.Database.IsNotFound(err) {
Expand Down Expand Up @@ -387,7 +390,7 @@ func (o *chatSvr) RegisterUser(ctx context.Context, req *chat.RegisterUserReq) (
AllowVibration: constant.DefaultAllowVibration,
AllowBeep: constant.DefaultAllowBeep,
AllowAddFriend: constant.DefaultAllowAddFriend,
EmailRegister: emailRegister,
RegisterType: registerType,
}
if err := o.Database.RegisterUser(ctx, register, account, attribute); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion internal/rpc/chat/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func DbToPbUserFullInfo(attribute *chat.Attribute) *common.UserFullInfo {
AllowBeep: attribute.AllowBeep,
AllowVibration: attribute.AllowVibration,
GlobalRecvMsgOpt: attribute.GlobalRecvMsgOpt,
EmailRegistered: attribute.EmailRegister,
RegisterType: attribute.RegisterType,
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/common/constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,8 @@ const (
const DefaultPlatform = 1

const CtxApiToken = "api-token"

const (
EmailRegister = 1
PhoneRegister = 2
)
2 changes: 1 addition & 1 deletion pkg/common/db/table/chat/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Attribute struct {
AllowBeep int32 `gorm:"column:allow_beep;default:1"`
AllowAddFriend int32 `gorm:"column:allow_add_friend;default:1"`
GlobalRecvMsgOpt int32 `gorm:"column:global_recv_msg_opt;default:0"`
EmailRegister bool `gorm:"column:email_register"`
RegisterType int32 `gorm:"column:register_type"`
}

func (Attribute) TableName() string {
Expand Down
991 changes: 495 additions & 496 deletions pkg/proto/chat/chat.pb.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/proto/chat/chat.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ message UpdateUserInfoReq{
OpenIMServer.protobuf.Int32Value allowBeep = 12;
OpenIMServer.protobuf.Int32Value allowVibration = 13;
OpenIMServer.protobuf.Int32Value globalRecvMsgOpt = 14;
OpenIMServer.protobuf.BoolValue emailRegistered = 15;
OpenIMServer.protobuf.Int32Value RegisterType = 15;
}

message UpdateUserInfoResp{
Expand Down Expand Up @@ -114,7 +114,7 @@ message RegisterUserInfo {
string email = 8;
string account = 9;
string password = 10;
bool emailRegistered = 11;
int32 RegisterType = 11;
}

message RegisterUserReq {
Expand Down
135 changes: 67 additions & 68 deletions pkg/proto/common/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/proto/common/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ message UserFullInfo{
int32 allowBeep = 13;
int32 allowVibration = 14;
int32 globalRecvMsgOpt = 15;
bool emailRegistered = 16;
int32 registerType = 16;
}

message UserPublicInfo{
Expand Down

0 comments on commit 0a18e14

Please sign in to comment.