mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-02 18:34:29 +08:00
fix pageFindUser
This commit is contained in:
parent
0009d27dd4
commit
9cd1cbe95d
@ -547,7 +547,6 @@ func (s *userServer) AddNotificationAccount(ctx context.Context, req *pbuser.Add
|
||||
}
|
||||
|
||||
user := &tablerelation.UserModel{
|
||||
UserID: req.UserID,
|
||||
UserID: req.UserID,
|
||||
Nickname: req.NickName,
|
||||
FaceURL: req.FaceURL,
|
||||
@ -597,41 +596,43 @@ func (s *userServer) UpdateNotificationAccountInfo(ctx context.Context, req *pbu
|
||||
}
|
||||
|
||||
func (s *userServer) SearchNotificationAccount(ctx context.Context, req *pbuser.SearchNotificationAccountReq) (*pbuser.SearchNotificationAccountResp, error) {
|
||||
// Check if user is an admin
|
||||
if err := authverify.CheckIMAdmin(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var users []*relation.UserModel
|
||||
var err error
|
||||
|
||||
// If a keyword is provided in the request
|
||||
if req.Keyword != "" {
|
||||
users, err = s.UserDatabase.Find(ctx, []string{req.Keyword})
|
||||
var users []*relation.UserModel
|
||||
var err error
|
||||
if req.Keyword != "" {
|
||||
// Find users by keyword
|
||||
users, err = s.UserDatabase.Find(ctx, []string{req.Keyword})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Convert users to response format
|
||||
resp := s.userModelToResp(users, req.Pagination)
|
||||
if resp.Total != 0 {
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// Find users by nickname if no users found by keyword
|
||||
users, err = s.UserDatabase.FindByNickname(ctx, req.Keyword)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = s.userModelToResp(users, req.Pagination)
|
||||
return resp, nil
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// If no keyword, find users with notification settings
|
||||
users, err = s.UserDatabase.FindNotification(ctx, constant.AppNotificationAdmin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := s.userModelToResp(users, req.Pagination)
|
||||
resp := s.userModelToResp(users, req.Pagination)
|
||||
return resp, nil
|
||||
}
|
||||
@ -684,8 +685,4 @@ func (s *userServer) userModelToResp(users []*relation.UserModel, pagination pag
|
||||
notificationAccounts := utils.Paginate(accounts, int(pagination.GetPageNumber()), int(pagination.GetShowNumber()))
|
||||
|
||||
return &pbuser.SearchNotificationAccountResp{Total: total, NotificationAccounts: notificationAccounts}
|
||||
|
||||
notificationAccounts := utils.Paginate(accounts, int(pagination.GetPageNumber()), int(pagination.GetShowNumber()))
|
||||
|
||||
return &pbuser.SearchNotificationAccountResp{Total: total, NotificationAccounts: notificationAccounts}
|
||||
}
|
||||
|
||||
@ -52,8 +52,6 @@ type UserDatabase interface {
|
||||
PageFindUser(ctx context.Context, level1 int64, level2 int64, pagination pagination.Pagination) (count int64, users []*relation.UserModel, err error)
|
||||
// Page If not found, no error is returned
|
||||
Page(ctx context.Context, pagination pagination.Pagination) (count int64, users []*relation.UserModel, err error)
|
||||
// FindUser
|
||||
PageFindUser(ctx context.Context, level int64, pagination pagination.Pagination) (count int64, users []*relation.UserModel, err error)
|
||||
// IsExist true as long as one exists
|
||||
IsExist(ctx context.Context, userIDs []string) (exist bool, err error)
|
||||
// GetAllUserID Get all user IDs
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user