diff --git a/internal/api/admin/admin.go b/internal/api/admin/admin.go index bafb5cdc..df0d8531 100644 --- a/internal/api/admin/admin.go +++ b/internal/api/admin/admin.go @@ -142,35 +142,24 @@ func (o *Api) AddUserAccount(c *gin.Context) { apiresp.GinError(c, err) return } - if _, err := o.chatClient.AddUserAccount(c, req); err != nil { + ip, err := o.GetClientIP(c) + if err != nil { apiresp.GinError(c, err) return } - - userInfo := &sdkws.UserInfo{ - UserID: req.User.UserID, - Nickname: req.User.Nickname, - FaceURL: req.User.FaceURL, - CreateTime: time.Now().UnixMilli(), - } imToken, err := o.imApiCaller.ImAdminTokenWithDefaultAdmin(c) if err != nil { apiresp.GinError(c, err) return } + ctx := o.WithAdminUser(mctx.WithApiToken(c, imToken)) - err = o.imApiCaller.RegisterUser(ctx, []*sdkws.UserInfo{userInfo}) + + err = o.registerChatUser(ctx, ip, []*chat.RegisterUserInfo{req.User}) if err != nil { - apiresp.GinError(c, err) return } - if resp, err := o.adminClient.FindDefaultFriend(c, &admin.FindDefaultFriendReq{}); err == nil { - _ = o.imApiCaller.ImportFriend(c, req.User.UserID, resp.UserIDs) - } - if resp, err := o.adminClient.FindDefaultGroup(c, &admin.FindDefaultGroupReq{}); err == nil { - _ = o.imApiCaller.InviteToGroup(c, req.User.UserID, resp.GroupIDs) - } apiresp.GinSuccess(c, nil) } diff --git a/pkg/common/db/model/chat/attribute.go b/pkg/common/db/model/chat/attribute.go index 9b83b2df..3597dd4a 100644 --- a/pkg/common/db/model/chat/attribute.go +++ b/pkg/common/db/model/chat/attribute.go @@ -140,6 +140,7 @@ func (o *Attribute) SearchNormalUser(ctx context.Context, keyword string, forbid {"account": bson.M{"$regex": keyword, "$options": "i"}}, {"nickname": bson.M{"$regex": keyword, "$options": "i"}}, {"phone_number": bson.M{"$regex": keyword, "$options": "i"}}, + {"email": bson.M{"$regex": keyword, "$options": "i"}}, } } return mongoutil.FindPage[*chat.Attribute](ctx, o.coll, filter, pagination)