|
|
@ -7,12 +7,9 @@
|
|
|
|
package gate
|
|
|
|
package gate
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"Open_IM/internal/msg_gateway/gate/open_im_media"
|
|
|
|
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
|
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
|
|
"Open_IM/pkg/utils"
|
|
|
|
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -117,139 +114,139 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (ws *WServer) signalMessageAssemble(s *open_im_sdk.SignalReq, operationID string) (isPass bool, errCode int32, errMsg string, r *open_im_sdk.SignalResp, msgData *open_im_sdk.MsgData) {
|
|
|
|
//func (ws *WServer) signalMessageAssemble(s *open_im_sdk.SignalReq, operationID string) (isPass bool, errCode int32, errMsg string, r *open_im_sdk.SignalResp, msgData *open_im_sdk.MsgData) {
|
|
|
|
var msg open_im_sdk.MsgData
|
|
|
|
// var msg open_im_sdk.MsgData
|
|
|
|
var resp open_im_sdk.SignalResp
|
|
|
|
// var resp open_im_sdk.SignalResp
|
|
|
|
media := open_im_media.NewMedia()
|
|
|
|
// media := open_im_media.NewMedia()
|
|
|
|
msg.MsgFrom = constant.UserMsgType
|
|
|
|
// msg.MsgFrom = constant.UserMsgType
|
|
|
|
msg.ContentType = constant.SignalingNotification
|
|
|
|
// msg.ContentType = constant.SignalingNotification
|
|
|
|
reqData, e := proto.Marshal(s)
|
|
|
|
// reqData, e := proto.Marshal(s)
|
|
|
|
if e != nil {
|
|
|
|
// if e != nil {
|
|
|
|
return false, 201, e.Error(), nil, nil
|
|
|
|
// return false, 201, e.Error(), nil, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
msg.Content = reqData
|
|
|
|
// msg.Content = reqData
|
|
|
|
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
|
|
|
// msg.CreateTime = utils.GetCurrentTimestampByMill()
|
|
|
|
options := make(map[string]bool, 6)
|
|
|
|
// options := make(map[string]bool, 6)
|
|
|
|
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
|
|
|
// utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
|
|
|
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
|
|
|
// utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
|
|
|
utils.SetSwitchFromOptions(options, constant.IsSenderSync, true)
|
|
|
|
// utils.SetSwitchFromOptions(options, constant.IsSenderSync, true)
|
|
|
|
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
|
|
|
// utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
|
|
|
utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
|
|
|
|
// utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
|
|
|
|
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
|
|
|
// utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
|
|
|
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true)
|
|
|
|
// utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true)
|
|
|
|
msg.Options = options
|
|
|
|
// msg.Options = options
|
|
|
|
switch payload := s.Payload.(type) {
|
|
|
|
// switch payload := s.Payload.(type) {
|
|
|
|
case *open_im_sdk.SignalReq_Invite:
|
|
|
|
// case *open_im_sdk.SignalReq_Invite:
|
|
|
|
token, liveURL, err2 := media.GetJoinToken(payload.Invite.Invitation.RoomID, payload.Invite.Invitation.InviterUserID, operationID, payload.Invite.Participant)
|
|
|
|
// token, liveURL, err2 := media.GetJoinToken(payload.Invite.Invitation.RoomID, payload.Invite.Invitation.InviterUserID, operationID, payload.Invite.Participant)
|
|
|
|
if err2 != nil {
|
|
|
|
// if err2 != nil {
|
|
|
|
return false, 202, err2.Error(), nil, nil
|
|
|
|
// return false, 202, err2.Error(), nil, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
invite := open_im_sdk.SignalResp_Invite{&open_im_sdk.SignalInviteReply{
|
|
|
|
// invite := open_im_sdk.SignalResp_Invite{&open_im_sdk.SignalInviteReply{
|
|
|
|
Token: token,
|
|
|
|
// Token: token,
|
|
|
|
RoomID: payload.Invite.Invitation.RoomID,
|
|
|
|
// RoomID: payload.Invite.Invitation.RoomID,
|
|
|
|
LiveURL: liveURL,
|
|
|
|
// LiveURL: liveURL,
|
|
|
|
}}
|
|
|
|
// }}
|
|
|
|
resp.Payload = &invite
|
|
|
|
// resp.Payload = &invite
|
|
|
|
msg.SenderPlatformID = payload.Invite.Invitation.PlatformID
|
|
|
|
// msg.SenderPlatformID = payload.Invite.Invitation.PlatformID
|
|
|
|
msg.SessionType = payload.Invite.Invitation.SessionType
|
|
|
|
// msg.SessionType = payload.Invite.Invitation.SessionType
|
|
|
|
msg.OfflinePushInfo = payload.Invite.OfflinePushInfo
|
|
|
|
// msg.OfflinePushInfo = payload.Invite.OfflinePushInfo
|
|
|
|
msg.SendID = payload.Invite.Invitation.InviterUserID
|
|
|
|
// msg.SendID = payload.Invite.Invitation.InviterUserID
|
|
|
|
if len(payload.Invite.Invitation.InviteeUserIDList) > 0 {
|
|
|
|
// if len(payload.Invite.Invitation.InviteeUserIDList) > 0 {
|
|
|
|
msg.RecvID = payload.Invite.Invitation.InviteeUserIDList[0]
|
|
|
|
// msg.RecvID = payload.Invite.Invitation.InviteeUserIDList[0]
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
return false, 203, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
// return false, 203, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
msg.ClientMsgID = utils.GetMsgID(payload.Invite.Invitation.InviterUserID)
|
|
|
|
// msg.ClientMsgID = utils.GetMsgID(payload.Invite.Invitation.InviterUserID)
|
|
|
|
return true, 0, "", &resp, &msg
|
|
|
|
// return true, 0, "", &resp, &msg
|
|
|
|
case *open_im_sdk.SignalReq_InviteInGroup:
|
|
|
|
// case *open_im_sdk.SignalReq_InviteInGroup:
|
|
|
|
token, liveURL, err2 := media.GetJoinToken(payload.InviteInGroup.Invitation.RoomID, payload.InviteInGroup.Invitation.InviterUserID, operationID, payload.InviteInGroup.Participant)
|
|
|
|
// token, liveURL, err2 := media.GetJoinToken(payload.InviteInGroup.Invitation.RoomID, payload.InviteInGroup.Invitation.InviterUserID, operationID, payload.InviteInGroup.Participant)
|
|
|
|
if err2 != nil {
|
|
|
|
// if err2 != nil {
|
|
|
|
return false, 204, err2.Error(), nil, nil
|
|
|
|
// return false, 204, err2.Error(), nil, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
inviteGroup := open_im_sdk.SignalResp_InviteInGroup{&open_im_sdk.SignalInviteInGroupReply{
|
|
|
|
// inviteGroup := open_im_sdk.SignalResp_InviteInGroup{&open_im_sdk.SignalInviteInGroupReply{
|
|
|
|
RoomID: payload.InviteInGroup.Invitation.RoomID,
|
|
|
|
// RoomID: payload.InviteInGroup.Invitation.RoomID,
|
|
|
|
Token: token,
|
|
|
|
// Token: token,
|
|
|
|
LiveURL: liveURL,
|
|
|
|
// LiveURL: liveURL,
|
|
|
|
}}
|
|
|
|
// }}
|
|
|
|
resp.Payload = &inviteGroup
|
|
|
|
// resp.Payload = &inviteGroup
|
|
|
|
msg.SenderPlatformID = payload.InviteInGroup.Invitation.PlatformID
|
|
|
|
// msg.SenderPlatformID = payload.InviteInGroup.Invitation.PlatformID
|
|
|
|
msg.SessionType = payload.InviteInGroup.Invitation.SessionType
|
|
|
|
// msg.SessionType = payload.InviteInGroup.Invitation.SessionType
|
|
|
|
msg.OfflinePushInfo = payload.InviteInGroup.OfflinePushInfo
|
|
|
|
// msg.OfflinePushInfo = payload.InviteInGroup.OfflinePushInfo
|
|
|
|
msg.SendID = payload.InviteInGroup.Invitation.InviterUserID
|
|
|
|
// msg.SendID = payload.InviteInGroup.Invitation.InviterUserID
|
|
|
|
if len(payload.InviteInGroup.Invitation.InviteeUserIDList) > 0 {
|
|
|
|
// if len(payload.InviteInGroup.Invitation.InviteeUserIDList) > 0 {
|
|
|
|
msg.GroupID = payload.InviteInGroup.Invitation.GroupID
|
|
|
|
// msg.GroupID = payload.InviteInGroup.Invitation.GroupID
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
return false, 205, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
// return false, 205, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
msg.ClientMsgID = utils.GetMsgID(payload.InviteInGroup.Invitation.InviterUserID)
|
|
|
|
// msg.ClientMsgID = utils.GetMsgID(payload.InviteInGroup.Invitation.InviterUserID)
|
|
|
|
|
|
|
|
//
|
|
|
|
return true, 0, "", &resp, &msg
|
|
|
|
// return true, 0, "", &resp, &msg
|
|
|
|
case *open_im_sdk.SignalReq_Cancel:
|
|
|
|
// case *open_im_sdk.SignalReq_Cancel:
|
|
|
|
cancel := open_im_sdk.SignalResp_Cancel{&open_im_sdk.SignalCancelReply{}}
|
|
|
|
// cancel := open_im_sdk.SignalResp_Cancel{&open_im_sdk.SignalCancelReply{}}
|
|
|
|
resp.Payload = &cancel
|
|
|
|
// resp.Payload = &cancel
|
|
|
|
msg.OfflinePushInfo = payload.Cancel.OfflinePushInfo
|
|
|
|
// msg.OfflinePushInfo = payload.Cancel.OfflinePushInfo
|
|
|
|
msg.SendID = payload.Cancel.Invitation.InviterUserID
|
|
|
|
// msg.SendID = payload.Cancel.Invitation.InviterUserID
|
|
|
|
msg.SenderPlatformID = payload.Cancel.Invitation.PlatformID
|
|
|
|
// msg.SenderPlatformID = payload.Cancel.Invitation.PlatformID
|
|
|
|
msg.SessionType = payload.Cancel.Invitation.SessionType
|
|
|
|
// msg.SessionType = payload.Cancel.Invitation.SessionType
|
|
|
|
if len(payload.Cancel.Invitation.InviteeUserIDList) > 0 {
|
|
|
|
// if len(payload.Cancel.Invitation.InviteeUserIDList) > 0 {
|
|
|
|
switch payload.Cancel.Invitation.SessionType {
|
|
|
|
// switch payload.Cancel.Invitation.SessionType {
|
|
|
|
case constant.SingleChatType:
|
|
|
|
// case constant.SingleChatType:
|
|
|
|
msg.RecvID = payload.Cancel.Invitation.InviteeUserIDList[0]
|
|
|
|
// msg.RecvID = payload.Cancel.Invitation.InviteeUserIDList[0]
|
|
|
|
case constant.GroupChatType:
|
|
|
|
// case constant.GroupChatType:
|
|
|
|
msg.GroupID = payload.Cancel.Invitation.GroupID
|
|
|
|
// msg.GroupID = payload.Cancel.Invitation.GroupID
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
return false, 206, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
// return false, 206, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
msg.ClientMsgID = utils.GetMsgID(payload.Cancel.OpUserID)
|
|
|
|
// msg.ClientMsgID = utils.GetMsgID(payload.Cancel.OpUserID)
|
|
|
|
return true, 0, "", &resp, &msg
|
|
|
|
// return true, 0, "", &resp, &msg
|
|
|
|
case *open_im_sdk.SignalReq_Accept:
|
|
|
|
// case *open_im_sdk.SignalReq_Accept:
|
|
|
|
token, liveURL, err2 := media.GetJoinToken(payload.Accept.Invitation.RoomID, payload.Accept.OpUserID, operationID, payload.Accept.Participant)
|
|
|
|
// token, liveURL, err2 := media.GetJoinToken(payload.Accept.Invitation.RoomID, payload.Accept.OpUserID, operationID, payload.Accept.Participant)
|
|
|
|
if err2 != nil {
|
|
|
|
// if err2 != nil {
|
|
|
|
return false, 207, err2.Error(), nil, nil
|
|
|
|
// return false, 207, err2.Error(), nil, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
accept := open_im_sdk.SignalResp_Accept{&open_im_sdk.SignalAcceptReply{
|
|
|
|
// accept := open_im_sdk.SignalResp_Accept{&open_im_sdk.SignalAcceptReply{
|
|
|
|
Token: token,
|
|
|
|
// Token: token,
|
|
|
|
LiveURL: liveURL,
|
|
|
|
// LiveURL: liveURL,
|
|
|
|
RoomID: payload.Accept.Invitation.RoomID,
|
|
|
|
// RoomID: payload.Accept.Invitation.RoomID,
|
|
|
|
}}
|
|
|
|
// }}
|
|
|
|
resp.Payload = &accept
|
|
|
|
// resp.Payload = &accept
|
|
|
|
msg.OfflinePushInfo = payload.Accept.OfflinePushInfo
|
|
|
|
// msg.OfflinePushInfo = payload.Accept.OfflinePushInfo
|
|
|
|
msg.SendID = payload.Accept.OpUserID
|
|
|
|
// msg.SendID = payload.Accept.OpUserID
|
|
|
|
msg.SenderPlatformID = payload.Accept.Invitation.PlatformID
|
|
|
|
// msg.SenderPlatformID = payload.Accept.Invitation.PlatformID
|
|
|
|
msg.SessionType = payload.Accept.Invitation.SessionType
|
|
|
|
// msg.SessionType = payload.Accept.Invitation.SessionType
|
|
|
|
if len(payload.Accept.Invitation.InviteeUserIDList) > 0 {
|
|
|
|
// if len(payload.Accept.Invitation.InviteeUserIDList) > 0 {
|
|
|
|
switch payload.Accept.Invitation.SessionType {
|
|
|
|
// switch payload.Accept.Invitation.SessionType {
|
|
|
|
case constant.SingleChatType:
|
|
|
|
// case constant.SingleChatType:
|
|
|
|
msg.RecvID = payload.Accept.Invitation.InviterUserID
|
|
|
|
// msg.RecvID = payload.Accept.Invitation.InviterUserID
|
|
|
|
case constant.GroupChatType:
|
|
|
|
// case constant.GroupChatType:
|
|
|
|
msg.GroupID = payload.Accept.Invitation.GroupID
|
|
|
|
// msg.GroupID = payload.Accept.Invitation.GroupID
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
return false, 208, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
// return false, 208, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
msg.ClientMsgID = utils.GetMsgID(payload.Accept.OpUserID)
|
|
|
|
// msg.ClientMsgID = utils.GetMsgID(payload.Accept.OpUserID)
|
|
|
|
return true, 0, "", &resp, &msg
|
|
|
|
// return true, 0, "", &resp, &msg
|
|
|
|
case *open_im_sdk.SignalReq_HungUp:
|
|
|
|
// case *open_im_sdk.SignalReq_HungUp:
|
|
|
|
case *open_im_sdk.SignalReq_Reject:
|
|
|
|
// case *open_im_sdk.SignalReq_Reject:
|
|
|
|
reject := open_im_sdk.SignalResp_Reject{&open_im_sdk.SignalRejectReply{}}
|
|
|
|
// reject := open_im_sdk.SignalResp_Reject{&open_im_sdk.SignalRejectReply{}}
|
|
|
|
resp.Payload = &reject
|
|
|
|
// resp.Payload = &reject
|
|
|
|
msg.OfflinePushInfo = payload.Reject.OfflinePushInfo
|
|
|
|
// msg.OfflinePushInfo = payload.Reject.OfflinePushInfo
|
|
|
|
msg.SendID = payload.Reject.OpUserID
|
|
|
|
// msg.SendID = payload.Reject.OpUserID
|
|
|
|
msg.SenderPlatformID = payload.Reject.Invitation.PlatformID
|
|
|
|
// msg.SenderPlatformID = payload.Reject.Invitation.PlatformID
|
|
|
|
msg.SessionType = payload.Reject.Invitation.SessionType
|
|
|
|
// msg.SessionType = payload.Reject.Invitation.SessionType
|
|
|
|
if len(payload.Reject.Invitation.InviteeUserIDList) > 0 {
|
|
|
|
// if len(payload.Reject.Invitation.InviteeUserIDList) > 0 {
|
|
|
|
switch payload.Reject.Invitation.SessionType {
|
|
|
|
// switch payload.Reject.Invitation.SessionType {
|
|
|
|
case constant.SingleChatType:
|
|
|
|
// case constant.SingleChatType:
|
|
|
|
msg.RecvID = payload.Reject.Invitation.InviterUserID
|
|
|
|
// msg.RecvID = payload.Reject.Invitation.InviterUserID
|
|
|
|
case constant.GroupChatType:
|
|
|
|
// case constant.GroupChatType:
|
|
|
|
msg.GroupID = payload.Reject.Invitation.GroupID
|
|
|
|
// msg.GroupID = payload.Reject.Invitation.GroupID
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
return false, 209, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
// return false, 209, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
msg.ClientMsgID = utils.GetMsgID(payload.Reject.OpUserID)
|
|
|
|
// msg.ClientMsgID = utils.GetMsgID(payload.Reject.OpUserID)
|
|
|
|
return true, 0, "", &resp, &msg
|
|
|
|
// return true, 0, "", &resp, &msg
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
return false, 210, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
// return false, 210, errors.New("InviteeUserIDList is null").Error(), nil, nil
|
|
|
|
}
|
|
|
|
//}
|
|
|
|