Merge remote-tracking branch 'origin/tuoyun' into tuoyun

pull/232/head
skiffer-git 2 years ago
commit 6a149c74d1

@ -700,4 +700,4 @@ demo:
imAPIURL: http://127.0.0.1:10002 imAPIURL: http://127.0.0.1:10002
rtc: rtc:
signalTimeout: 3000 signalTimeout: 60

@ -21,9 +21,7 @@ func GetRTCInvitationInfo(c *gin.Context) {
return return
} }
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
var ok bool ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var errInfo string
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok { if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg) 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()}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return 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.OpUserID = invitationInfo.OpUserID
resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID
resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType

@ -3,7 +3,6 @@ package gate
import ( import (
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/grpc-etcdv3/getcdv3"
pbChat "Open_IM/pkg/proto/chat" pbChat "Open_IM/pkg/proto/chat"
@ -238,13 +237,7 @@ func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
ws.sendSignalMsgResp(conn, 200, err.Error(), m, &signalResp) ws.sendSignalMsgResp(conn, 200, err.Error(), m, &signalResp)
} else { } else {
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String()) log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
// save invitation info for offline push ws.sendSignalMsgResp(conn, 0, "", m, &signalResp)
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 { } else {
log.NewError(m.OperationID, utils.GetSelfFuncName(), respPb.IsPass, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg) log.NewError(m.OperationID, utils.GetSelfFuncName(), respPb.IsPass, respPb.CommonResp.ErrCode, respPb.CommonResp.ErrMsg)

@ -10,6 +10,7 @@ import (
"Open_IM/internal/push" "Open_IM/internal/push"
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/grpc-etcdv3/getcdv3"
pbPush "Open_IM/pkg/proto/push" pbPush "Open_IM/pkg/proto/push"
@ -126,6 +127,11 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
if err != nil { if err != nil {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error()) 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) log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), UIDList, content, jsonCustomContent, "opts:", opts)
pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, pushMsg.OperationID, opts) pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, pushMsg.OperationID, opts)
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline pushResult: ", pushResult) log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline pushResult: ", pushResult)

@ -1426,12 +1426,12 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
if req.Ex != nil { if req.Ex != nil {
m["ex"] = req.Ex.Value m["ex"] = req.Ex.Value
} }
err = imdb.UpdateGroupMemberInfoByMap(groupMember, m) err = imdb.UpdateGroupMemberInfoByMap(groupMember, m)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetGroupMemberInfo failed", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetGroupMemberInfo failed", err.Error())
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + ":" + err.Error() resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + ":" + err.Error()
return resp, nil
} }
chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID) chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())

@ -222,7 +222,7 @@ var ContentType2PushContent = map[int64]string{
AtText: "[有人@你]", AtText: "[有人@你]",
GroupMsg: "你收到一条群聊消息", GroupMsg: "你收到一条群聊消息",
Common: "你收到一条新消息", Common: "你收到一条新消息",
SignalMsg: "音視頻通話邀請", SignalMsg: "音视频通话邀请",
} }
const ( const (

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

Loading…
Cancel
Save