Skip to content

Commit

Permalink
fix bug: obtain user online status err(#567) (#592)
Browse files Browse the repository at this point in the history
* fix: implement of GetUsersOnlineStatus (#567)

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

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

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

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

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

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

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

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

* fix bug: obtain user online status err(#567)
  • Loading branch information
BanTanger committed Jul 22, 2023
1 parent 5a7084a commit edd6a86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion internal/api/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) {
reply, err := msgClient.GetUsersOnlineStatus(c, &req)
if err != nil {
log.ZWarn(c, "GetUsersOnlineStatus rpc err", err)
continue

parseError := apiresp.ParseError(err)
log.ZDebug(c, "errcode bantanger", "errcode", parseError.ErrCode)
if parseError.ErrCode == errs.NoPermissionError {
apiresp.GinError(c, err)
return
}
} else {
wsResult = append(wsResult, reply.SuccessResult...)
}
Expand Down
6 changes: 5 additions & 1 deletion internal/msggateway/hub_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit edd6a86

Please sign in to comment.