mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 11:06:43 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
commit
e95644ada2
@ -178,6 +178,8 @@ tokenpolicy:
|
|||||||
accessSecret: "open_im_server" #token生成相关,默认即可
|
accessSecret: "open_im_server" #token生成相关,默认即可
|
||||||
# Token effective time day as a unit
|
# Token effective time day as a unit
|
||||||
accessExpire: 3650 #token过期时间(天) 默认即可
|
accessExpire: 3650 #token过期时间(天) 默认即可
|
||||||
|
messageverify:
|
||||||
|
friendVerify: false
|
||||||
|
|
||||||
# c2c:
|
# c2c:
|
||||||
# callbackBeforeSendMsg:
|
# callbackBeforeSendMsg:
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"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"
|
||||||
|
rpc "Open_IM/pkg/proto/friend"
|
||||||
pbGroup "Open_IM/pkg/proto/group"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
@ -41,16 +42,43 @@ type MsgCallBackResp struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func userRelationshipVerification(data *pbChat.SendMsgReq) {
|
func userRelationshipVerification(data *pbChat.SendMsgReq) (bool, int32, string) {
|
||||||
|
if data.MsgData.SessionType == constant.GroupChatType {
|
||||||
//etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
return true, 0, ""
|
||||||
//client := pbChat.NewChatClient(etcdConn)
|
}
|
||||||
//reply, err := client.SendMsg(context.Background(), &req)
|
req := &rpc.IsInBlackListReq{CommID: &rpc.CommID{}}
|
||||||
//if err != nil {
|
req.CommID.OperationID = data.OperationID
|
||||||
// log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), err.Error())
|
req.CommID.OpUserID = data.MsgData.RecvID
|
||||||
//} else if reply.ErrCode != 0 {
|
req.CommID.FromUserID = data.MsgData.RecvID
|
||||||
// log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String())
|
req.CommID.ToUserID = data.MsgData.SendID
|
||||||
//}
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
|
reply, err := client.IsInBlackList(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
log.NewDebug(data.OperationID, "IsInBlackListReq rpc failed, ", req.String(), err.Error())
|
||||||
|
return false, 600, err.Error()
|
||||||
|
} else if reply.Response == false {
|
||||||
|
log.NewDebug(data.OperationID, "IsInBlackListReq ", req.String())
|
||||||
|
return reply.Response, 600, "in black list"
|
||||||
|
}
|
||||||
|
if config.Config.MessageVerify.FriendVerify {
|
||||||
|
friendReq := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
|
||||||
|
friendReq.CommID.OperationID = data.OperationID
|
||||||
|
friendReq.CommID.OpUserID = data.MsgData.RecvID
|
||||||
|
friendReq.CommID.FromUserID = data.MsgData.RecvID
|
||||||
|
friendReq.CommID.ToUserID = data.MsgData.SendID
|
||||||
|
friendReply, err := client.IsFriend(context.Background(), friendReq)
|
||||||
|
if err != nil {
|
||||||
|
log.NewDebug(data.OperationID, "IsFriendReq rpc failed, ", req.String(), err.Error())
|
||||||
|
return false, 601, err.Error()
|
||||||
|
} else if friendReply.Response == false {
|
||||||
|
log.NewDebug(data.OperationID, "not friend ", req.String())
|
||||||
|
return friendReply.Response, 601, "not friend"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true, 0, ""
|
||||||
|
}
|
||||||
|
return true, 0, ""
|
||||||
}
|
}
|
||||||
func (rpc *rpcChat) encapsulateMsgData(msg *sdk_ws.MsgData) {
|
func (rpc *rpcChat) encapsulateMsgData(msg *sdk_ws.MsgData) {
|
||||||
msg.ServerMsgID = GetMsgID(msg.SendID)
|
msg.ServerMsgID = GetMsgID(msg.SendID)
|
||||||
@ -102,7 +130,10 @@ func (rpc *rpcChat) encapsulateMsgData(msg *sdk_ws.MsgData) {
|
|||||||
func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, error) {
|
func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, error) {
|
||||||
replay := pbChat.SendMsgResp{}
|
replay := pbChat.SendMsgResp{}
|
||||||
log.NewDebug(pb.OperationID, "rpc sendMsg come here", pb.String())
|
log.NewDebug(pb.OperationID, "rpc sendMsg come here", pb.String())
|
||||||
userRelationshipVerification(pb)
|
flag, errCode, errMsg := userRelationshipVerification(pb)
|
||||||
|
if !flag {
|
||||||
|
return returnMsg(&replay, pb, errCode, errMsg, "", 0)
|
||||||
|
}
|
||||||
//if !utils.VerifyToken(pb.Token, pb.SendID) {
|
//if !utils.VerifyToken(pb.Token, pb.SendID) {
|
||||||
// return returnMsg(&replay, pb, http.StatusUnauthorized, "token validate err,not authorized", "", 0)
|
// return returnMsg(&replay, pb, http.StatusUnauthorized, "token validate err,not authorized", "", 0)
|
||||||
rpc.encapsulateMsgData(pb.MsgData)
|
rpc.encapsulateMsgData(pb.MsgData)
|
||||||
|
@ -20,8 +20,8 @@ var (
|
|||||||
var Config config
|
var Config config
|
||||||
|
|
||||||
type callBackConfig struct {
|
type callBackConfig struct {
|
||||||
Enable bool `yaml:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
CallbackTimeOut int `yaml:"callbackTimeOut"`
|
CallbackTimeOut int `yaml:"callbackTimeOut"`
|
||||||
CallbackFailedContinue bool `callbackFailedContinue`
|
CallbackFailedContinue bool `callbackFailedContinue`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ type config struct {
|
|||||||
Api struct {
|
Api struct {
|
||||||
GinPort []int `yaml:"openImApiPort"`
|
GinPort []int `yaml:"openImApiPort"`
|
||||||
}
|
}
|
||||||
CmsApi struct{
|
CmsApi struct {
|
||||||
GinPort []int `yaml:"openImCmsApiPort"`
|
GinPort []int `yaml:"openImCmsApiPort"`
|
||||||
}
|
}
|
||||||
Sdk struct {
|
Sdk struct {
|
||||||
@ -173,8 +173,8 @@ type config struct {
|
|||||||
AccessSecret string `yaml:"accessSecret"`
|
AccessSecret string `yaml:"accessSecret"`
|
||||||
AccessExpire int64 `yaml:"accessExpire"`
|
AccessExpire int64 `yaml:"accessExpire"`
|
||||||
}
|
}
|
||||||
MessageJudge struct {
|
MessageVerify struct {
|
||||||
IsJudgeFriend bool `yaml:"isJudgeFriend"`
|
FriendVerify bool `yaml:"friendVerify"`
|
||||||
}
|
}
|
||||||
IOSPush struct {
|
IOSPush struct {
|
||||||
PushSound string `yaml:"pushSound"`
|
PushSound string `yaml:"pushSound"`
|
||||||
@ -182,12 +182,12 @@ type config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Callback struct {
|
Callback struct {
|
||||||
CallbackUrl string `yaml:"callbackUrl"`
|
CallbackUrl string `yaml:"callbackUrl"`
|
||||||
CallbackBeforeSendSingleMsg callBackConfig `yaml:"callbackbeforeSendSingleMsg"`
|
CallbackBeforeSendSingleMsg callBackConfig `yaml:"callbackbeforeSendSingleMsg"`
|
||||||
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"`
|
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"`
|
||||||
CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"`
|
CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"`
|
||||||
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
|
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
|
||||||
CallbackWordFilter callBackConfig `yaml:"callbackWordFilter"`
|
CallbackWordFilter callBackConfig `yaml:"callbackWordFilter"`
|
||||||
} `yaml:"callback"`
|
} `yaml:"callback"`
|
||||||
Notification struct {
|
Notification struct {
|
||||||
///////////////////////group/////////////////////////////
|
///////////////////////group/////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user