mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 09:36:00 +08:00
tag
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
)
|
||||
|
||||
func SetTagNotification(operationID, sendID, recvID, content string, contentType int32) {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "args: ", sendID, recvID, content, contentType)
|
||||
var n NotificationMsg
|
||||
n.SendID = sendID
|
||||
n.RecvID = recvID
|
||||
n.ContentType = contentType
|
||||
n.SessionType = constant.SingleChatType
|
||||
n.MsgFrom = constant.UserMsgType
|
||||
n.OperationID = operationID
|
||||
n.Content = []byte(content)
|
||||
Notification(&n)
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func TagSendMessage(operationID, sendID, recvID, content string, contentType int32) {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "args: ", sendID, recvID, content, contentType)
|
||||
var req pbChat.SendMsgReq
|
||||
var msgData pbCommon.MsgData
|
||||
msgData.SendID = sendID
|
||||
msgData.RecvID = recvID
|
||||
msgData.ContentType = contentType
|
||||
msgData.SessionType = constant.SingleChatType
|
||||
msgData.MsgFrom = constant.UserMsgType
|
||||
msgData.Content = []byte(content)
|
||||
msgData.Options = map[string]bool{}
|
||||
msgData.Options[constant.IsSenderConversationUpdate] = false
|
||||
req.MsgData = &msgData
|
||||
req.OperationID = operationID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
respPb, err := client.SendMsg(context.Background(), &req)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "send msg failed", err.Error())
|
||||
return
|
||||
}
|
||||
if respPb.ErrCode != 0 {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "send tag msg failed ", respPb)
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (s *officeServer) GetUserTags(_ context.Context, req *pbOffice.GetUserTagsR
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
return resp, nil
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "tags: ", tags)
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "tags: ", tags)
|
||||
for _, v := range tags {
|
||||
tag := &pbOffice.Tag{
|
||||
TagID: v.TagID,
|
||||
@@ -149,7 +149,7 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
|
||||
resp = &pbOffice.SendMsg2TagResp{CommonResp: &pbOffice.CommonResp{}}
|
||||
userIDList, err := db.DB.GetUserIDListByTagID(req.SendID, req.TagID)
|
||||
for _, userID := range userIDList {
|
||||
msg.SetTagNotification(req.OperationID, req.SendID, userID, req.Content, req.ContentType)
|
||||
msg.TagSendMessage(req.OperationID, req.SendID, userID, req.Content, req.ContentType)
|
||||
}
|
||||
if err := db.DB.SaveTagSendLog(req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", err.Error())
|
||||
@@ -178,10 +178,23 @@ func (s *officeServer) GetTagSendLogs(_ context.Context, req *pbOffice.GetTagSen
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
return resp, nil
|
||||
}
|
||||
if err := utils.CopyStructFields(&resp.TagSendLogs, tagSendLogs); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
for _, v := range tagSendLogs {
|
||||
var userList []*pbOffice.TagUser
|
||||
for _, v2 := range v.TagUserList {
|
||||
userList = append(userList, &pbOffice.TagUser{
|
||||
UserID: v2.UserID,
|
||||
UserName: v2.UserName,
|
||||
})
|
||||
}
|
||||
resp.TagSendLogs = append(resp.TagSendLogs, &pbOffice.TagSendLog{
|
||||
TagID: v.TagID,
|
||||
TagName: v.TagName,
|
||||
ContentType: v.ContentType,
|
||||
Content: v.Content,
|
||||
SendTime: v.SendTime,
|
||||
TagUserList: userList,
|
||||
})
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user