fix bug: obtain user online status err(#567)

Signed-off-by: BanTanger <88583317+BanTanger@users.noreply.github.com>
pull/636/head
BanTanger 2 years ago
parent f25f7e0ef8
commit df16bda12f

@ -84,7 +84,11 @@ func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) {
reply, err := msgClient.GetUsersOnlineStatus(c, &req)
if err != nil {
log.ZWarn(c, "GetUsersOnlineStatus rpc err", err)
continue
// apiresp.GinError(c, err)
parseError := apiresp.ParseError(err)
if parseError.ErrCode == errs.NoPermissionError {
apiresp.GinError(c, err)
}
} else {
wsResult = append(wsResult, reply.SuccessResult...)
}

@ -16,8 +16,9 @@ package msggateway
import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"google.golang.org/grpc"
@ -82,6 +83,9 @@ func (s *Server) GetUsersOnlineStatus(
ctx context.Context,
req *msggateway.GetUsersOnlineStatusReq,
) (*msggateway.GetUsersOnlineStatusResp, error) {
if !tokenverify.IsAppManagerUid(ctx) {
return nil, errs.ErrNoPermission.Wrap("only app manager")
}
var resp msggateway.GetUsersOnlineStatusResp
for _, userID := range req.UserIDs {
clients, ok := s.LongConnServer.GetUserAllCons(userID)

Loading…
Cancel
Save