conversation

This commit is contained in:
wangchuxiao
2023-04-26 14:10:12 +08:00
parent 0dc16d54a5
commit 16231ee077
8 changed files with 261 additions and 65 deletions
+4 -20
View File
@@ -2,13 +2,12 @@ package notification
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/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/golang/protobuf/proto"
)
type ConversationNotificationSender struct {
@@ -19,21 +18,6 @@ func NewConversationNotificationSender(client discoveryregistry.SvcDiscoveryRegi
return &ConversationNotificationSender{rpcclient.NewMsgClient(client)}
}
func (c *ConversationNotificationSender) SetConversationNotification(ctx context.Context, sendID, recvID string, contentType int, m proto.Message) {
var err error
var n rpcclient.NotificationMsg
n.SendID = sendID
n.RecvID = recvID
n.ContentType = int32(contentType)
n.SessionType = constant.SingleChatType
n.MsgFrom = constant.SysMsgType
n.Content, err = json.Marshal(m)
if err != nil {
return
}
c.Notification(ctx, &n)
}
// SetPrivate调用
func (c *ConversationNotificationSender) ConversationSetPrivateNotification(ctx context.Context, sendID, recvID string, isPrivateChat bool) {
tips := &sdkws.ConversationSetPrivateTips{
@@ -41,7 +25,7 @@ func (c *ConversationNotificationSender) ConversationSetPrivateNotification(ctx
SendID: sendID,
IsPrivate: isPrivateChat,
}
c.SetConversationNotification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, tips)
c.Notification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, constant.SingleChatType, tips, config.Config.Notification.ConversationSetPrivate)
}
// 会话改变
@@ -49,7 +33,7 @@ func (c *ConversationNotificationSender) ConversationChangeNotification(ctx cont
tips := &sdkws.ConversationUpdateTips{
UserID: userID,
}
c.SetConversationNotification(ctx, userID, userID, constant.ConversationOptChangeNotification, tips)
c.Notification(ctx, userID, userID, constant.ConversationChangeNotification, constant.SingleChatType, tips, config.Config.Notification.ConversationChanged)
}
// 会话未读数同步
@@ -59,5 +43,5 @@ func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(ct
ConversationIDList: []string{conversationID},
UpdateUnreadCountTime: updateUnreadCountTime,
}
c.SetConversationNotification(ctx, userID, userID, constant.ConversationUnreadNotification, tips)
c.Notification(ctx, userID, userID, constant.ConversationUnreadNotification, constant.SingleChatType, tips, config.Config.Notification.ConversationChanged)
}