mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-13 21:45:58 +08:00
refactor: 3.7.0 code conventions. (#2148)
* Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * feat: add code lint * feat: add code lint * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * feat: code format * Script Refactoring * Script Refactoring * Script Refactoring * Adjust MinIO configuration settings * Adjust configuration settings * Adjust configuration settings * refactor: config change. * refactor: webhooks update. * Adjust configuration settings * refactor: webhooks update. * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * feat: s3 api addr * refactor: webhooks update. * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * refactor: webhooks update. * refactor: kafka update. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * refactor: kafka update. * refactor: kafka update. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * Windows can compile and run. * Windows can compile and run. * refactor: kafka update. * feat: msg cache split * refactor: webhooks update * refactor: webhooks update * refactor: friends update * refactor: group update * refactor: third update * refactor: api update * refactor: crontab update * refactor: msggateway update * mage * mage * refactor: all module update. * check * refactor: all module update. * load config * load config * load config * load config * refactor: all module update. * refactor: all module update. * refactor: all module update. * refactor: all module update. * refactor: all module update. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * refactor: all module update. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * update tools * update tools * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * update protocol * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: api remove token auth by redis directly. * Code Refactoring * refactor: websocket auth change to call rpc of auth. * refactor: kick online user and remove token change to call auth rpc. * refactor: kick online user and remove token change to call auth rpc. * refactor: remove msggateway redis. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor webhook * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor webhook * refactor: cmd update. * refactor: cmd update. * fix: runtime: goroutine stack exceeds * refactor: cmd update. * refactor notification * refactor notification * refactor * refactor: cmd update. * refactor: cmd update. * refactor * refactor * refactor * protojson * protojson * protojson * go mod * wrapperspb * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: context update. * refactor: websocket update info. * refactor: websocket update info. * refactor: websocket update info. * refactor: websocket update info. * refactor: api name change. * refactor: debug info. * refactor: debug info. * refactor: debug info. * fix: update file * refactor * refactor * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * fix: callback update. * fix: callback update. * refactor * fix: update message. * fix: msg cache timeout. * refactor * refactor * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: websocket handle error remove when upgrade error. --------- Co-authored-by: skiffer-git <44203734@qq.com> Co-authored-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> Co-authored-by: withchao <993506633@qq.com>
This commit is contained in:
+113
-97
@@ -17,62 +17,64 @@ package rpcclient
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
"github.com/OpenIMSDK/protocol/msg"
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
||||
"github.com/openimsdk/protocol/constant"
|
||||
"github.com/openimsdk/protocol/msg"
|
||||
"github.com/openimsdk/protocol/sdkws"
|
||||
"github.com/openimsdk/tools/discovery"
|
||||
"github.com/openimsdk/tools/log"
|
||||
"github.com/openimsdk/tools/mcontext"
|
||||
"github.com/openimsdk/tools/mq/memamq"
|
||||
"github.com/openimsdk/tools/system/program"
|
||||
"github.com/openimsdk/tools/utils/idutil"
|
||||
"github.com/openimsdk/tools/utils/jsonutil"
|
||||
"github.com/openimsdk/tools/utils/timeutil"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"time"
|
||||
)
|
||||
|
||||
func newContentTypeConf(conf *config.GlobalConfig) map[int32]config.NotificationConf {
|
||||
return map[int32]config.NotificationConf{
|
||||
func newContentTypeConf(conf *config.Notification) map[int32]config.NotificationConfig {
|
||||
return map[int32]config.NotificationConfig{
|
||||
// group
|
||||
constant.GroupCreatedNotification: conf.Notification.GroupCreated,
|
||||
constant.GroupInfoSetNotification: conf.Notification.GroupInfoSet,
|
||||
constant.JoinGroupApplicationNotification: conf.Notification.JoinGroupApplication,
|
||||
constant.MemberQuitNotification: conf.Notification.MemberQuit,
|
||||
constant.GroupApplicationAcceptedNotification: conf.Notification.GroupApplicationAccepted,
|
||||
constant.GroupApplicationRejectedNotification: conf.Notification.GroupApplicationRejected,
|
||||
constant.GroupOwnerTransferredNotification: conf.Notification.GroupOwnerTransferred,
|
||||
constant.MemberKickedNotification: conf.Notification.MemberKicked,
|
||||
constant.MemberInvitedNotification: conf.Notification.MemberInvited,
|
||||
constant.MemberEnterNotification: conf.Notification.MemberEnter,
|
||||
constant.GroupDismissedNotification: conf.Notification.GroupDismissed,
|
||||
constant.GroupMutedNotification: conf.Notification.GroupMuted,
|
||||
constant.GroupCancelMutedNotification: conf.Notification.GroupCancelMuted,
|
||||
constant.GroupMemberMutedNotification: conf.Notification.GroupMemberMuted,
|
||||
constant.GroupMemberCancelMutedNotification: conf.Notification.GroupMemberCancelMuted,
|
||||
constant.GroupMemberInfoSetNotification: conf.Notification.GroupMemberInfoSet,
|
||||
constant.GroupMemberSetToAdminNotification: conf.Notification.GroupMemberSetToAdmin,
|
||||
constant.GroupMemberSetToOrdinaryUserNotification: conf.Notification.GroupMemberSetToOrdinary,
|
||||
constant.GroupInfoSetAnnouncementNotification: conf.Notification.GroupInfoSetAnnouncement,
|
||||
constant.GroupInfoSetNameNotification: conf.Notification.GroupInfoSetName,
|
||||
constant.GroupCreatedNotification: conf.GroupCreated,
|
||||
constant.GroupInfoSetNotification: conf.GroupInfoSet,
|
||||
constant.JoinGroupApplicationNotification: conf.JoinGroupApplication,
|
||||
constant.MemberQuitNotification: conf.MemberQuit,
|
||||
constant.GroupApplicationAcceptedNotification: conf.GroupApplicationAccepted,
|
||||
constant.GroupApplicationRejectedNotification: conf.GroupApplicationRejected,
|
||||
constant.GroupOwnerTransferredNotification: conf.GroupOwnerTransferred,
|
||||
constant.MemberKickedNotification: conf.MemberKicked,
|
||||
constant.MemberInvitedNotification: conf.MemberInvited,
|
||||
constant.MemberEnterNotification: conf.MemberEnter,
|
||||
constant.GroupDismissedNotification: conf.GroupDismissed,
|
||||
constant.GroupMutedNotification: conf.GroupMuted,
|
||||
constant.GroupCancelMutedNotification: conf.GroupCancelMuted,
|
||||
constant.GroupMemberMutedNotification: conf.GroupMemberMuted,
|
||||
constant.GroupMemberCancelMutedNotification: conf.GroupMemberCancelMuted,
|
||||
constant.GroupMemberInfoSetNotification: conf.GroupMemberInfoSet,
|
||||
constant.GroupMemberSetToAdminNotification: conf.GroupMemberSetToAdmin,
|
||||
constant.GroupMemberSetToOrdinaryUserNotification: conf.GroupMemberSetToOrdinary,
|
||||
constant.GroupInfoSetAnnouncementNotification: conf.GroupInfoSetAnnouncement,
|
||||
constant.GroupInfoSetNameNotification: conf.GroupInfoSetName,
|
||||
// user
|
||||
constant.UserInfoUpdatedNotification: conf.Notification.UserInfoUpdated,
|
||||
constant.UserStatusChangeNotification: conf.Notification.UserStatusChanged,
|
||||
constant.UserInfoUpdatedNotification: conf.UserInfoUpdated,
|
||||
constant.UserStatusChangeNotification: conf.UserStatusChanged,
|
||||
// friend
|
||||
constant.FriendApplicationNotification: conf.Notification.FriendApplicationAdded,
|
||||
constant.FriendApplicationApprovedNotification: conf.Notification.FriendApplicationApproved,
|
||||
constant.FriendApplicationRejectedNotification: conf.Notification.FriendApplicationRejected,
|
||||
constant.FriendAddedNotification: conf.Notification.FriendAdded,
|
||||
constant.FriendDeletedNotification: conf.Notification.FriendDeleted,
|
||||
constant.FriendRemarkSetNotification: conf.Notification.FriendRemarkSet,
|
||||
constant.BlackAddedNotification: conf.Notification.BlackAdded,
|
||||
constant.BlackDeletedNotification: conf.Notification.BlackDeleted,
|
||||
constant.FriendInfoUpdatedNotification: conf.Notification.FriendInfoUpdated,
|
||||
constant.FriendsInfoUpdateNotification: conf.Notification.FriendInfoUpdated, //use the same FriendInfoUpdated
|
||||
constant.FriendApplicationNotification: conf.FriendApplicationAdded,
|
||||
constant.FriendApplicationApprovedNotification: conf.FriendApplicationApproved,
|
||||
constant.FriendApplicationRejectedNotification: conf.FriendApplicationRejected,
|
||||
constant.FriendAddedNotification: conf.FriendAdded,
|
||||
constant.FriendDeletedNotification: conf.FriendDeleted,
|
||||
constant.FriendRemarkSetNotification: conf.FriendRemarkSet,
|
||||
constant.BlackAddedNotification: conf.BlackAdded,
|
||||
constant.BlackDeletedNotification: conf.BlackDeleted,
|
||||
constant.FriendInfoUpdatedNotification: conf.FriendInfoUpdated,
|
||||
constant.FriendsInfoUpdateNotification: conf.FriendInfoUpdated, // use the same FriendInfoUpdated
|
||||
// conversation
|
||||
constant.ConversationChangeNotification: conf.Notification.ConversationChanged,
|
||||
constant.ConversationUnreadNotification: conf.Notification.ConversationChanged,
|
||||
constant.ConversationPrivateChatNotification: conf.Notification.ConversationSetPrivate,
|
||||
constant.ConversationChangeNotification: conf.ConversationChanged,
|
||||
constant.ConversationUnreadNotification: conf.ConversationChanged,
|
||||
constant.ConversationPrivateChatNotification: conf.ConversationSetPrivate,
|
||||
// msg
|
||||
constant.MsgRevokeNotification: {IsSendMsg: false, ReliabilityLevel: constant.ReliableNotificationNoMsg},
|
||||
constant.HasReadReceipt: {IsSendMsg: false, ReliabilityLevel: constant.ReliableNotificationNoMsg},
|
||||
@@ -83,26 +85,26 @@ func newContentTypeConf(conf *config.GlobalConfig) map[int32]config.Notification
|
||||
func newSessionTypeConf() map[int32]int32 {
|
||||
return map[int32]int32{
|
||||
// group
|
||||
constant.GroupCreatedNotification: constant.SuperGroupChatType,
|
||||
constant.GroupInfoSetNotification: constant.SuperGroupChatType,
|
||||
constant.GroupCreatedNotification: constant.ReadGroupChatType,
|
||||
constant.GroupInfoSetNotification: constant.ReadGroupChatType,
|
||||
constant.JoinGroupApplicationNotification: constant.SingleChatType,
|
||||
constant.MemberQuitNotification: constant.SuperGroupChatType,
|
||||
constant.MemberQuitNotification: constant.ReadGroupChatType,
|
||||
constant.GroupApplicationAcceptedNotification: constant.SingleChatType,
|
||||
constant.GroupApplicationRejectedNotification: constant.SingleChatType,
|
||||
constant.GroupOwnerTransferredNotification: constant.SuperGroupChatType,
|
||||
constant.MemberKickedNotification: constant.SuperGroupChatType,
|
||||
constant.MemberInvitedNotification: constant.SuperGroupChatType,
|
||||
constant.MemberEnterNotification: constant.SuperGroupChatType,
|
||||
constant.GroupDismissedNotification: constant.SuperGroupChatType,
|
||||
constant.GroupMutedNotification: constant.SuperGroupChatType,
|
||||
constant.GroupCancelMutedNotification: constant.SuperGroupChatType,
|
||||
constant.GroupMemberMutedNotification: constant.SuperGroupChatType,
|
||||
constant.GroupMemberCancelMutedNotification: constant.SuperGroupChatType,
|
||||
constant.GroupMemberInfoSetNotification: constant.SuperGroupChatType,
|
||||
constant.GroupMemberSetToAdminNotification: constant.SuperGroupChatType,
|
||||
constant.GroupMemberSetToOrdinaryUserNotification: constant.SuperGroupChatType,
|
||||
constant.GroupInfoSetAnnouncementNotification: constant.SuperGroupChatType,
|
||||
constant.GroupInfoSetNameNotification: constant.SuperGroupChatType,
|
||||
constant.GroupOwnerTransferredNotification: constant.ReadGroupChatType,
|
||||
constant.MemberKickedNotification: constant.ReadGroupChatType,
|
||||
constant.MemberInvitedNotification: constant.ReadGroupChatType,
|
||||
constant.MemberEnterNotification: constant.ReadGroupChatType,
|
||||
constant.GroupDismissedNotification: constant.ReadGroupChatType,
|
||||
constant.GroupMutedNotification: constant.ReadGroupChatType,
|
||||
constant.GroupCancelMutedNotification: constant.ReadGroupChatType,
|
||||
constant.GroupMemberMutedNotification: constant.ReadGroupChatType,
|
||||
constant.GroupMemberCancelMutedNotification: constant.ReadGroupChatType,
|
||||
constant.GroupMemberInfoSetNotification: constant.ReadGroupChatType,
|
||||
constant.GroupMemberSetToAdminNotification: constant.ReadGroupChatType,
|
||||
constant.GroupMemberSetToOrdinaryUserNotification: constant.ReadGroupChatType,
|
||||
constant.GroupInfoSetAnnouncementNotification: constant.ReadGroupChatType,
|
||||
constant.GroupInfoSetNameNotification: constant.ReadGroupChatType,
|
||||
// user
|
||||
constant.UserInfoUpdatedNotification: constant.SingleChatType,
|
||||
constant.UserStatusChangeNotification: constant.SingleChatType,
|
||||
@@ -129,23 +131,22 @@ func newSessionTypeConf() map[int32]int32 {
|
||||
type Message struct {
|
||||
conn grpc.ClientConnInterface
|
||||
Client msg.MsgClient
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
Config *config.GlobalConfig
|
||||
discov discovery.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func NewMessage(discov discoveryregistry.SvcDiscoveryRegistry, config *config.GlobalConfig) *Message {
|
||||
conn, err := discov.GetConn(context.Background(), config.RpcRegisterName.OpenImMsgName)
|
||||
func NewMessage(discov discovery.SvcDiscoveryRegistry, rpcRegisterName string) *Message {
|
||||
conn, err := discov.GetConn(context.Background(), rpcRegisterName)
|
||||
if err != nil {
|
||||
util.ExitWithError(err)
|
||||
program.ExitWithError(err)
|
||||
}
|
||||
client := msg.NewMsgClient(conn)
|
||||
return &Message{discov: discov, conn: conn, Client: client, Config: config}
|
||||
return &Message{discov: discov, conn: conn, Client: client}
|
||||
}
|
||||
|
||||
type MessageRpcClient Message
|
||||
|
||||
func NewMessageRpcClient(discov discoveryregistry.SvcDiscoveryRegistry, config *config.GlobalConfig) MessageRpcClient {
|
||||
return MessageRpcClient(*NewMessage(discov, config))
|
||||
func NewMessageRpcClient(discov discovery.SvcDiscoveryRegistry, rpcRegisterName string) MessageRpcClient {
|
||||
return MessageRpcClient(*NewMessage(discov, rpcRegisterName))
|
||||
}
|
||||
|
||||
// SendMsg sends a message through the gRPC client and returns the response.
|
||||
@@ -212,10 +213,17 @@ func (m *MessageRpcClient) GetConversationMaxSeq(ctx context.Context, conversati
|
||||
}
|
||||
|
||||
type NotificationSender struct {
|
||||
contentTypeConf map[int32]config.NotificationConf
|
||||
contentTypeConf map[int32]config.NotificationConfig
|
||||
sessionTypeConf map[int32]int32
|
||||
sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error)
|
||||
getUserInfo func(ctx context.Context, userID string) (*sdkws.UserInfo, error)
|
||||
queue *memamq.MemoryQueue
|
||||
}
|
||||
|
||||
func WithQueue(queue *memamq.MemoryQueue) NotificationSenderOptions {
|
||||
return func(s *NotificationSender) {
|
||||
s.queue = queue
|
||||
}
|
||||
}
|
||||
|
||||
type NotificationSenderOptions func(*NotificationSender)
|
||||
@@ -238,11 +246,19 @@ func WithUserRpcClient(userRpcClient *UserRpcClient) NotificationSenderOptions {
|
||||
}
|
||||
}
|
||||
|
||||
func NewNotificationSender(config *config.GlobalConfig, opts ...NotificationSenderOptions) *NotificationSender {
|
||||
notificationSender := &NotificationSender{contentTypeConf: newContentTypeConf(config), sessionTypeConf: newSessionTypeConf()}
|
||||
const (
|
||||
notificationWorkerCount = 2
|
||||
notificationBufferSize = 200
|
||||
)
|
||||
|
||||
func NewNotificationSender(conf *config.Notification, opts ...NotificationSenderOptions) *NotificationSender {
|
||||
notificationSender := &NotificationSender{contentTypeConf: newContentTypeConf(conf), sessionTypeConf: newSessionTypeConf()}
|
||||
for _, opt := range opts {
|
||||
opt(notificationSender)
|
||||
}
|
||||
if notificationSender.queue == nil {
|
||||
notificationSender.queue = memamq.NewMemoryQueue(notificationWorkerCount, notificationBufferSize)
|
||||
}
|
||||
return notificationSender
|
||||
}
|
||||
|
||||
@@ -258,12 +274,15 @@ func WithRpcGetUserName() NotificationOptions {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string, contentType, sesstionType int32, m proto.Message, opts ...NotificationOptions) (err error) {
|
||||
n := sdkws.NotificationElem{Detail: utils.StructToJsonString(m)}
|
||||
func (s *NotificationSender) send(ctx context.Context, sendID, recvID string, contentType, sessionType int32, m proto.Message, opts ...NotificationOptions) {
|
||||
ctx = mcontext.WithMustInfoCtx([]string{mcontext.GetOperationID(ctx), mcontext.GetOpUserID(ctx), mcontext.GetOpUserPlatform(ctx), mcontext.GetConnID(ctx)})
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*time.Duration(5))
|
||||
defer cancel()
|
||||
n := sdkws.NotificationElem{Detail: jsonutil.StructToJsonString(m)}
|
||||
content, err := json.Marshal(&n)
|
||||
if err != nil {
|
||||
errInfo := fmt.Sprintf("MsgClient Notification json.Marshal failed, sendID:%s, recvID:%s, contentType:%d, msg:%s", sendID, recvID, contentType, m)
|
||||
return errs.Wrap(err, errInfo)
|
||||
log.ZWarn(ctx, "json.Marshal failed", err, "sendID", sendID, "recvID", recvID, "contentType", contentType, "msg", jsonutil.StructToJsonString(m))
|
||||
return
|
||||
}
|
||||
notificationOpt := ¬ificationOpt{}
|
||||
for _, opt := range opts {
|
||||
@@ -275,26 +294,24 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
|
||||
if notificationOpt.WithRpcGetUsername && s.getUserInfo != nil {
|
||||
userInfo, err = s.getUserInfo(ctx, sendID)
|
||||
if err != nil {
|
||||
errInfo := fmt.Sprintf("getUserInfo failed, sendID:%s", sendID)
|
||||
return errs.Wrap(err, errInfo)
|
||||
} else {
|
||||
msg.SenderNickname = userInfo.Nickname
|
||||
msg.SenderFaceURL = userInfo.FaceURL
|
||||
log.ZWarn(ctx, "getUserInfo failed", err, "sendID", sendID)
|
||||
return
|
||||
}
|
||||
msg.SenderNickname = userInfo.Nickname
|
||||
msg.SenderFaceURL = userInfo.FaceURL
|
||||
}
|
||||
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 = sesstionType
|
||||
if msg.SessionType == constant.SuperGroupChatType {
|
||||
msg.SessionType = sessionType
|
||||
if msg.SessionType == constant.ReadGroupChatType {
|
||||
msg.GroupID = recvID
|
||||
}
|
||||
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
||||
msg.ClientMsgID = utils.GetMsgID(sendID)
|
||||
msg.CreateTime = timeutil.GetCurrentTimestampByMill()
|
||||
msg.ClientMsgID = idutil.GetMsgIDByMD5(sendID)
|
||||
optionsConfig := s.contentTypeConf[contentType]
|
||||
if sendID == recvID && contentType == constant.HasReadReceipt {
|
||||
optionsConfig.ReliabilityLevel = constant.UnreliableNotification
|
||||
@@ -302,21 +319,20 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
|
||||
options := config.GetOptionsByNotification(optionsConfig)
|
||||
s.SetOptionsByContentType(ctx, options, contentType)
|
||||
msg.Options = options
|
||||
offlineInfo.Title = title
|
||||
offlineInfo.Desc = desc
|
||||
offlineInfo.Ex = ex
|
||||
msg.OfflinePushInfo = &offlineInfo
|
||||
req.MsgData = &msg
|
||||
_, err = s.sendMsg(ctx, &req)
|
||||
if err != nil {
|
||||
errInfo := fmt.Sprintf("MsgClient Notification SendMsg failed, req:%s", &req)
|
||||
return errs.Wrap(err, errInfo)
|
||||
log.ZWarn(ctx, "SendMsg failed", err, "req", req.String())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message, opts ...NotificationOptions) error {
|
||||
return s.NotificationWithSesstionType(ctx, sendID, recvID, contentType, s.sessionTypeConf[contentType], m, opts...)
|
||||
func (s *NotificationSender) NotificationWithSessionType(ctx context.Context, sendID, recvID string, contentType, sessionType int32, m proto.Message, opts ...NotificationOptions) {
|
||||
s.queue.Push(func() { s.send(ctx, sendID, recvID, contentType, sessionType, m, opts...) })
|
||||
}
|
||||
|
||||
func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message, opts ...NotificationOptions) {
|
||||
s.NotificationWithSessionType(ctx, sendID, recvID, contentType, s.sessionTypeConf[contentType], m, opts...)
|
||||
}
|
||||
|
||||
func (s *NotificationSender) SetOptionsByContentType(_ context.Context, options map[string]bool, contentType int32) {
|
||||
|
||||
Reference in New Issue
Block a user