mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-01-09 13:36:57 +08:00
fix: changing naming irregularities under pkg and internal packages (#520)
This commit is contained in:
parent
2de5861488
commit
5283232017
@ -154,17 +154,21 @@ func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqRe
|
|||||||
|
|
||||||
func (m *MessageRpcClient) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
|
func (m *MessageRpcClient) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
|
||||||
resp, err := m.Client.PullMessageBySeqs(ctx, req)
|
resp, err := m.Client.PullMessageBySeqs(ctx, req)
|
||||||
|
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetConversationMaxSeq
|
||||||
func (m *MessageRpcClient) GetConversationMaxSeq(ctx context.Context, conversationID string) (int64, error) {
|
func (m *MessageRpcClient) GetConversationMaxSeq(ctx context.Context, conversationID string) (int64, error) {
|
||||||
resp, err := m.Client.GetConversationMaxSeq(ctx, &msg.GetConversationMaxSeqReq{ConversationID: conversationID})
|
resp, err := m.Client.GetConversationMaxSeq(ctx, &msg.GetConversationMaxSeqReq{ConversationID: conversationID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.MaxSeq, nil
|
return resp.MaxSeq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotificationSender
|
||||||
type NotificationSender struct {
|
type NotificationSender struct {
|
||||||
contentTypeConf map[int32]config.NotificationConf
|
contentTypeConf map[int32]config.NotificationConf
|
||||||
sessionTypeConf map[int32]int32
|
sessionTypeConf map[int32]int32
|
||||||
@ -172,31 +176,37 @@ type NotificationSender struct {
|
|||||||
getUserInfo func(ctx context.Context, userID string) (*sdkws.UserInfo, error)
|
getUserInfo func(ctx context.Context, userID string) (*sdkws.UserInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotificationSenderOptions
|
||||||
type NotificationSenderOptions func(*NotificationSender)
|
type NotificationSenderOptions func(*NotificationSender)
|
||||||
|
|
||||||
|
// WithLocalSendMsg
|
||||||
func WithLocalSendMsg(sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error)) NotificationSenderOptions {
|
func WithLocalSendMsg(sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error)) NotificationSenderOptions {
|
||||||
return func(s *NotificationSender) {
|
return func(s *NotificationSender) {
|
||||||
s.sendMsg = sendMsg
|
s.sendMsg = sendMsg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithRpcClient
|
||||||
func WithRpcClient(msgRpcClient *MessageRpcClient) NotificationSenderOptions {
|
func WithRpcClient(msgRpcClient *MessageRpcClient) NotificationSenderOptions {
|
||||||
return func(s *NotificationSender) {
|
return func(s *NotificationSender) {
|
||||||
s.sendMsg = msgRpcClient.SendMsg
|
s.sendMsg = msgRpcClient.SendMsg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithUserRpcClient
|
||||||
func WithUserRpcClient(userRpcClient *UserRpcClient) NotificationSenderOptions {
|
func WithUserRpcClient(userRpcClient *UserRpcClient) NotificationSenderOptions {
|
||||||
return func(s *NotificationSender) {
|
return func(s *NotificationSender) {
|
||||||
s.getUserInfo = userRpcClient.GetUserInfo
|
s.getUserInfo = userRpcClient.GetUserInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewNotificationSender
|
||||||
func NewNotificationSender(opts ...NotificationSenderOptions) *NotificationSender {
|
func NewNotificationSender(opts ...NotificationSenderOptions) *NotificationSender {
|
||||||
notificationSender := &NotificationSender{contentTypeConf: newContentTypeConf(), sessionTypeConf: newSessionTypeConf()}
|
notificationSender := &NotificationSender{contentTypeConf: newContentTypeConf(), sessionTypeConf: newSessionTypeConf()}
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(notificationSender)
|
opt(notificationSender)
|
||||||
}
|
}
|
||||||
|
|
||||||
return notificationSender
|
return notificationSender
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,19 +214,23 @@ type notificationOpt struct {
|
|||||||
WithRpcGetUsername bool
|
WithRpcGetUsername bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotificationOptions
|
||||||
type NotificationOptions func(*notificationOpt)
|
type NotificationOptions func(*notificationOpt)
|
||||||
|
|
||||||
|
// WithRpcGetUserName
|
||||||
func WithRpcGetUserName() NotificationOptions {
|
func WithRpcGetUserName() NotificationOptions {
|
||||||
return func(opt *notificationOpt) {
|
return func(opt *notificationOpt) {
|
||||||
opt.WithRpcGetUsername = true
|
opt.WithRpcGetUsername = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotificationWithSesstionType
|
||||||
func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string, contentType, sesstionType int32, m proto.Message, opts ...NotificationOptions) (err error) {
|
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)}
|
n := sdkws.NotificationElem{Detail: utils.StructToJsonString(m)}
|
||||||
content, err := json.Marshal(&n)
|
content, err := json.Marshal(&n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "MsgClient Notification json.Marshal failed", err, "sendID", sendID, "recvID", recvID, "contentType", contentType, "msg", m)
|
log.ZError(ctx, "MsgClient Notification json.Marshal failed", err, "sendID", sendID, "recvID", recvID, "contentType", contentType, "msg", m)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
notificationOpt := ¬ificationOpt{}
|
notificationOpt := ¬ificationOpt{}
|
||||||
@ -260,9 +274,11 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
|
|||||||
} else {
|
} else {
|
||||||
log.ZError(ctx, "MsgClient Notification SendMsg failed", err, "req", &req)
|
log.ZError(ctx, "MsgClient Notification SendMsg failed", err, "req", &req)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notification
|
||||||
func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message, opts ...NotificationOptions) error {
|
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...)
|
return s.NotificationWithSesstionType(ctx, sendID, recvID, contentType, s.sessionTypeConf[contentType], m, opts...)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package notification
|
package notification
|
||||||
|
|
||||||
|
// CommonUser
|
||||||
type CommonUser interface {
|
type CommonUser interface {
|
||||||
GetNickname() string
|
GetNickname() string
|
||||||
GetFaceURL() string
|
GetFaceURL() string
|
||||||
@ -21,6 +22,7 @@ type CommonUser interface {
|
|||||||
GetEx() string
|
GetEx() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CommonGroup
|
||||||
type CommonGroup interface {
|
type CommonGroup interface {
|
||||||
GetNickname() string
|
GetNickname() string
|
||||||
GetFaceURL() string
|
GetFaceURL() string
|
||||||
|
|||||||
@ -22,15 +22,17 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ConversationNotificationSender
|
||||||
type ConversationNotificationSender struct {
|
type ConversationNotificationSender struct {
|
||||||
*rpcclient.NotificationSender
|
*rpcclient.NotificationSender
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewConversationNotificationSender
|
||||||
func NewConversationNotificationSender(msgRpcClient *rpcclient.MessageRpcClient) *ConversationNotificationSender {
|
func NewConversationNotificationSender(msgRpcClient *rpcclient.MessageRpcClient) *ConversationNotificationSender {
|
||||||
return &ConversationNotificationSender{rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient))}
|
return &ConversationNotificationSender{rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient))}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPrivate调用.
|
// ConversationSetPrivateNotification
|
||||||
func (c *ConversationNotificationSender) ConversationSetPrivateNotification(
|
func (c *ConversationNotificationSender) ConversationSetPrivateNotification(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
sendID, recvID string,
|
sendID, recvID string,
|
||||||
@ -41,18 +43,20 @@ func (c *ConversationNotificationSender) ConversationSetPrivateNotification(
|
|||||||
SendID: sendID,
|
SendID: sendID,
|
||||||
IsPrivate: isPrivateChat,
|
IsPrivate: isPrivateChat,
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Notification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, tips)
|
return c.Notification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 会话改变.
|
// ConversationChangeNotification
|
||||||
func (c *ConversationNotificationSender) ConversationChangeNotification(ctx context.Context, userID string) error {
|
func (c *ConversationNotificationSender) ConversationChangeNotification(ctx context.Context, userID string) error {
|
||||||
tips := &sdkws.ConversationUpdateTips{
|
tips := &sdkws.ConversationUpdateTips{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Notification(ctx, userID, userID, constant.ConversationChangeNotification, tips)
|
return c.Notification(ctx, userID, userID, constant.ConversationChangeNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 会话未读数同步.
|
// ConversationUnreadChangeNotification
|
||||||
func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(
|
func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
userID, conversationID string,
|
userID, conversationID string,
|
||||||
@ -64,5 +68,6 @@ func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(
|
|||||||
HasReadSeq: hasReadSeq,
|
HasReadSeq: hasReadSeq,
|
||||||
UnreadCountTime: unreadCountTime,
|
UnreadCountTime: unreadCountTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Notification(ctx, userID, userID, constant.ConversationUnreadNotification, tips)
|
return c.Notification(ctx, userID, userID, constant.ConversationUnreadNotification, tips)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,9 +28,10 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// FriendNotificationSender
|
||||||
type FriendNotificationSender struct {
|
type FriendNotificationSender struct {
|
||||||
*rpcclient.NotificationSender
|
*rpcclient.NotificationSender
|
||||||
// 找不到报错
|
// if not finded, return err
|
||||||
getUsersInfo func(ctx context.Context, userIDs []string) ([]CommonUser, error)
|
getUsersInfo func(ctx context.Context, userIDs []string) ([]CommonUser, error)
|
||||||
// db controller
|
// db controller
|
||||||
db controller.FriendDatabase
|
db controller.FriendDatabase
|
||||||
@ -38,12 +39,14 @@ type FriendNotificationSender struct {
|
|||||||
|
|
||||||
type friendNotificationSenderOptions func(*FriendNotificationSender)
|
type friendNotificationSenderOptions func(*FriendNotificationSender)
|
||||||
|
|
||||||
|
// WithFriendDB
|
||||||
func WithFriendDB(db controller.FriendDatabase) friendNotificationSenderOptions {
|
func WithFriendDB(db controller.FriendDatabase) friendNotificationSenderOptions {
|
||||||
return func(s *FriendNotificationSender) {
|
return func(s *FriendNotificationSender) {
|
||||||
s.db = db
|
s.db = db
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithDBFunc
|
||||||
func WithDBFunc(
|
func WithDBFunc(
|
||||||
fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error),
|
fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error),
|
||||||
) friendNotificationSenderOptions {
|
) friendNotificationSenderOptions {
|
||||||
@ -56,12 +59,14 @@ func WithDBFunc(
|
|||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
result = append(result, user)
|
result = append(result, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
s.getUsersInfo = f
|
s.getUsersInfo = f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithRpcFunc
|
||||||
func WithRpcFunc(
|
func WithRpcFunc(
|
||||||
fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error),
|
fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error),
|
||||||
) friendNotificationSenderOptions {
|
) friendNotificationSenderOptions {
|
||||||
@ -74,12 +79,14 @@ func WithRpcFunc(
|
|||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
result = append(result, user)
|
result = append(result, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
s.getUsersInfo = f
|
s.getUsersInfo = f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewFriendNotificationSender
|
||||||
func NewFriendNotificationSender(
|
func NewFriendNotificationSender(
|
||||||
msgRpcClient *rpcclient.MessageRpcClient,
|
msgRpcClient *rpcclient.MessageRpcClient,
|
||||||
opts ...friendNotificationSenderOptions,
|
opts ...friendNotificationSenderOptions,
|
||||||
@ -90,6 +97,7 @@ func NewFriendNotificationSender(
|
|||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(f)
|
opt(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +113,7 @@ func (f *FriendNotificationSender) getUsersInfoMap(
|
|||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
result[user.GetUserID()] = user.(*sdkws.UserInfo)
|
result[user.GetUserID()] = user.(*sdkws.UserInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,16 +123,20 @@ func (f *FriendNotificationSender) getFromToUserNickname(
|
|||||||
) (string, string, error) {
|
) (string, string, error) {
|
||||||
users, err := f.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
|
users, err := f.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", nil
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
|
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserInfoUpdatedNotification
|
||||||
func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Context, changedUserID string) error {
|
func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Context, changedUserID string) error {
|
||||||
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
|
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
|
||||||
|
|
||||||
return f.Notification(ctx, mcontext.GetOpUserID(ctx), changedUserID, constant.UserInfoUpdatedNotification, &tips)
|
return f.Notification(ctx, mcontext.GetOpUserID(ctx), changedUserID, constant.UserInfoUpdatedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FriendApplicationAddNotification
|
||||||
func (f *FriendNotificationSender) FriendApplicationAddNotification(
|
func (f *FriendNotificationSender) FriendApplicationAddNotification(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbFriend.ApplyToAddFriendReq,
|
req *pbFriend.ApplyToAddFriendReq,
|
||||||
@ -132,9 +145,11 @@ func (f *FriendNotificationSender) FriendApplicationAddNotification(
|
|||||||
FromUserID: req.FromUserID,
|
FromUserID: req.FromUserID,
|
||||||
ToUserID: req.ToUserID,
|
ToUserID: req.ToUserID,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
return f.Notification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &tips)
|
return f.Notification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FriendApplicationAgreedNotification
|
||||||
func (c *FriendNotificationSender) FriendApplicationAgreedNotification(
|
func (c *FriendNotificationSender) FriendApplicationAgreedNotification(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *pbFriend.RespondFriendApplyReq,
|
req *pbFriend.RespondFriendApplyReq,
|
||||||
@ -143,6 +158,7 @@ func (c *FriendNotificationSender) FriendApplicationAgreedNotification(
|
|||||||
FromUserID: req.FromUserID,
|
FromUserID: req.FromUserID,
|
||||||
ToUserID: req.ToUserID,
|
ToUserID: req.ToUserID,
|
||||||
}, HandleMsg: req.HandleMsg}
|
}, HandleMsg: req.HandleMsg}
|
||||||
|
|
||||||
return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips)
|
return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,9 +170,11 @@ func (c *FriendNotificationSender) FriendApplicationRefusedNotification(
|
|||||||
FromUserID: req.FromUserID,
|
FromUserID: req.FromUserID,
|
||||||
ToUserID: req.ToUserID,
|
ToUserID: req.ToUserID,
|
||||||
}, HandleMsg: req.HandleMsg}
|
}, HandleMsg: req.HandleMsg}
|
||||||
|
|
||||||
return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &tips)
|
return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FriendAddedNotification
|
||||||
func (c *FriendNotificationSender) FriendAddedNotification(
|
func (c *FriendNotificationSender) FriendAddedNotification(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
operationID, opUserID, fromUserID, toUserID string,
|
operationID, opUserID, fromUserID, toUserID string,
|
||||||
@ -178,31 +196,39 @@ func (c *FriendNotificationSender) FriendAddedNotification(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Notification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &tips)
|
return c.Notification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FriendDeletedNotification
|
||||||
func (c *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) error {
|
func (c *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) error {
|
||||||
tips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{
|
tips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{
|
||||||
FromUserID: req.OwnerUserID,
|
FromUserID: req.OwnerUserID,
|
||||||
ToUserID: req.FriendUserID,
|
ToUserID: req.FriendUserID,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
return c.Notification(ctx, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &tips)
|
return c.Notification(ctx, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FriendRemarkSetNotification
|
||||||
func (c *FriendNotificationSender) FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) error {
|
func (c *FriendNotificationSender) FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) error {
|
||||||
tips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}}
|
tips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||||
tips.FromToUserID.FromUserID = fromUserID
|
tips.FromToUserID.FromUserID = fromUserID
|
||||||
tips.FromToUserID.ToUserID = toUserID
|
tips.FromToUserID.ToUserID = toUserID
|
||||||
|
|
||||||
return c.Notification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &tips)
|
return c.Notification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BlackAddedNotification
|
||||||
func (c *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) error {
|
func (c *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) error {
|
||||||
tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
|
tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||||
tips.FromToUserID.FromUserID = req.OwnerUserID
|
tips.FromToUserID.FromUserID = req.OwnerUserID
|
||||||
tips.FromToUserID.ToUserID = req.BlackUserID
|
tips.FromToUserID.ToUserID = req.BlackUserID
|
||||||
|
|
||||||
return c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &tips)
|
return c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BlackDeletedNotification
|
||||||
func (c *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) {
|
func (c *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) {
|
||||||
blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{
|
blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{
|
||||||
FromUserID: req.OwnerUserID,
|
FromUserID: req.OwnerUserID,
|
||||||
@ -211,6 +237,7 @@ func (c *FriendNotificationSender) BlackDeletedNotification(ctx context.Context,
|
|||||||
c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
|
c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FriendInfoUpdatedNotification
|
||||||
func (c *FriendNotificationSender) FriendInfoUpdatedNotification(
|
func (c *FriendNotificationSender) FriendInfoUpdatedNotification(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
changedUserID string,
|
changedUserID string,
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewGroupNotificationSender
|
||||||
func NewGroupNotificationSender(
|
func NewGroupNotificationSender(
|
||||||
db controller.GroupDatabase,
|
db controller.GroupDatabase,
|
||||||
msgRpcClient *rpcclient.MessageRpcClient,
|
msgRpcClient *rpcclient.MessageRpcClient,
|
||||||
@ -43,6 +44,7 @@ func NewGroupNotificationSender(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupNotificationSender
|
||||||
type GroupNotificationSender struct {
|
type GroupNotificationSender struct {
|
||||||
*rpcclient.NotificationSender
|
*rpcclient.NotificationSender
|
||||||
getUsersInfo func(ctx context.Context, userIDs []string) ([]CommonUser, error)
|
getUsersInfo func(ctx context.Context, userIDs []string) ([]CommonUser, error)
|
||||||
@ -57,6 +59,7 @@ func (g *GroupNotificationSender) getUser(ctx context.Context, userID string) (*
|
|||||||
if len(users) == 0 {
|
if len(users) == 0 {
|
||||||
return nil, errs.ErrUserIDNotFound.Wrap(fmt.Sprintf("user %s not found", userID))
|
return nil, errs.ErrUserIDNotFound.Wrap(fmt.Sprintf("user %s not found", userID))
|
||||||
}
|
}
|
||||||
|
|
||||||
return &sdkws.PublicUserInfo{
|
return &sdkws.PublicUserInfo{
|
||||||
UserID: users[0].GetUserID(),
|
UserID: users[0].GetUserID(),
|
||||||
Nickname: users[0].GetNickname(),
|
Nickname: users[0].GetNickname(),
|
||||||
@ -78,6 +81,7 @@ func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID stri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &sdkws.GroupInfo{
|
return &sdkws.GroupInfo{
|
||||||
GroupID: gm.GroupID,
|
GroupID: gm.GroupID,
|
||||||
GroupName: gm.GroupName,
|
GroupName: gm.GroupName,
|
||||||
@ -122,7 +126,7 @@ func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID s
|
|||||||
res = append(res, g.groupMemberDB2PB(member, user.AppMangerLevel))
|
res = append(res, g.groupMemberDB2PB(member, user.AppMangerLevel))
|
||||||
delete(users, member.UserID)
|
delete(users, member.UserID)
|
||||||
}
|
}
|
||||||
//for userID, info := range users {
|
// for userID, info := range users {
|
||||||
// if info.AppMangerLevel == constant.AppAdmin {
|
// if info.AppMangerLevel == constant.AppAdmin {
|
||||||
// res = append(res, &sdkws.GroupMemberFullInfo{
|
// res = append(res, &sdkws.GroupMemberFullInfo{
|
||||||
// GroupID: groupID,
|
// GroupID: groupID,
|
||||||
@ -132,7 +136,7 @@ func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID s
|
|||||||
// AppMangerLevel: info.AppMangerLevel,
|
// AppMangerLevel: info.AppMangerLevel,
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
//}
|
// }
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +149,7 @@ func (g *GroupNotificationSender) getGroupMemberMap(ctx context.Context, groupID
|
|||||||
for i, member := range members {
|
for i, member := range members {
|
||||||
m[member.UserID] = members[i]
|
m[member.UserID] = members[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,6 +161,7 @@ func (g *GroupNotificationSender) getGroupMember(ctx context.Context, groupID st
|
|||||||
if len(members) == 0 {
|
if len(members) == 0 {
|
||||||
return nil, errs.ErrInternalServer.Wrap(fmt.Sprintf("group %s member %s not found", groupID, userID))
|
return nil, errs.ErrInternalServer.Wrap(fmt.Sprintf("group %s member %s not found", groupID, userID))
|
||||||
}
|
}
|
||||||
|
|
||||||
return members[0], nil
|
return members[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +171,7 @@ func (g *GroupNotificationSender) getGroupOwnerAndAdminUserID(ctx context.Contex
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
fn := func(e *relation.GroupMemberModel) string { return e.UserID }
|
fn := func(e *relation.GroupMemberModel) string { return e.UserID }
|
||||||
|
|
||||||
return utils.Slice(members, fn), nil
|
return utils.Slice(members, fn), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,6 +223,7 @@ func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs [
|
|||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
result[user.GetUserID()] = user.(*sdkws.UserInfo)
|
result[user.GetUserID()] = user.(*sdkws.UserInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,37 +263,47 @@ func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws
|
|||||||
(*opUser).FaceURL = user.FaceURL
|
(*opUser).FaceURL = user.FaceURL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupCreatedNotification
|
||||||
func (g *GroupNotificationSender) GroupCreatedNotification(ctx context.Context, tips *sdkws.GroupCreatedTips) (err error) {
|
func (g *GroupNotificationSender) GroupCreatedNotification(ctx context.Context, tips *sdkws.GroupCreatedTips) (err error) {
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupCreatedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupCreatedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupInfoSetNotification
|
||||||
func (g *GroupNotificationSender) GroupInfoSetNotification(ctx context.Context, tips *sdkws.GroupInfoSetTips) (err error) {
|
func (g *GroupNotificationSender) GroupInfoSetNotification(ctx context.Context, tips *sdkws.GroupInfoSetTips) (err error) {
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNotification, tips, rpcclient.WithRpcGetUserName())
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNotification, tips, rpcclient.WithRpcGetUserName())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupInfoSetNameNotification
|
||||||
func (g *GroupNotificationSender) GroupInfoSetNameNotification(ctx context.Context, tips *sdkws.GroupInfoSetNameTips) (err error) {
|
func (g *GroupNotificationSender) GroupInfoSetNameNotification(ctx context.Context, tips *sdkws.GroupInfoSetNameTips) (err error) {
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNameNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNameNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupInfoSetAnnouncementNotification
|
||||||
func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(ctx context.Context, tips *sdkws.GroupInfoSetAnnouncementTips) (err error) {
|
func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(ctx context.Context, tips *sdkws.GroupInfoSetAnnouncementTips) (err error) {
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, rpcclient.WithRpcGetUserName())
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, rpcclient.WithRpcGetUserName())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JoinGroupApplicationNotification
|
||||||
func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) (err error) {
|
func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) (err error) {
|
||||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -307,9 +325,11 @@ func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.C
|
|||||||
log.ZError(ctx, "JoinGroupApplicationNotification failed", err, "group", req.GroupID, "userID", userID)
|
log.ZError(ctx, "JoinGroupApplicationNotification failed", err, "group", req.GroupID, "userID", userID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MemberQuitNotification
|
||||||
func (g *GroupNotificationSender) MemberQuitNotification(ctx context.Context, member *sdkws.GroupMemberFullInfo) (err error) {
|
func (g *GroupNotificationSender) MemberQuitNotification(ctx context.Context, member *sdkws.GroupMemberFullInfo) (err error) {
|
||||||
defer log.ZDebug(ctx, "return")
|
defer log.ZDebug(ctx, "return")
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -322,9 +342,11 @@ func (g *GroupNotificationSender) MemberQuitNotification(ctx context.Context, me
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tips := &sdkws.MemberQuitTips{Group: group, QuitUser: member}
|
tips := &sdkws.MemberQuitTips{Group: group, QuitUser: member}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), member.GroupID, constant.MemberQuitNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), member.GroupID, constant.MemberQuitNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupApplicationAcceptedNotification
|
||||||
func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
||||||
defer log.ZDebug(ctx, "return")
|
defer log.ZDebug(ctx, "return")
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -350,9 +372,11 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
|
|||||||
log.ZError(ctx, "failed", err)
|
log.ZError(ctx, "failed", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupApplicationRejectedNotification
|
||||||
func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
||||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -372,9 +396,11 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
|
|||||||
log.ZError(ctx, "failed", err)
|
log.ZError(ctx, "failed", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupOwnerTransferredNotification
|
||||||
func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) (err error) {
|
func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) (err error) {
|
||||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -389,16 +415,20 @@ func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.
|
|||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupOwnerTransferredNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupOwnerTransferredNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MemberKickedNotification
|
||||||
func (g *GroupNotificationSender) MemberKickedNotification(ctx context.Context, tips *sdkws.MemberKickedTips) (err error) {
|
func (g *GroupNotificationSender) MemberKickedNotification(ctx context.Context, tips *sdkws.MemberKickedTips) (err error) {
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.MemberKickedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.MemberKickedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MemberInvitedNotification
|
||||||
func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context, groupID, reason string, invitedUserIDList []string) (err error) {
|
func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context, groupID, reason string, invitedUserIDList []string) (err error) {
|
||||||
group, err := g.getGroupInfo(ctx, groupID)
|
group, err := g.getGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -415,9 +445,11 @@ func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context,
|
|||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberInvitedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberInvitedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MemberEnterNotification
|
||||||
func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
||||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -435,9 +467,11 @@ func (g *GroupNotificationSender) GroupDismissedNotification(ctx context.Context
|
|||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupDismissedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupDismissedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupMemberMutedNotification
|
||||||
func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Context, groupID, groupMemberUserID string, mutedSeconds uint32) (err error) {
|
func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Context, groupID, groupMemberUserID string, mutedSeconds uint32) (err error) {
|
||||||
group, err := g.getGroupInfo(ctx, groupID)
|
group, err := g.getGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -454,6 +488,7 @@ func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Conte
|
|||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberMutedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberMutedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,6 +505,7 @@ func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(ctx context
|
|||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberCancelMutedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberCancelMutedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,6 +525,7 @@ func (g *GroupNotificationSender) GroupMutedNotification(ctx context.Context, gr
|
|||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMutedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMutedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -508,9 +545,11 @@ func (g *GroupNotificationSender) GroupCancelMutedNotification(ctx context.Conte
|
|||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupMemberInfoSetNotification
|
||||||
func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||||
group, err := g.getGroupInfo(ctx, groupID)
|
group, err := g.getGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -524,6 +563,7 @@ func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Con
|
|||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberInfoSetNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberInfoSetNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,6 +580,7 @@ func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(ctx context.
|
|||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToAdminNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToAdminNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,6 +600,7 @@ func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx c
|
|||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToOrdinaryUserNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToOrdinaryUserNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MemberEnterDirectlyNotification
|
||||||
func (g *GroupNotificationSender) MemberEnterDirectlyNotification(ctx context.Context, groupID string, entrantUserID string) (err error) {
|
func (g *GroupNotificationSender) MemberEnterDirectlyNotification(ctx context.Context, groupID string, entrantUserID string) (err error) {
|
||||||
defer log.ZDebug(ctx, "return")
|
defer log.ZDebug(ctx, "return")
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -575,9 +617,11 @@ func (g *GroupNotificationSender) MemberEnterDirectlyNotification(ctx context.Co
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tips := &sdkws.MemberEnterTips{Group: group, EntrantUser: user}
|
tips := &sdkws.MemberEnterTips{Group: group, EntrantUser: user}
|
||||||
|
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberEnterNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberEnterNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SuperGroupNotification
|
||||||
func (g *GroupNotificationSender) SuperGroupNotification(ctx context.Context, sendID, recvID string) (err error) {
|
func (g *GroupNotificationSender) SuperGroupNotification(ctx context.Context, sendID, recvID string) (err error) {
|
||||||
defer log.ZDebug(ctx, "return")
|
defer log.ZDebug(ctx, "return")
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -586,5 +630,6 @@ func (g *GroupNotificationSender) SuperGroupNotification(ctx context.Context, se
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
err = g.Notification(ctx, sendID, recvID, constant.SuperGroupUpdateNotification, nil)
|
err = g.Notification(ctx, sendID, recvID, constant.SuperGroupUpdateNotification, nil)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,23 +22,28 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// MsgNotificationSender
|
||||||
type MsgNotificationSender struct {
|
type MsgNotificationSender struct {
|
||||||
*rpcclient.NotificationSender
|
*rpcclient.NotificationSender
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewMsgNotificationSender
|
||||||
func NewMsgNotificationSender(opts ...rpcclient.NotificationSenderOptions) *MsgNotificationSender {
|
func NewMsgNotificationSender(opts ...rpcclient.NotificationSenderOptions) *MsgNotificationSender {
|
||||||
return &MsgNotificationSender{rpcclient.NewNotificationSender(opts...)}
|
return &MsgNotificationSender{rpcclient.NewNotificationSender(opts...)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserDeleteMsgsNotification
|
||||||
func (m *MsgNotificationSender) UserDeleteMsgsNotification(ctx context.Context, userID, conversationID string, seqs []int64) error {
|
func (m *MsgNotificationSender) UserDeleteMsgsNotification(ctx context.Context, userID, conversationID string, seqs []int64) error {
|
||||||
tips := sdkws.DeleteMsgsTips{
|
tips := sdkws.DeleteMsgsTips{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
ConversationID: conversationID,
|
ConversationID: conversationID,
|
||||||
Seqs: seqs,
|
Seqs: seqs,
|
||||||
}
|
}
|
||||||
|
|
||||||
return m.Notification(ctx, userID, userID, constant.DeleteMsgsNotification, &tips)
|
return m.Notification(ctx, userID, userID, constant.DeleteMsgsNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarkAsReadNotification
|
||||||
func (m *MsgNotificationSender) MarkAsReadNotification(ctx context.Context, conversationID string, sesstionType int32, sendID, recvID string, seqs []int64, hasReadSeq int64) error {
|
func (m *MsgNotificationSender) MarkAsReadNotification(ctx context.Context, conversationID string, sesstionType int32, sendID, recvID string, seqs []int64, hasReadSeq int64) error {
|
||||||
tips := &sdkws.MarkAsReadTips{
|
tips := &sdkws.MarkAsReadTips{
|
||||||
MarkAsReadUserID: sendID,
|
MarkAsReadUserID: sendID,
|
||||||
@ -46,5 +51,6 @@ func (m *MsgNotificationSender) MarkAsReadNotification(ctx context.Context, conv
|
|||||||
Seqs: seqs,
|
Seqs: seqs,
|
||||||
HasReadSeq: hasReadSeq,
|
HasReadSeq: hasReadSeq,
|
||||||
}
|
}
|
||||||
|
|
||||||
return m.NotificationWithSesstionType(ctx, sendID, recvID, constant.HasReadReceipt, sesstionType, tips)
|
return m.NotificationWithSesstionType(ctx, sendID, recvID, constant.HasReadReceipt, sesstionType, tips)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,17 +24,20 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/push"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/push"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Push
|
||||||
type Push struct {
|
type Push struct {
|
||||||
conn grpc.ClientConnInterface
|
conn grpc.ClientConnInterface
|
||||||
Client push.PushMsgServiceClient
|
Client push.PushMsgServiceClient
|
||||||
discov discoveryregistry.SvcDiscoveryRegistry
|
discov discoveryregistry.SvcDiscoveryRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewPush
|
||||||
func NewPush(discov discoveryregistry.SvcDiscoveryRegistry) *Push {
|
func NewPush(discov discoveryregistry.SvcDiscoveryRegistry) *Push {
|
||||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImPushName)
|
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImPushName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Push{
|
return &Push{
|
||||||
discov: discov,
|
discov: discov,
|
||||||
conn: conn,
|
conn: conn,
|
||||||
@ -42,12 +45,15 @@ func NewPush(discov discoveryregistry.SvcDiscoveryRegistry) *Push {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PushRpcClient
|
||||||
type PushRpcClient Push
|
type PushRpcClient Push
|
||||||
|
|
||||||
|
// NewPushRpcClient
|
||||||
func NewPushRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) PushRpcClient {
|
func NewPushRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) PushRpcClient {
|
||||||
return PushRpcClient(*NewPush(discov))
|
return PushRpcClient(*NewPush(discov))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DelUserPushToken
|
||||||
func (p *PushRpcClient) DelUserPushToken(
|
func (p *PushRpcClient) DelUserPushToken(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *push.DelUserPushTokenReq,
|
req *push.DelUserPushTokenReq,
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Third
|
||||||
type Third struct {
|
type Third struct {
|
||||||
conn grpc.ClientConnInterface
|
conn grpc.ClientConnInterface
|
||||||
Client third.ThirdClient
|
Client third.ThirdClient
|
||||||
@ -35,20 +36,22 @@ type Third struct {
|
|||||||
MinioClient *minio.Client
|
MinioClient *minio.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewThird
|
||||||
func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
|
func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
|
||||||
|
var minioClient *minio.Client
|
||||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImThirdName)
|
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImThirdName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
client := third.NewThirdClient(conn)
|
client := third.NewThirdClient(conn)
|
||||||
minioClient, err := minioInit()
|
minioClient, err = minioInit()
|
||||||
|
|
||||||
return &Third{discov: discov, Client: client, conn: conn, MinioClient: minioClient}
|
return &Third{discov: discov, Client: client, conn: conn, MinioClient: minioClient}
|
||||||
}
|
}
|
||||||
|
|
||||||
func minioInit() (*minio.Client, error) {
|
func minioInit() (*minio.Client, error) {
|
||||||
minioClient := &minio.Client{}
|
var minioClient *minio.Client
|
||||||
var initUrl string
|
initUrl := config.Config.Object.Minio.Endpoint
|
||||||
initUrl = config.Config.Object.Minio.Endpoint
|
|
||||||
minioUrl, err := url.Parse(initUrl)
|
minioUrl, err := url.Parse(initUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -66,5 +69,6 @@ func minioInit() (*minio.Client, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return minioClient, nil
|
return minioClient, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,32 +29,39 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// User
|
||||||
type User struct {
|
type User struct {
|
||||||
conn grpc.ClientConnInterface
|
conn grpc.ClientConnInterface
|
||||||
Client user.UserClient
|
Client user.UserClient
|
||||||
Discov discoveryregistry.SvcDiscoveryRegistry
|
Discov discoveryregistry.SvcDiscoveryRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewUser
|
||||||
func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
|
func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
|
||||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
|
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
client := user.NewUserClient(conn)
|
client := user.NewUserClient(conn)
|
||||||
|
|
||||||
return &User{Discov: discov, Client: client, conn: conn}
|
return &User{Discov: discov, Client: client, conn: conn}
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserRpcClient User
|
type UserRpcClient User
|
||||||
|
|
||||||
|
// NewUserRpcClientByUser
|
||||||
func NewUserRpcClientByUser(user *User) *UserRpcClient {
|
func NewUserRpcClientByUser(user *User) *UserRpcClient {
|
||||||
rpc := UserRpcClient(*user)
|
rpc := UserRpcClient(*user)
|
||||||
|
|
||||||
return &rpc
|
return &rpc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewUserRpcClient
|
||||||
func NewUserRpcClient(client discoveryregistry.SvcDiscoveryRegistry) UserRpcClient {
|
func NewUserRpcClient(client discoveryregistry.SvcDiscoveryRegistry) UserRpcClient {
|
||||||
return UserRpcClient(*NewUser(client))
|
return UserRpcClient(*NewUser(client))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUsersInfo
|
||||||
func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error) {
|
func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error) {
|
||||||
resp, err := u.Client.GetDesignateUsers(ctx, &user.GetDesignateUsersReq{
|
resp, err := u.Client.GetDesignateUsers(ctx, &user.GetDesignateUsersReq{
|
||||||
UserIDs: userIDs,
|
UserIDs: userIDs,
|
||||||
@ -67,27 +74,33 @@ func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*
|
|||||||
})); len(ids) > 0 {
|
})); len(ids) > 0 {
|
||||||
return nil, errs.ErrUserIDNotFound.Wrap(strings.Join(ids, ","))
|
return nil, errs.ErrUserIDNotFound.Wrap(strings.Join(ids, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.UsersInfo, nil
|
return resp.UsersInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserInfo
|
||||||
func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.UserInfo, error) {
|
func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.UserInfo, error) {
|
||||||
users, err := u.GetUsersInfo(ctx, []string{userID})
|
users, err := u.GetUsersInfo(ctx, []string{userID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return users[0], nil
|
return users[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUsersInfoMap
|
||||||
func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
|
func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
|
||||||
users, err := u.GetUsersInfo(ctx, userIDs)
|
users, err := u.GetUsersInfo(ctx, userIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.SliceToMap(users, func(e *sdkws.UserInfo) string {
|
return utils.SliceToMap(users, func(e *sdkws.UserInfo) string {
|
||||||
return e.UserID
|
return e.UserID
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPublicUserInfos
|
||||||
func (u *UserRpcClient) GetPublicUserInfos(
|
func (u *UserRpcClient) GetPublicUserInfos(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
userIDs []string,
|
userIDs []string,
|
||||||
@ -97,6 +110,7 @@ func (u *UserRpcClient) GetPublicUserInfos(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.Slice(users, func(e *sdkws.UserInfo) *sdkws.PublicUserInfo {
|
return utils.Slice(users, func(e *sdkws.UserInfo) *sdkws.PublicUserInfo {
|
||||||
return &sdkws.PublicUserInfo{
|
return &sdkws.PublicUserInfo{
|
||||||
UserID: e.UserID,
|
UserID: e.UserID,
|
||||||
@ -107,14 +121,17 @@ func (u *UserRpcClient) GetPublicUserInfos(
|
|||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPublicUserInfo
|
||||||
func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) {
|
func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) {
|
||||||
users, err := u.GetPublicUserInfos(ctx, []string{userID}, true)
|
users, err := u.GetPublicUserInfos(ctx, []string{userID}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return users[0], nil
|
return users[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPublicUserInfoMap
|
||||||
func (u *UserRpcClient) GetPublicUserInfoMap(
|
func (u *UserRpcClient) GetPublicUserInfoMap(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
userIDs []string,
|
userIDs []string,
|
||||||
@ -124,11 +141,13 @@ func (u *UserRpcClient) GetPublicUserInfoMap(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.SliceToMap(users, func(e *sdkws.PublicUserInfo) string {
|
return utils.SliceToMap(users, func(e *sdkws.PublicUserInfo) string {
|
||||||
return e.UserID
|
return e.UserID
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserGlobalMsgRecvOpt
|
||||||
func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID string) (int32, error) {
|
func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID string) (int32, error) {
|
||||||
resp, err := u.Client.GetGlobalRecvMessageOpt(ctx, &user.GetGlobalRecvMessageOptReq{
|
resp, err := u.Client.GetGlobalRecvMessageOpt(ctx, &user.GetGlobalRecvMessageOptReq{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
@ -136,21 +155,26 @@ func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID stri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.GlobalRecvMsgOpt, err
|
return resp.GlobalRecvMsgOpt, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Access
|
||||||
func (u *UserRpcClient) Access(ctx context.Context, ownerUserID string) error {
|
func (u *UserRpcClient) Access(ctx context.Context, ownerUserID string) error {
|
||||||
_, err := u.GetUserInfo(ctx, ownerUserID)
|
_, err := u.GetUserInfo(ctx, ownerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return tokenverify.CheckAccessV3(ctx, ownerUserID)
|
return tokenverify.CheckAccessV3(ctx, ownerUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAllUserIDs
|
||||||
func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumber int32) ([]string, error) {
|
func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumber int32) ([]string, error) {
|
||||||
resp, err := u.Client.GetAllUserID(ctx, &user.GetAllUserIDReq{Pagination: &sdkws.RequestPagination{PageNumber: pageNumber, ShowNumber: showNumber}})
|
resp, err := u.Client.GetAllUserID(ctx, &user.GetAllUserIDReq{Pagination: &sdkws.RequestPagination{PageNumber: pageNumber, ShowNumber: showNumber}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.UserIDs, nil
|
return resp.UserIDs, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Start
|
||||||
func Start(
|
func Start(
|
||||||
rpcPort int,
|
rpcPort int,
|
||||||
rpcRegisterName string,
|
rpcRegisterName string,
|
||||||
@ -108,5 +109,6 @@ func Start(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return utils.Wrap1(srv.Serve(listener))
|
return utils.Wrap1(srv.Serve(listener))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Statistics num
|
||||||
type Statistics struct {
|
type Statistics struct {
|
||||||
AllCount *uint64
|
AllCount *uint64
|
||||||
ModuleName string
|
ModuleName string
|
||||||
@ -34,10 +35,12 @@ func (s *Statistics) output() {
|
|||||||
defer t.Stop()
|
defer t.Stop()
|
||||||
var sum uint64
|
var sum uint64
|
||||||
var timeIntervalNum uint64
|
var timeIntervalNum uint64
|
||||||
|
outputCh := make(chan struct{})
|
||||||
for {
|
for {
|
||||||
sum = *s.AllCount
|
sum = *s.AllCount
|
||||||
select {
|
select {
|
||||||
case <-t.C:
|
case <-t.C:
|
||||||
|
outputCh <- struct{}{}
|
||||||
}
|
}
|
||||||
if *s.AllCount-sum <= 0 {
|
if *s.AllCount-sum <= 0 {
|
||||||
intervalCount = 0
|
intervalCount = 0
|
||||||
@ -63,8 +66,10 @@ func (s *Statistics) output() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewStatistics
|
||||||
func NewStatistics(allCount *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
|
func NewStatistics(allCount *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
|
||||||
p := &Statistics{AllCount: allCount, ModuleName: moduleName, SleepTime: uint64(sleepTime), PrintArgs: printArgs}
|
p := &Statistics{AllCount: allCount, ModuleName: moduleName, SleepTime: uint64(sleepTime), PrintArgs: printArgs}
|
||||||
go p.output()
|
go p.output()
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user