mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-03 00:25:59 +08:00
delete
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||
@@ -82,6 +81,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tips := sdkws.RevokeMsgTips{
|
||||
RevokerUserID: req.UserID,
|
||||
ClientMsgID: "",
|
||||
@@ -90,36 +90,13 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
|
||||
SesstionType: msgs[0].SessionType,
|
||||
ConversationID: req.ConversationID,
|
||||
}
|
||||
detail, err := json.Marshal(&tips)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var recvID string
|
||||
if msgs[0].SessionType == constant.SuperGroupChatType {
|
||||
recvID = msgs[0].GroupID
|
||||
} else {
|
||||
recvID = msgs[0].RecvID
|
||||
}
|
||||
notificationElem := sdkws.NotificationElem{Detail: string(detail)}
|
||||
content, err := json.Marshal(¬ificationElem)
|
||||
if err != nil {
|
||||
return nil, errs.Wrap(err)
|
||||
}
|
||||
msgData := sdkws.MsgData{
|
||||
SendID: req.UserID,
|
||||
RecvID: msgs[0].RecvID,
|
||||
GroupID: msgs[0].GroupID,
|
||||
Content: content,
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: constant.MsgRevokeNotification,
|
||||
SessionType: msgs[0].SessionType,
|
||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||
ClientMsgID: utils.GetMsgID(req.UserID),
|
||||
Options: config.GetOptionsByNotification(config.NotificationConf{
|
||||
IsSendMsg: false,
|
||||
ReliabilityLevel: 2,
|
||||
}),
|
||||
OfflinePushInfo: nil,
|
||||
}
|
||||
if msgData.SessionType == constant.SuperGroupChatType {
|
||||
msgData.GroupID = msgData.RecvID
|
||||
}
|
||||
_, err = m.SendMsg(ctx, &msg.SendMsgReq{MsgData: &msgData})
|
||||
if err != nil {
|
||||
if err := m.notificationSender.Notification(ctx, req.UserID, recvID, constant.MsgRevokeNotification, &tips, utils.WithSendMsg(false), utils.WithHistory(true), utils.WithPersistent()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &msg.RevokeMsgResp{}, nil
|
||||
|
||||
@@ -2,18 +2,14 @@ package msg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||
promePkg "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (m *msgServer) SendMsg(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, error error) {
|
||||
@@ -108,42 +104,3 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbMsg.SendMsgReq
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *msgServer) notification(ctx context.Context, sendID, recvID string, contentType, sessionType int32, msgPb proto.Message, cfg config.NotificationConf, opts ...utils.OptionsOpt) error {
|
||||
n := sdkws.NotificationElem{Detail: utils.StructToJsonString(m)}
|
||||
content, err := json.Marshal(&n)
|
||||
if err != nil {
|
||||
log.ZError(ctx, "MsgClient Notification json.Marshal failed", err, "sendID", sendID, "recvID", recvID, "contentType", contentType, "msg", m)
|
||||
return err
|
||||
}
|
||||
var req msg.SendMsgReq
|
||||
var msg sdkws.MsgData
|
||||
var offlineInfo sdkws.OfflinePushInfo
|
||||
var title, desc, ex string
|
||||
msg.SendID = sendID
|
||||
msg.RecvID = recvID
|
||||
msg.Content = content
|
||||
msg.MsgFrom = constant.SysMsgType
|
||||
msg.ContentType = contentType
|
||||
msg.SessionType = sessionType
|
||||
if msg.SessionType == constant.SuperGroupChatType {
|
||||
msg.GroupID = recvID
|
||||
}
|
||||
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
||||
msg.ClientMsgID = utils.GetMsgID(sendID)
|
||||
options := config.GetOptionsByNotification(cfg)
|
||||
options = utils.WithOptions(options, opts...)
|
||||
msg.Options = options
|
||||
offlineInfo.Title = title
|
||||
offlineInfo.Desc = desc
|
||||
offlineInfo.Ex = ex
|
||||
msg.OfflinePushInfo = &offlineInfo
|
||||
req.MsgData = &msg
|
||||
_, err = m.SendMsg(ctx, &req)
|
||||
if err == nil {
|
||||
log.ZDebug(ctx, "MsgClient Notification SendMsg success", "req", &req)
|
||||
} else {
|
||||
log.ZError(ctx, "MsgClient Notification SendMsg failed", err, "req", &req)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ type msgServer struct {
|
||||
ConversationLocalCache *localcache.ConversationLocalCache
|
||||
MessageLocker MessageLocker
|
||||
Handlers MessageInterceptorChain
|
||||
notificationSender *rpcclient.NotificationSender
|
||||
}
|
||||
|
||||
func (m *msgServer) addInterceptorHandler(interceptorFunc ...MessageInterceptorFunc) {
|
||||
@@ -64,7 +65,6 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
extendMsgCacheModel := cache.NewExtendMsgSetCacheRedis(rdb, extendMsgModel, cache.GetDefaultOpt())
|
||||
extendMsgDatabase := controller.NewExtendMsgDatabase(extendMsgModel, extendMsgCacheModel, tx.NewMongo(mongo.GetClient()))
|
||||
msgDatabase := controller.NewCommonMsgDatabase(msgDocModel, cacheModel)
|
||||
|
||||
s := &msgServer{
|
||||
Conversation: rpcclient.NewConversationClient(client),
|
||||
User: rpcclient.NewUserClient(client),
|
||||
@@ -78,6 +78,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
friend: rpcclient.NewFriendClient(client),
|
||||
MessageLocker: NewLockerMessage(cacheModel),
|
||||
}
|
||||
s.notificationSender = rpcclient.NewNotificationSender(rpcclient.WithLocalSendMsg(s.SendMsg))
|
||||
s.addInterceptorHandler(MessageHasReadEnabled, MessageModifyCallback)
|
||||
s.initPrometheus()
|
||||
msg.RegisterMsgServer(server, s)
|
||||
|
||||
Reference in New Issue
Block a user