pull/232/head
wangchuxiao 2 years ago
parent 891738747a
commit 1687b70bde

@ -21,9 +21,7 @@ func GetRTCInvitationInfo(c *gin.Context) {
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool
var errInfo string
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
@ -37,6 +35,10 @@ func GetRTCInvitationInfo(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
if err := db.DB.DelUserSignalList(userID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelUserSignalList result:", err.Error())
}
resp.Data.OpUserID = invitationInfo.OpUserID
resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID
resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType

@ -3,7 +3,6 @@ package gate
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbChat "Open_IM/pkg/proto/chat"
@ -238,14 +237,8 @@ func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
ws.sendSignalMsgResp(conn, 200, err.Error(), m, &signalResp)
} else {
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
// save invitation info for offline push
if err := db.DB.NewCacheSignalInfo(pbData.MsgData); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), m, &signalResp)
ws.sendSignalMsgResp(conn, 200, err.Error(), m, &signalResp)
} else {
ws.sendSignalMsgResp(conn, 0, "", m, &signalResp)
}
}
} else {
log.NewError(m.OperationID, utils.GetSelfFuncName(), respPb.IsPass, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg)
ws.sendSignalMsgResp(conn, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg, m, &signalResp)

@ -10,6 +10,7 @@ import (
"Open_IM/internal/push"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbPush "Open_IM/pkg/proto/push"
@ -126,6 +127,11 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
if err != nil {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error())
}
// save invitation info for offline push
if err := db.DB.HandleSignalInfo(pushMsg.MsgData); err != nil {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), err.Error(), pushMsg.MsgData)
continue
}
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), UIDList, content, jsonCustomContent, "opts:", opts)
pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, pushMsg.OperationID, opts)
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline pushResult: ", pushResult)

@ -108,22 +108,26 @@ func (d *DataBases) CleanUpOneUserAllMsgFromRedis(userID string, operationID str
return nil
}
func (d *DataBases) NewCacheSignalInfo(msg *pbCommon.MsgData) error {
func (d *DataBases) HandleSignalInfo(msg *pbCommon.MsgData) error {
req := &pbRtc.SignalReq{}
if err := proto.Unmarshal(msg.Content, req); err != nil {
return err
}
//log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "SignalReq: ", req.String())
var inviteeUserIDList []string
switch invitationInfo := req.Payload.(type) {
var isInviteSignal bool
switch signalInfo := req.Payload.(type) {
case *pbRtc.SignalReq_Invite:
inviteeUserIDList = invitationInfo.Invite.Invitation.InviteeUserIDList
inviteeUserIDList = signalInfo.Invite.Invitation.InviteeUserIDList
isInviteSignal = true
case *pbRtc.SignalReq_InviteInGroup:
inviteeUserIDList = invitationInfo.InviteInGroup.Invitation.InviteeUserIDList
inviteeUserIDList = signalInfo.InviteInGroup.Invitation.InviteeUserIDList
isInviteSignal = true
default:
log2.NewDebug("", utils.GetSelfFuncName(), "req type not invite", string(msg.Content))
log2.NewDebug("", utils.GetSelfFuncName(), "req invalid type", string(msg.Content))
return nil
}
if isInviteSignal {
for _, userID := range inviteeUserIDList {
timeout, err := strconv.Atoi(config.Config.Rtc.SignalTimeout)
if err != nil {
@ -145,6 +149,7 @@ func (d *DataBases) NewCacheSignalInfo(msg *pbCommon.MsgData) error {
}
return err
}
}
return nil
}
@ -183,14 +188,14 @@ func (d *DataBases) GetAvailableSignalInvitationInfo(userID string) (invitationI
if err != nil {
return nil, utils.Wrap(err, "GetSignalInfoFromCacheByClientMsgID")
}
err = d.delUserSingalList(userID)
err = d.DelUserSignalList(userID)
if err != nil {
return nil, utils.Wrap(err, "GetSignalInfoFromCacheByClientMsgID")
}
return invitationInfo, nil
}
func (d *DataBases) delUserSingalList(userID string) error {
func (d *DataBases) DelUserSignalList(userID string) error {
keyList := SignalListCache + userID
err := d.rdb.Del(context.Background(), keyList).Err()
return err

Loading…
Cancel
Save