delete notification

This commit is contained in:
wangchuxiao 2023-05-29 20:18:47 +08:00
parent 32d9eb83d1
commit 02a1d10a8b
3 changed files with 48 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package msg
import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
@ -27,6 +28,7 @@ func (m *msgServer) ClearConversationsMsg(ctx context.Context, req *msg.ClearCon
if err := m.MsgDatabase.SetUserConversationsMinSeqs(ctx, req.UserID, m.getMinSeqs(maxSeqs)); err != nil {
return nil, err
}
m.conversationClearSync(ctx, req.DeleteSyncOpt, req.UserID, req.ConversationIDs)
return &msg.ClearConversationsMsgResp{}, nil
}
@ -46,6 +48,7 @@ func (m *msgServer) UserClearAllMsg(ctx context.Context, req *msg.UserClearAllMs
if err := m.MsgDatabase.SetUserConversationsMinSeqs(ctx, req.UserID, m.getMinSeqs(maxSeqs)); err != nil {
return nil, err
}
m.conversationClearSync(ctx, req.DeleteSyncOpt, req.UserID, conversationIDs)
return &msg.UserClearAllMsgResp{}, nil
}
@ -56,6 +59,7 @@ func (m *msgServer) DeleteMsgs(ctx context.Context, req *msg.DeleteMsgsReq) (*ms
if err := m.MsgDatabase.DeleteUserMsgsBySeqs(ctx, req.UserID, req.ConversationID, req.Seqs); err != nil {
return nil, err
}
m.DeleteMsgsNotification(ctx, req.ConversationID, req.UserID, req.Seqs, req.DeleteSyncOpt)
return &msg.DeleteMsgsResp{}, nil
}
@ -78,3 +82,31 @@ func (m *msgServer) DeleteMsgPhysical(ctx context.Context, req *msg.DeleteMsgPhy
}
return &msg.DeleteMsgPhysicalResp{}, nil
}
func (m *msgServer) conversationClearSync(ctx context.Context, opt *msg.DeleteSyncOpt, userID string, conversationIDs []string) {
if opt == nil {
return
}
for _, conversationID := range conversationIDs {
conversation, err := m.Conversation.GetConversation(ctx, userID, conversationID)
if err != nil {
log.ZWarn(ctx, "GetConversation error", err, "conversationID", conversationID, "userID", userID)
continue
}
if conversation.ConversationType == constant.SingleChatType || conversation.ConversationType == constant.NotificationChatType {
} else if conversation.ConversationType == constant.SuperGroupChatType {
}
}
if opt.IsSyncSelf {
} else if opt.IsSyncOther {
}
}
func (m *msgServer) DeleteMsgsNotification(ctx context.Context, conversationID, userID string, seqs []int64, opt *msg.DeleteSyncOpt) error {
return nil
}

View File

@ -76,3 +76,12 @@ func (c *ConversationClient) GetConversationIDs(ctx context.Context, ownerUserID
resp, err := conversation.NewConversationClient(cc).GetConversationIDs(ctx, &pbConversation.GetConversationIDsReq{UserID: ownerUserID})
return resp.ConversationIDs, err
}
func (c *ConversationClient) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*pbConversation.Conversation, error) {
cc, err := c.getConn(ctx)
if err != nil {
return nil, err
}
resp, err := conversation.NewConversationClient(cc).GetConversation(ctx, &pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID})
return resp.Conversation, err
}

View File

@ -52,6 +52,8 @@ func newContentTypeConf() map[int32]config.NotificationConf {
constant.ConversationChangeNotification: config.Config.Notification.ConversationChanged,
constant.ConversationUnreadNotification: config.Config.Notification.ConversationChanged,
constant.ConversationPrivateChatNotification: config.Config.Notification.ConversationSetPrivate,
// msg
constant.MsgRevokeNotification: {IsSendMsg: false, ReliabilityLevel: constant.ReliableNotificationNoMsg},
}
}
@ -158,7 +160,7 @@ func NewNotificationSender(opts ...NewNotificationSenderOptions) *NotificationSe
return notificationSender
}
func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message, opts ...utils.OptionsOpt) error {
func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string, contentType, sesstionType int32, m proto.Message, opts ...utils.OptionsOpt) (err error) {
n := sdkws.NotificationElem{Detail: utils.StructToJsonString(m)}
content, err := json.Marshal(&n)
if err != nil {
@ -196,3 +198,7 @@ func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID st
}
return err
}
func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message, opts ...utils.OptionsOpt) error {
return s.NotificationWithSesstionType(ctx, sendID, recvID, contentType, s.sessionTypeConf[contentType], m, opts...)
}