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

This commit is contained in:
Gordon
2022-02-15 14:32:40 +08:00
12 changed files with 188 additions and 37 deletions
+1 -1
View File
@@ -324,7 +324,7 @@ func GetUserReqGroupApplicationList(c *gin.Context) {
}
req := &rpc.GetUserReqApplicationListReq{}
utils.CopyStructFields(req, params)
//ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
//ok, req.OpUserID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
//if !ok {
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
+1 -2
View File
@@ -155,7 +155,7 @@ func AddUser(c *gin.Context) {
reqPb pb.AddUserReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
@@ -183,7 +183,6 @@ func BlockUser(c *gin.Context) {
return
}
utils.CopyStructFields(&reqPb, &req)
fmt.Println(reqPb, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
fmt.Println(reqPb)
@@ -0,0 +1,54 @@
package msg
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
func conversationNotification(contentType int32, m proto.Message, operationID, userID string) {
var err error
var tips open_im_sdk.TipsComm
tips.Detail, err = proto.Marshal(m)
if err != nil {
log.Error(operationID, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), m.String())
return
}
marshaler := jsonpb.Marshaler{
OrigName: true,
EnumsAsInts: false,
EmitDefaults: false,
}
tips.JsonDetail, _ = marshaler.MarshalToString(m)
cn := config.Config.Notification
switch contentType {
case constant.ConversationOptChangeNotification:
tips.DefaultTips = cn.ConversationOptUpdate.DefaultTips.Tips
}
var n NotificationMsg
n.SendID = userID
n.RecvID = userID
n.ContentType = contentType
n.SessionType = constant.SingleChatType
n.MsgFrom = constant.SysMsgType
n.OperationID = operationID
n.Content, err = proto.Marshal(&tips)
if err != nil {
log.Error(operationID, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), tips.String())
return
}
Notification(&n)
}
// 客户端调用设置opt接口后调用
func SetReceiveMessageOptNotification(operationID, opUserID, userID string) {
log.NewInfo(operationID, utils.GetSelfFuncName(), "operation user: ", opUserID, "operation id: ", userID)
conversationUpdateTips := open_im_sdk.ConversationUpdateTips{
UserID: userID,
}
conversationNotification(constant.ConversationOptChangeNotification, &conversationUpdateTips, operationID, userID)
}
+8 -1
View File
@@ -139,6 +139,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
isSend := modifyMessageByUserMessageReceiveOpt(pb.MsgData.RecvID, pb.MsgData.SendID, constant.SingleChatType, pb)
if isSend {
msgToMQ.MsgData = pb.MsgData
log.NewInfo(msgToMQ.OperationID, msgToMQ)
err1 := rpc.sendMsgToKafka(&msgToMQ, msgToMQ.MsgData.RecvID)
if err1 != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:RecvID", msgToMQ.MsgData.RecvID, msgToMQ.String())
@@ -437,7 +438,13 @@ func Notification(n *NotificationMsg) {
ex = config.Config.Notification.BlackDeleted.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.BlackDeleted.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.BlackDeleted.Conversation.UnreadCount
case constant.ConversationOptChangeNotification:
pushSwitch = config.Config.Notification.ConversationOptUpdate.OfflinePush.PushSwitch
title = config.Config.Notification.ConversationOptUpdate.OfflinePush.Title
desc = config.Config.Notification.ConversationOptUpdate.OfflinePush.Desc
ex = config.Config.Notification.ConversationOptUpdate.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.ConversationOptUpdate.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.ConversationOptUpdate.Conversation.UnreadCount
}
switch reliabilityLevel {
case constant.UnreliableNotification:
+1
View File
@@ -111,6 +111,7 @@ func (s *userServer) SetReceiveMessageOpt(ctx context.Context, req *pbUser.SetRe
for _, v := range req.ConversationIDList {
resp.ConversationOptResultList = append(resp.ConversationOptResultList, &pbUser.OptResult{ConversationID: v, Result: req.Opt})
}
chat.SetReceiveMessageOptNotification(req.OperationID, req.OpUserID, req.FromUserID)
log.NewInfo(req.OperationID, "SetReceiveMessageOpt rpc return ", resp.String())
return &resp, nil
}