mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-03 16:45:59 +08:00
style: add format
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
@@ -3,10 +3,11 @@ package rpcclient
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func NewAuth(discov discoveryregistry.SvcDiscoveryRegistry) *Auth {
|
||||
|
||||
@@ -4,11 +4,12 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Conversation struct {
|
||||
@@ -32,12 +33,18 @@ func NewConversationRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) Con
|
||||
return ConversationRpcClient(*NewConversation(discov))
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) error {
|
||||
func (c *ConversationRpcClient) ModifyConversationField(
|
||||
ctx context.Context,
|
||||
req *pbConversation.ModifyConversationFieldReq,
|
||||
) error {
|
||||
_, err := c.Client.ModifyConversationField(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
|
||||
func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(
|
||||
ctx context.Context,
|
||||
userID, conversationID string,
|
||||
) (int32, error) {
|
||||
var req pbConversation.GetConversationReq
|
||||
req.OwnerUserID = userID
|
||||
req.ConversationID = conversationID
|
||||
@@ -49,21 +56,51 @@ func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Cont
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID string) error {
|
||||
_, err := c.Client.CreateSingleChatConversations(ctx, &pbConversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID})
|
||||
_, err := c.Client.CreateSingleChatConversations(
|
||||
ctx,
|
||||
&pbConversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID},
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(ctx context.Context, groupID string, userIDs []string) error {
|
||||
_, err := c.Client.CreateGroupChatConversations(ctx, &pbConversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID})
|
||||
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userIDs []string,
|
||||
) error {
|
||||
_, err := c.Client.CreateGroupChatConversations(
|
||||
ctx,
|
||||
&pbConversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID},
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) SetConversationMaxSeq(ctx context.Context, ownerUserIDs []string, conversationID string, maxSeq int64) error {
|
||||
_, err := c.Client.SetConversationMaxSeq(ctx, &pbConversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq})
|
||||
func (c *ConversationRpcClient) SetConversationMaxSeq(
|
||||
ctx context.Context,
|
||||
ownerUserIDs []string,
|
||||
conversationID string,
|
||||
maxSeq int64,
|
||||
) error {
|
||||
_, err := c.Client.SetConversationMaxSeq(
|
||||
ctx,
|
||||
&pbConversation.SetConversationMaxSeqReq{
|
||||
OwnerUserID: ownerUserIDs,
|
||||
ConversationID: conversationID,
|
||||
MaxSeq: maxSeq,
|
||||
},
|
||||
)
|
||||
return err
|
||||
}
|
||||
func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbConversation.ConversationReq) error {
|
||||
_, err := c.Client.SetConversations(ctx, &pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
|
||||
|
||||
func (c *ConversationRpcClient) SetConversations(
|
||||
ctx context.Context,
|
||||
userIDs []string,
|
||||
conversation *pbConversation.ConversationReq,
|
||||
) error {
|
||||
_, err := c.Client.SetConversations(
|
||||
ctx,
|
||||
&pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation},
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -75,16 +112,28 @@ func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUse
|
||||
return resp.ConversationIDs, nil
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*pbConversation.Conversation, error) {
|
||||
resp, err := c.Client.GetConversation(ctx, &pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID})
|
||||
func (c *ConversationRpcClient) GetConversation(
|
||||
ctx context.Context,
|
||||
ownerUserID, conversationID string,
|
||||
) (*pbConversation.Conversation, error) {
|
||||
resp, err := c.Client.GetConversation(
|
||||
ctx,
|
||||
&pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.Conversation, nil
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*pbConversation.Conversation, error) {
|
||||
resp, err := c.Client.GetConversationsByConversationID(ctx, &pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs})
|
||||
func (c *ConversationRpcClient) GetConversationsByConversationID(
|
||||
ctx context.Context,
|
||||
conversationIDs []string,
|
||||
) ([]*pbConversation.Conversation, error) {
|
||||
resp, err := c.Client.GetConversationsByConversationID(
|
||||
ctx,
|
||||
&pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -94,8 +143,15 @@ func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Con
|
||||
return resp.Conversations, nil
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*pbConversation.Conversation, error) {
|
||||
resp, err := c.Client.GetConversations(ctx, &pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs})
|
||||
func (c *ConversationRpcClient) GetConversations(
|
||||
ctx context.Context,
|
||||
ownerUserID string,
|
||||
conversationIDs []string,
|
||||
) ([]*pbConversation.Conversation, error) {
|
||||
resp, err := c.Client.GetConversations(
|
||||
ctx,
|
||||
&pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+10
-3
@@ -3,11 +3,12 @@ package rpcclient
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
|
||||
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Friend struct {
|
||||
@@ -31,8 +32,14 @@ func NewFriendRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) FriendRpc
|
||||
return FriendRpcClient(*NewFriend(discov))
|
||||
}
|
||||
|
||||
func (f *FriendRpcClient) GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (resp *sdkws.FriendInfo, err error) {
|
||||
r, err := f.Client.GetDesignatedFriends(ctx, &friend.GetDesignatedFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{friendUserID}})
|
||||
func (f *FriendRpcClient) GetFriendsInfo(
|
||||
ctx context.Context,
|
||||
ownerUserID, friendUserID string,
|
||||
) (resp *sdkws.FriendInfo, err error) {
|
||||
r, err := f.Client.GetDesignatedFriends(
|
||||
ctx,
|
||||
&friend.GetDesignatedFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{friendUserID}},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+38
-8
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"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"
|
||||
@@ -11,7 +13,6 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Group struct {
|
||||
@@ -35,7 +36,11 @@ func NewGroupRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) GroupRpcCl
|
||||
return GroupRpcClient(*NewGroup(discov))
|
||||
}
|
||||
|
||||
func (g *GroupRpcClient) GetGroupInfos(ctx context.Context, groupIDs []string, complete bool) ([]*sdkws.GroupInfo, error) {
|
||||
func (g *GroupRpcClient) GetGroupInfos(
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
complete bool,
|
||||
) ([]*sdkws.GroupInfo, error) {
|
||||
resp, err := g.Client.GetGroupsInfo(ctx, &group.GetGroupsInfoReq{
|
||||
GroupIDs: groupIDs,
|
||||
})
|
||||
@@ -60,7 +65,11 @@ func (g *GroupRpcClient) GetGroupInfo(ctx context.Context, groupID string) (*sdk
|
||||
return groups[0], nil
|
||||
}
|
||||
|
||||
func (g *GroupRpcClient) GetGroupInfoMap(ctx context.Context, groupIDs []string, complete bool) (map[string]*sdkws.GroupInfo, error) {
|
||||
func (g *GroupRpcClient) GetGroupInfoMap(
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
complete bool,
|
||||
) (map[string]*sdkws.GroupInfo, error) {
|
||||
groups, err := g.GetGroupInfos(ctx, groupIDs, complete)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -70,7 +79,12 @@ func (g *GroupRpcClient) GetGroupInfoMap(ctx context.Context, groupIDs []string,
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (g *GroupRpcClient) GetGroupMemberInfos(ctx context.Context, groupID string, userIDs []string, complete bool) ([]*sdkws.GroupMemberFullInfo, error) {
|
||||
func (g *GroupRpcClient) GetGroupMemberInfos(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userIDs []string,
|
||||
complete bool,
|
||||
) ([]*sdkws.GroupMemberFullInfo, error) {
|
||||
resp, err := g.Client.GetGroupMembersInfo(ctx, &group.GetGroupMembersInfoReq{
|
||||
GroupID: groupID,
|
||||
UserIDs: userIDs,
|
||||
@@ -88,7 +102,11 @@ func (g *GroupRpcClient) GetGroupMemberInfos(ctx context.Context, groupID string
|
||||
return resp.Members, nil
|
||||
}
|
||||
|
||||
func (g *GroupRpcClient) GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) {
|
||||
func (g *GroupRpcClient) GetGroupMemberInfo(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userID string,
|
||||
) (*sdkws.GroupMemberFullInfo, error) {
|
||||
members, err := g.GetGroupMemberInfos(ctx, groupID, []string{userID}, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -96,7 +114,12 @@ func (g *GroupRpcClient) GetGroupMemberInfo(ctx context.Context, groupID string,
|
||||
return members[0], nil
|
||||
}
|
||||
|
||||
func (g *GroupRpcClient) GetGroupMemberInfoMap(ctx context.Context, groupID string, userIDs []string, complete bool) (map[string]*sdkws.GroupMemberFullInfo, error) {
|
||||
func (g *GroupRpcClient) GetGroupMemberInfoMap(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userIDs []string,
|
||||
complete bool,
|
||||
) (map[string]*sdkws.GroupMemberFullInfo, error) {
|
||||
members, err := g.GetGroupMemberInfos(ctx, groupID, userIDs, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -106,7 +129,10 @@ func (g *GroupRpcClient) GetGroupMemberInfoMap(ctx context.Context, groupID stri
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (g *GroupRpcClient) GetOwnerAndAdminInfos(ctx context.Context, groupID string) ([]*sdkws.GroupMemberFullInfo, error) {
|
||||
func (g *GroupRpcClient) GetOwnerAndAdminInfos(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
) ([]*sdkws.GroupMemberFullInfo, error) {
|
||||
resp, err := g.Client.GetGroupMemberRoleLevel(ctx, &group.GetGroupMemberRoleLevelReq{
|
||||
GroupID: groupID,
|
||||
RoleLevels: []int32{constant.GroupOwner, constant.GroupAdmin},
|
||||
@@ -145,7 +171,11 @@ func (g *GroupRpcClient) GetGroupInfoCache(ctx context.Context, groupID string)
|
||||
return resp.GroupInfo, nil
|
||||
}
|
||||
|
||||
func (g *GroupRpcClient) GetGroupMemberCache(ctx context.Context, groupID string, groupMemberID string) (*sdkws.GroupMemberFullInfo, error) {
|
||||
func (g *GroupRpcClient) GetGroupMemberCache(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
groupMemberID string,
|
||||
) (*sdkws.GroupMemberFullInfo, error) {
|
||||
resp, err := g.Client.GetGroupMemberCache(ctx, &group.GetGroupMemberCacheReq{
|
||||
GroupID: groupID,
|
||||
GroupMemberID: groupMemberID,
|
||||
|
||||
+41
-8
@@ -4,6 +4,9 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||
@@ -11,8 +14,6 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
// "google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -134,7 +135,10 @@ func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqRe
|
||||
return resp, err
|
||||
}
|
||||
|
||||
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)
|
||||
return resp, err
|
||||
}
|
||||
@@ -155,7 +159,9 @@ type NotificationSender struct {
|
||||
|
||||
type NewNotificationSenderOptions func(*NotificationSender)
|
||||
|
||||
func WithLocalSendMsg(sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error)) NewNotificationSenderOptions {
|
||||
func WithLocalSendMsg(
|
||||
sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error),
|
||||
) NewNotificationSenderOptions {
|
||||
return func(s *NotificationSender) {
|
||||
s.sendMsg = sendMsg
|
||||
}
|
||||
@@ -168,18 +174,39 @@ func WithRpcClient(msgRpcClient *MessageRpcClient) NewNotificationSenderOptions
|
||||
}
|
||||
|
||||
func NewNotificationSender(opts ...NewNotificationSenderOptions) *NotificationSender {
|
||||
notificationSender := &NotificationSender{contentTypeConf: newContentTypeConf(), sessionTypeConf: newSessionTypeConf()}
|
||||
notificationSender := &NotificationSender{
|
||||
contentTypeConf: newContentTypeConf(),
|
||||
sessionTypeConf: newSessionTypeConf(),
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(notificationSender)
|
||||
}
|
||||
return notificationSender
|
||||
}
|
||||
|
||||
func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string, contentType, sesstionType int32, m proto.Message, opts ...utils.OptionsOpt) (err 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 {
|
||||
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
|
||||
}
|
||||
var req msg.SendMsgReq
|
||||
@@ -214,6 +241,12 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message, opts ...utils.OptionsOpt) error {
|
||||
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...)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,11 @@ func NewConversationNotificationSender(msgRpcClient *rpcclient.MessageRpcClient)
|
||||
}
|
||||
|
||||
// SetPrivate调用
|
||||
func (c *ConversationNotificationSender) ConversationSetPrivateNotification(ctx context.Context, sendID, recvID string, isPrivateChat bool) error {
|
||||
func (c *ConversationNotificationSender) ConversationSetPrivateNotification(
|
||||
ctx context.Context,
|
||||
sendID, recvID string,
|
||||
isPrivateChat bool,
|
||||
) error {
|
||||
tips := &sdkws.ConversationSetPrivateTips{
|
||||
RecvID: recvID,
|
||||
SendID: sendID,
|
||||
@@ -35,7 +39,11 @@ func (c *ConversationNotificationSender) ConversationChangeNotification(ctx cont
|
||||
}
|
||||
|
||||
// 会话未读数同步
|
||||
func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(ctx context.Context, userID, conversationID string, unreadCountTime, hasReadSeq int64) error {
|
||||
func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(
|
||||
ctx context.Context,
|
||||
userID, conversationID string,
|
||||
unreadCountTime, hasReadSeq int64,
|
||||
) error {
|
||||
tips := &sdkws.ConversationHasReadTips{
|
||||
UserID: userID,
|
||||
ConversationID: conversationID,
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
@@ -12,7 +14,6 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type ExtendMsgNotificationSender struct {
|
||||
@@ -23,8 +24,16 @@ func NewExtendMsgNotificationSender(client discoveryregistry.SvcDiscoveryRegistr
|
||||
return &ExtendMsgNotificationSender{}
|
||||
}
|
||||
|
||||
func (e *ExtendMsgNotificationSender) ExtendMessageUpdatedNotification(ctx context.Context, sendID string, conversationID string, sessionType int32,
|
||||
req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||
func (e *ExtendMsgNotificationSender) ExtendMessageUpdatedNotification(
|
||||
ctx context.Context,
|
||||
sendID string,
|
||||
conversationID string,
|
||||
sessionType int32,
|
||||
req *msg.SetMessageReactionExtensionsReq,
|
||||
resp *msg.SetMessageReactionExtensionsResp,
|
||||
isHistory bool,
|
||||
isReactionFromCache bool,
|
||||
) {
|
||||
var content sdkws.ReactionMessageModifierNotification
|
||||
content.ConversationID = req.ConversationID
|
||||
content.OpUserID = mcontext.GetOpUserID(ctx)
|
||||
@@ -43,10 +52,28 @@ func (e *ExtendMsgNotificationSender) ExtendMessageUpdatedNotification(ctx conte
|
||||
content.IsReact = resp.IsReact
|
||||
content.IsExternalExtensions = req.IsExternalExtensions
|
||||
content.MsgFirstModifyTime = resp.MsgFirstModifyTime
|
||||
e.messageReactionSender(ctx, sendID, conversationID, sessionType, constant.ReactionMessageModifier, &content, isHistory, isReactionFromCache)
|
||||
e.messageReactionSender(
|
||||
ctx,
|
||||
sendID,
|
||||
conversationID,
|
||||
sessionType,
|
||||
constant.ReactionMessageModifier,
|
||||
&content,
|
||||
isHistory,
|
||||
isReactionFromCache,
|
||||
)
|
||||
}
|
||||
func (e *ExtendMsgNotificationSender) ExtendMessageDeleteNotification(ctx context.Context, sendID string, conversationID string, sessionType int32,
|
||||
req *msg.DeleteMessagesReactionExtensionsReq, resp *msg.DeleteMessagesReactionExtensionsResp, isHistory bool, isReactionFromCache bool) {
|
||||
|
||||
func (e *ExtendMsgNotificationSender) ExtendMessageDeleteNotification(
|
||||
ctx context.Context,
|
||||
sendID string,
|
||||
conversationID string,
|
||||
sessionType int32,
|
||||
req *msg.DeleteMessagesReactionExtensionsReq,
|
||||
resp *msg.DeleteMessagesReactionExtensionsResp,
|
||||
isHistory bool,
|
||||
isReactionFromCache bool,
|
||||
) {
|
||||
var content sdkws.ReactionMessageDeleteNotification
|
||||
content.ConversationID = req.ConversationID
|
||||
content.OpUserID = req.OpUserID
|
||||
@@ -63,9 +90,27 @@ func (e *ExtendMsgNotificationSender) ExtendMessageDeleteNotification(ctx contex
|
||||
content.SuccessReactionExtensions = keyMap
|
||||
content.ClientMsgID = req.ClientMsgID
|
||||
content.MsgFirstModifyTime = req.MsgFirstModifyTime
|
||||
e.messageReactionSender(ctx, sendID, conversationID, sessionType, constant.ReactionMessageDeleter, &content, isHistory, isReactionFromCache)
|
||||
e.messageReactionSender(
|
||||
ctx,
|
||||
sendID,
|
||||
conversationID,
|
||||
sessionType,
|
||||
constant.ReactionMessageDeleter,
|
||||
&content,
|
||||
isHistory,
|
||||
isReactionFromCache,
|
||||
)
|
||||
}
|
||||
func (e *ExtendMsgNotificationSender) messageReactionSender(ctx context.Context, sendID string, conversationID string, sessionType, contentType int32, m proto.Message, isHistory bool, isReactionFromCache bool) error {
|
||||
|
||||
func (e *ExtendMsgNotificationSender) messageReactionSender(
|
||||
ctx context.Context,
|
||||
sendID string,
|
||||
conversationID string,
|
||||
sessionType, contentType int32,
|
||||
m proto.Message,
|
||||
isHistory bool,
|
||||
isReactionFromCache bool,
|
||||
) error {
|
||||
options := make(map[string]bool, 5)
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||
|
||||
@@ -30,7 +30,9 @@ func WithFriendDB(db controller.FriendDatabase) friendNotificationSenderOptions
|
||||
}
|
||||
}
|
||||
|
||||
func WithDBFunc(fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error)) friendNotificationSenderOptions {
|
||||
func WithDBFunc(
|
||||
fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error),
|
||||
) friendNotificationSenderOptions {
|
||||
return func(s *FriendNotificationSender) {
|
||||
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
|
||||
users, err := fn(ctx, userIDs)
|
||||
@@ -46,7 +48,9 @@ func WithDBFunc(fn func(ctx context.Context, userIDs []string) (users []*relatio
|
||||
}
|
||||
}
|
||||
|
||||
func WithRpcFunc(fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error)) friendNotificationSenderOptions {
|
||||
func WithRpcFunc(
|
||||
fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error),
|
||||
) friendNotificationSenderOptions {
|
||||
return func(s *FriendNotificationSender) {
|
||||
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
|
||||
users, err := fn(ctx, userIDs)
|
||||
@@ -62,7 +66,10 @@ func WithRpcFunc(fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserIn
|
||||
}
|
||||
}
|
||||
|
||||
func NewFriendNotificationSender(msgRpcClient *rpcclient.MessageRpcClient, opts ...friendNotificationSenderOptions) *FriendNotificationSender {
|
||||
func NewFriendNotificationSender(
|
||||
msgRpcClient *rpcclient.MessageRpcClient,
|
||||
opts ...friendNotificationSenderOptions,
|
||||
) *FriendNotificationSender {
|
||||
f := &FriendNotificationSender{
|
||||
NotificationSender: rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient)),
|
||||
}
|
||||
@@ -72,7 +79,10 @@ func NewFriendNotificationSender(msgRpcClient *rpcclient.MessageRpcClient, opts
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *FriendNotificationSender) getUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
|
||||
func (f *FriendNotificationSender) getUsersInfoMap(
|
||||
ctx context.Context,
|
||||
userIDs []string,
|
||||
) (map[string]*sdkws.UserInfo, error) {
|
||||
users, err := f.getUsersInfo(ctx, userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -84,7 +94,10 @@ func (f *FriendNotificationSender) getUsersInfoMap(ctx context.Context, userIDs
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (f *FriendNotificationSender) getFromToUserNickname(ctx context.Context, fromUserID, toUserID string) (string, string, error) {
|
||||
func (f *FriendNotificationSender) getFromToUserNickname(
|
||||
ctx context.Context,
|
||||
fromUserID, toUserID string,
|
||||
) (string, string, error) {
|
||||
users, err := f.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
|
||||
if err != nil {
|
||||
return "", "", nil
|
||||
@@ -97,7 +110,10 @@ func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Conte
|
||||
return f.Notification(ctx, mcontext.GetOpUserID(ctx), changedUserID, constant.UserInfoUpdatedNotification, &tips)
|
||||
}
|
||||
|
||||
func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) error {
|
||||
func (f *FriendNotificationSender) FriendApplicationAddNotification(
|
||||
ctx context.Context,
|
||||
req *pbFriend.ApplyToAddFriendReq,
|
||||
) error {
|
||||
tips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.FromUserID,
|
||||
ToUserID: req.ToUserID,
|
||||
@@ -105,7 +121,10 @@ func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.
|
||||
return f.Notification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &tips)
|
||||
}
|
||||
|
||||
func (c *FriendNotificationSender) FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) error {
|
||||
func (c *FriendNotificationSender) FriendApplicationAgreedNotification(
|
||||
ctx context.Context,
|
||||
req *pbFriend.RespondFriendApplyReq,
|
||||
) error {
|
||||
tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.FromUserID,
|
||||
ToUserID: req.ToUserID,
|
||||
@@ -113,7 +132,10 @@ func (c *FriendNotificationSender) FriendApplicationAgreedNotification(ctx conte
|
||||
return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips)
|
||||
}
|
||||
|
||||
func (c *FriendNotificationSender) FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) error {
|
||||
func (c *FriendNotificationSender) FriendApplicationRefusedNotification(
|
||||
ctx context.Context,
|
||||
req *pbFriend.RespondFriendApplyReq,
|
||||
) error {
|
||||
tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.FromUserID,
|
||||
ToUserID: req.ToUserID,
|
||||
@@ -121,7 +143,10 @@ func (c *FriendNotificationSender) FriendApplicationRefusedNotification(ctx cont
|
||||
return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &tips)
|
||||
}
|
||||
|
||||
func (c *FriendNotificationSender) FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) error {
|
||||
func (c *FriendNotificationSender) FriendAddedNotification(
|
||||
ctx context.Context,
|
||||
operationID, opUserID, fromUserID, toUserID string,
|
||||
) error {
|
||||
tips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}}
|
||||
user, err := c.getUsersInfo(ctx, []string{opUserID})
|
||||
if err != nil {
|
||||
@@ -172,7 +197,11 @@ func (c *FriendNotificationSender) BlackDeletedNotification(ctx context.Context,
|
||||
c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
|
||||
}
|
||||
|
||||
func (c *FriendNotificationSender) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string) {
|
||||
func (c *FriendNotificationSender) FriendInfoUpdatedNotification(
|
||||
ctx context.Context,
|
||||
changedUserID string,
|
||||
needNotifiedUserID string,
|
||||
) {
|
||||
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
|
||||
c.Notification(ctx, mcontext.GetOpUserID(ctx), needNotifiedUserID, constant.FriendInfoUpdatedNotification, &tips)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,11 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||
)
|
||||
|
||||
func NewGroupNotificationSender(db controller.GroupDatabase, msgRpcClient *rpcclient.MessageRpcClient, fn func(ctx context.Context, userIDs []string) ([]CommonUser, error)) *GroupNotificationSender {
|
||||
func NewGroupNotificationSender(
|
||||
db controller.GroupDatabase,
|
||||
msgRpcClient *rpcclient.MessageRpcClient,
|
||||
fn func(ctx context.Context, userIDs []string) ([]CommonUser, error),
|
||||
) *GroupNotificationSender {
|
||||
return &GroupNotificationSender{
|
||||
NotificationSender: rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient)),
|
||||
getUsersInfo: fn,
|
||||
@@ -80,7 +84,11 @@ func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID stri
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID string, userIDs []string) ([]*sdkws.GroupMemberFullInfo, error) {
|
||||
func (g *GroupNotificationSender) getGroupMembers(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userIDs []string,
|
||||
) ([]*sdkws.GroupMemberFullInfo, error) {
|
||||
members, err := g.db.FindGroupMember(ctx, []string{groupID}, userIDs, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -95,7 +103,9 @@ func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID s
|
||||
for _, member := range members {
|
||||
user, ok := users[member.UserID]
|
||||
if !ok {
|
||||
return nil, errs.ErrUserIDNotFound.Wrap(fmt.Sprintf("group %s member %s not in user", member.GroupID, member.UserID))
|
||||
return nil, errs.ErrUserIDNotFound.Wrap(
|
||||
fmt.Sprintf("group %s member %s not in user", member.GroupID, member.UserID),
|
||||
)
|
||||
}
|
||||
if member.Nickname == "" {
|
||||
member.Nickname = user.Nickname
|
||||
@@ -117,7 +127,11 @@ func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID s
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) getGroupMemberMap(ctx context.Context, groupID string, userIDs []string) (map[string]*sdkws.GroupMemberFullInfo, error) {
|
||||
func (g *GroupNotificationSender) getGroupMemberMap(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userIDs []string,
|
||||
) (map[string]*sdkws.GroupMemberFullInfo, error) {
|
||||
members, err := g.getGroupMembers(ctx, groupID, userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -129,7 +143,11 @@ func (g *GroupNotificationSender) getGroupMemberMap(ctx context.Context, groupID
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) getGroupMember(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) {
|
||||
func (g *GroupNotificationSender) getGroupMember(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userID string,
|
||||
) (*sdkws.GroupMemberFullInfo, error) {
|
||||
members, err := g.getGroupMembers(ctx, groupID, []string{userID})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -149,7 +167,11 @@ func (g *GroupNotificationSender) getGroupOwnerAndAdminUserID(ctx context.Contex
|
||||
return utils.Slice(members, fn), nil
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) groupDB2PB(group *relation.GroupModel, ownerUserID string, memberCount uint32) *sdkws.GroupInfo {
|
||||
func (g *GroupNotificationSender) groupDB2PB(
|
||||
group *relation.GroupModel,
|
||||
ownerUserID string,
|
||||
memberCount uint32,
|
||||
) *sdkws.GroupInfo {
|
||||
return &sdkws.GroupInfo{
|
||||
GroupID: group.GroupID,
|
||||
GroupName: group.GroupName,
|
||||
@@ -171,7 +193,10 @@ func (g *GroupNotificationSender) groupDB2PB(group *relation.GroupModel, ownerUs
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberModel, appMangerLevel int32) *sdkws.GroupMemberFullInfo {
|
||||
func (g *GroupNotificationSender) groupMemberDB2PB(
|
||||
member *relation.GroupMemberModel,
|
||||
appMangerLevel int32,
|
||||
) *sdkws.GroupMemberFullInfo {
|
||||
return &sdkws.GroupMemberFullInfo{
|
||||
GroupID: member.GroupID,
|
||||
UserID: member.UserID,
|
||||
@@ -188,7 +213,10 @@ func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberM
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
|
||||
func (g *GroupNotificationSender) getUsersInfoMap(
|
||||
ctx context.Context,
|
||||
userIDs []string,
|
||||
) (map[string]*sdkws.UserInfo, error) {
|
||||
users, err := g.getUsersInfo(ctx, userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -200,7 +228,11 @@ func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs [
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws.GroupMemberFullInfo, groupID string) error {
|
||||
func (g *GroupNotificationSender) fillOpUser(
|
||||
ctx context.Context,
|
||||
opUser **sdkws.GroupMemberFullInfo,
|
||||
groupID string,
|
||||
) error {
|
||||
if opUser == nil {
|
||||
return errs.ErrInternalServer.Wrap("**sdkws.GroupMemberFullInfo is nil")
|
||||
}
|
||||
@@ -239,35 +271,62 @@ func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws
|
||||
return nil
|
||||
}
|
||||
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupCreatedNotification, tips)
|
||||
}
|
||||
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNotification, tips)
|
||||
}
|
||||
|
||||
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 {
|
||||
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,
|
||||
)
|
||||
}
|
||||
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips)
|
||||
return g.Notification(
|
||||
ctx,
|
||||
mcontext.GetOpUserID(ctx),
|
||||
tips.Group.GroupID,
|
||||
constant.GroupInfoSetAnnouncementNotification,
|
||||
tips,
|
||||
)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -291,7 +350,10 @@ func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.C
|
||||
return nil
|
||||
}
|
||||
|
||||
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 func() {
|
||||
if err != nil {
|
||||
@@ -306,7 +368,10 @@ func (g *GroupNotificationSender) MemberQuitNotification(ctx context.Context, me
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), member.GroupID, constant.MemberQuitNotification, tips)
|
||||
}
|
||||
|
||||
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 func() {
|
||||
if err != nil {
|
||||
@@ -326,7 +391,13 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
|
||||
return err
|
||||
}
|
||||
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
||||
err = g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationAcceptedNotification, tips)
|
||||
err = g.Notification(
|
||||
ctx,
|
||||
mcontext.GetOpUserID(ctx),
|
||||
userID,
|
||||
constant.GroupApplicationAcceptedNotification,
|
||||
tips,
|
||||
)
|
||||
if err != nil {
|
||||
log.ZError(ctx, "failed", err)
|
||||
}
|
||||
@@ -334,7 +405,10 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
|
||||
return nil
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -348,7 +422,13 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
|
||||
return err
|
||||
}
|
||||
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
||||
err = g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationRejectedNotification, tips)
|
||||
err = g.Notification(
|
||||
ctx,
|
||||
mcontext.GetOpUserID(ctx),
|
||||
userID,
|
||||
constant.GroupApplicationRejectedNotification,
|
||||
tips,
|
||||
)
|
||||
if err != nil {
|
||||
log.ZError(ctx, "failed", err)
|
||||
}
|
||||
@@ -356,7 +436,10 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
|
||||
return nil
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -366,21 +449,38 @@ func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupOwnerTransferredTips{Group: group, OpUser: member[opUserID], NewGroupOwner: member[req.NewOwnerUserID]}
|
||||
tips := &sdkws.GroupOwnerTransferredTips{
|
||||
Group: group,
|
||||
OpUser: member[opUserID],
|
||||
NewGroupOwner: member[req.NewOwnerUserID],
|
||||
}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
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,
|
||||
)
|
||||
}
|
||||
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.MemberKickedNotification, tips)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -399,7 +499,10 @@ func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context,
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberInvitedNotification, tips)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -412,14 +515,21 @@ func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, r
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberEnterNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupDismissedNotification(ctx context.Context, tips *sdkws.GroupDismissedTips) (err error) {
|
||||
func (g *GroupNotificationSender) GroupDismissedNotification(
|
||||
ctx context.Context,
|
||||
tips *sdkws.GroupDismissedTips,
|
||||
) (err error) {
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupDismissedNotification, tips)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -436,7 +546,10 @@ func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Conte
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberMutedNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||
func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(
|
||||
ctx context.Context,
|
||||
groupID, groupMemberUserID string,
|
||||
) (err error) {
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -445,11 +558,21 @@ func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(ctx context
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupMemberCancelMutedTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], MutedUser: user[groupMemberUserID]}
|
||||
tips := &sdkws.GroupMemberCancelMutedTips{
|
||||
Group: group,
|
||||
OpUser: user[mcontext.GetOpUserID(ctx)],
|
||||
MutedUser: user[groupMemberUserID],
|
||||
}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
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,
|
||||
)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupMutedNotification(ctx context.Context, groupID string) (err error) {
|
||||
@@ -490,7 +613,10 @@ func (g *GroupNotificationSender) GroupCancelMutedNotification(ctx context.Conte
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -499,14 +625,21 @@ func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Con
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
|
||||
tips := &sdkws.GroupMemberInfoSetTips{
|
||||
Group: group,
|
||||
OpUser: user[mcontext.GetOpUserID(ctx)],
|
||||
ChangedUser: user[groupMemberUserID],
|
||||
}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberInfoSetNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||
func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(
|
||||
ctx context.Context,
|
||||
groupID, groupMemberUserID string,
|
||||
) (err error) {
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -515,14 +648,27 @@ func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(ctx context.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
|
||||
tips := &sdkws.GroupMemberInfoSetTips{
|
||||
Group: group,
|
||||
OpUser: user[mcontext.GetOpUserID(ctx)],
|
||||
ChangedUser: user[groupMemberUserID],
|
||||
}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
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,
|
||||
)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||
func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(
|
||||
ctx context.Context,
|
||||
groupID, groupMemberUserID string,
|
||||
) (err error) {
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -531,14 +677,28 @@ func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx c
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
|
||||
tips := &sdkws.GroupMemberInfoSetTips{
|
||||
Group: group,
|
||||
OpUser: user[mcontext.GetOpUserID(ctx)],
|
||||
ChangedUser: user[groupMemberUserID],
|
||||
}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToOrdinaryUserNotification, tips)
|
||||
return g.Notification(
|
||||
ctx,
|
||||
mcontext.GetOpUserID(ctx),
|
||||
group.GroupID,
|
||||
constant.GroupMemberSetToOrdinaryUserNotification,
|
||||
tips,
|
||||
)
|
||||
}
|
||||
|
||||
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 func() {
|
||||
if err != nil {
|
||||
|
||||
@@ -3,10 +3,11 @@ package rpcclient
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/push"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Push struct {
|
||||
@@ -33,6 +34,9 @@ func NewPushRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) PushRpcClie
|
||||
return PushRpcClient(*NewPush(discov))
|
||||
}
|
||||
|
||||
func (p *PushRpcClient) DelUserPushToken(ctx context.Context, req *push.DelUserPushTokenReq) (*push.DelUserPushTokenResp, error) {
|
||||
func (p *PushRpcClient) DelUserPushToken(
|
||||
ctx context.Context,
|
||||
req *push.DelUserPushTokenReq,
|
||||
) (*push.DelUserPushTokenResp, error) {
|
||||
return p.Client.DelUserPushToken(ctx, req)
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ package rpcclient
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Third struct {
|
||||
|
||||
+12
-3
@@ -5,6 +5,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
@@ -12,7 +14,6 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
@@ -70,7 +71,11 @@ func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (u *UserRpcClient) GetPublicUserInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.PublicUserInfo, error) {
|
||||
func (u *UserRpcClient) GetPublicUserInfos(
|
||||
ctx context.Context,
|
||||
userIDs []string,
|
||||
complete bool,
|
||||
) ([]*sdkws.PublicUserInfo, error) {
|
||||
users, err := u.GetUsersInfo(ctx, userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -93,7 +98,11 @@ func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*
|
||||
return users[0], nil
|
||||
}
|
||||
|
||||
func (u *UserRpcClient) GetPublicUserInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.PublicUserInfo, error) {
|
||||
func (u *UserRpcClient) GetPublicUserInfoMap(
|
||||
ctx context.Context,
|
||||
userIDs []string,
|
||||
complete bool,
|
||||
) (map[string]*sdkws.PublicUserInfo, error) {
|
||||
users, err := u.GetPublicUserInfos(ctx, userIDs, complete)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user