mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-09 14:07:11 +08:00
fix: fix lint erros in pkg/authverify,pkg/rpcclien
This commit is contained in:
parent
be0f294ec3
commit
db533d9f4e
@ -41,6 +41,7 @@ func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
|
|||||||
if opUserID == ownerUserID {
|
if opUserID == ownerUserID {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return errs.ErrNoPermission.Wrap(utils.GetSelfFuncName())
|
return errs.ErrNoPermission.Wrap(utils.GetSelfFuncName())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ func CheckAdmin(ctx context.Context) error {
|
|||||||
if utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID) {
|
if utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return errs.ErrNoPermission.Wrap(fmt.Sprintf("user %s is not admin userID", mcontext.GetOpUserID(ctx)))
|
return errs.ErrNoPermission.Wrap(fmt.Sprintf("user %s is not admin userID", mcontext.GetOpUserID(ctx)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,5 +76,6 @@ func WsVerifyToken(token, userID string, platformID int) error {
|
|||||||
if claim.PlatformID != platformID {
|
if claim.PlatformID != platformID {
|
||||||
return errs.ErrTokenInvalid.Wrap(fmt.Sprintf("token platform %d != %d", claim.PlatformID, platformID))
|
return errs.ErrTokenInvalid.Wrap(fmt.Sprintf("token platform %d != %d", claim.PlatformID, platformID))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,7 @@ func (c CommonCallbackResp) Parse() error {
|
|||||||
if c.ActionCode != errs.NoError || c.ErrCode != errs.NoError {
|
if c.ActionCode != errs.NoError || c.ErrCode != errs.NoError {
|
||||||
return errs.NewCodeError(int(c.ErrCode), c.ErrMsg).WithDetail(c.ErrDlt)
|
return errs.NewCodeError(int(c.ErrCode), c.ErrMsg).WithDetail(c.ErrDlt)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,7 @@ func NewAuth(discov discoveryregistry.SvcDiscoveryRegistry) *Auth {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
client := auth.NewAuthClient(conn)
|
client := auth.NewAuthClient(conn)
|
||||||
|
|
||||||
return &Auth{discov: discov, conn: conn, Client: client}
|
return &Auth{discov: discov, conn: conn, Client: client}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@ func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry) *Conversatio
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
client := pbconversation.NewConversationClient(conn)
|
client := pbconversation.NewConversationClient(conn)
|
||||||
|
|
||||||
return &Conversation{discov: discov, conn: conn, Client: client}
|
return &Conversation{discov: discov, conn: conn, Client: client}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,26 +57,31 @@ func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Cont
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return conversation.GetConversation().RecvMsgOpt, err
|
return conversation.GetConversation().RecvMsgOpt, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID string) error {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(ctx context.Context, groupID string, userIDs []string) error {
|
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(ctx context.Context, groupID string, userIDs []string) error {
|
||||||
_, err := c.Client.CreateGroupChatConversations(ctx, &pbconversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID})
|
_, err := c.Client.CreateGroupChatConversations(ctx, &pbconversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) SetConversationMaxSeq(ctx context.Context, ownerUserIDs []string, conversationID string, maxSeq int64) error {
|
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})
|
_, err := c.Client.SetConversationMaxSeq(ctx, &pbconversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbconversation.ConversationReq) error {
|
func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbconversation.ConversationReq) error {
|
||||||
_, err := c.Client.SetConversations(ctx, &pbconversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
|
_, err := c.Client.SetConversations(ctx, &pbconversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +90,7 @@ func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUse
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.ConversationIDs, nil
|
return resp.ConversationIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +99,7 @@ func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Conversation, nil
|
return resp.Conversation, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +114,7 @@ func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Con
|
|||||||
if len(resp.Conversations) == 0 {
|
if len(resp.Conversations) == 0 {
|
||||||
return nil, errs.ErrRecordNotFound.Wrap(fmt.Sprintf("conversationIDs: %v not found", conversationIDs))
|
return nil, errs.ErrRecordNotFound.Wrap(fmt.Sprintf("conversationIDs: %v not found", conversationIDs))
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Conversations, nil
|
return resp.Conversations, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,5 +133,6 @@ func (c *ConversationRpcClient) GetConversations(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Conversations, nil
|
return resp.Conversations, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,7 @@ func NewFriend(discov discoveryregistry.SvcDiscoveryRegistry) *Friend {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
client := friend.NewFriendClient(conn)
|
client := friend.NewFriendClient(conn)
|
||||||
|
|
||||||
return &Friend{discov: discov, conn: conn, Client: client}
|
return &Friend{discov: discov, conn: conn, Client: client}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ func (f *FriendRpcClient) GetFriendsInfo(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp = r.FriendsInfo[0]
|
resp = r.FriendsInfo[0]
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +70,7 @@ func (f *FriendRpcClient) IsFriend(ctx context.Context, possibleFriendUserID, us
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.InUser1Friends, nil
|
return resp.InUser1Friends, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +80,7 @@ func (f *FriendRpcClient) GetFriendIDs(ctx context.Context, ownerUserID string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.FriendIDs, nil
|
return resp.FriendIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,5 +89,6 @@ func (b *FriendRpcClient) IsBlocked(ctx context.Context, possibleBlackUserID, us
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.InUser2Blacks, nil
|
return r.InUser2Blacks, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,7 @@ func NewGroup(discov discoveryregistry.SvcDiscoveryRegistry) *Group {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
client := group.NewGroupClient(conn)
|
client := group.NewGroupClient(conn)
|
||||||
|
|
||||||
return &Group{discov: discov, conn: conn, Client: client}
|
return &Group{discov: discov, conn: conn, Client: client}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ func (g *GroupRpcClient) GetGroupInfos(
|
|||||||
return nil, errs.ErrGroupIDNotFound.Wrap(strings.Join(ids, ","))
|
return nil, errs.ErrGroupIDNotFound.Wrap(strings.Join(ids, ","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.GroupInfos, nil
|
return resp.GroupInfos, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +79,7 @@ func (g *GroupRpcClient) GetGroupInfo(ctx context.Context, groupID string) (*sdk
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups[0], nil
|
return groups[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +92,7 @@ func (g *GroupRpcClient) GetGroupInfoMap(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.SliceToMap(groups, func(e *sdkws.GroupInfo) string {
|
return utils.SliceToMap(groups, func(e *sdkws.GroupInfo) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
}), nil
|
}), nil
|
||||||
@ -114,6 +118,7 @@ func (g *GroupRpcClient) GetGroupMemberInfos(
|
|||||||
return nil, errs.ErrNotInGroupYet.Wrap(strings.Join(ids, ","))
|
return nil, errs.ErrNotInGroupYet.Wrap(strings.Join(ids, ","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Members, nil
|
return resp.Members, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +131,7 @@ func (g *GroupRpcClient) GetGroupMemberInfo(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return members[0], nil
|
return members[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +145,7 @@ func (g *GroupRpcClient) GetGroupMemberInfoMap(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.SliceToMap(members, func(e *sdkws.GroupMemberFullInfo) string {
|
return utils.SliceToMap(members, func(e *sdkws.GroupMemberFullInfo) string {
|
||||||
return e.UserID
|
return e.UserID
|
||||||
}), nil
|
}), nil
|
||||||
@ -155,6 +162,7 @@ func (g *GroupRpcClient) GetOwnerAndAdminInfos(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Members, nil
|
return resp.Members, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +171,7 @@ func (g *GroupRpcClient) GetOwnerInfo(ctx context.Context, groupID string) (*sdk
|
|||||||
GroupID: groupID,
|
GroupID: groupID,
|
||||||
RoleLevels: []int32{constant.GroupOwner},
|
RoleLevels: []int32{constant.GroupOwner},
|
||||||
})
|
})
|
||||||
|
|
||||||
return resp.Members[0], err
|
return resp.Members[0], err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,6 +182,7 @@ func (g *GroupRpcClient) GetGroupMemberIDs(ctx context.Context, groupID string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.UserIDs, nil
|
return resp.UserIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +193,7 @@ func (g *GroupRpcClient) GetGroupInfoCache(ctx context.Context, groupID string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.GroupInfo, nil
|
return resp.GroupInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +209,7 @@ func (g *GroupRpcClient) GetGroupMemberCache(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Member, nil
|
return resp.Member, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,6 +218,7 @@ func (g *GroupRpcClient) DismissGroup(ctx context.Context, groupID string) error
|
|||||||
GroupID: groupID,
|
GroupID: groupID,
|
||||||
DeleteMember: true,
|
DeleteMember: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,5 +226,6 @@ func (g *GroupRpcClient) NotificationUserInfoUpdate(ctx context.Context, userID
|
|||||||
_, err := g.Client.NotificationUserInfoUpdate(ctx, &group.NotificationUserInfoUpdateReq{
|
_, err := g.Client.NotificationUserInfoUpdate(ctx, &group.NotificationUserInfoUpdateReq{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
})
|
})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -136,6 +136,7 @@ func NewMessage(discov discoveryregistry.SvcDiscoveryRegistry) *Message {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
client := msg.NewMsgClient(conn)
|
client := msg.NewMsgClient(conn)
|
||||||
|
|
||||||
return &Message{discov: discov, conn: conn, Client: client}
|
return &Message{discov: discov, conn: conn, Client: client}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,16 +148,19 @@ func NewMessageRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) MessageR
|
|||||||
|
|
||||||
func (m *MessageRpcClient) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) {
|
func (m *MessageRpcClient) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) {
|
||||||
resp, err := m.Client.SendMsg(ctx, req)
|
resp, err := m.Client.SendMsg(ctx, req)
|
||||||
|
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqReq) (*sdkws.GetMaxSeqResp, error) {
|
func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqReq) (*sdkws.GetMaxSeqResp, error) {
|
||||||
resp, err := m.Client.GetMaxSeq(ctx, req)
|
resp, err := m.Client.GetMaxSeq(ctx, req)
|
||||||
|
|
||||||
return resp, err
|
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)
|
resp, err := m.Client.PullMessageBySeqs(ctx, req)
|
||||||
|
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +169,7 @@ func (m *MessageRpcClient) GetConversationMaxSeq(ctx context.Context, conversati
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.MaxSeq, nil
|
return resp.MaxSeq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,6 +205,7 @@ func NewNotificationSender(opts ...NotificationSenderOptions) *NotificationSende
|
|||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(notificationSender)
|
opt(notificationSender)
|
||||||
}
|
}
|
||||||
|
|
||||||
return notificationSender
|
return notificationSender
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,6 +226,7 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
|
|||||||
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{}
|
||||||
@ -229,7 +236,8 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
|
|||||||
var req msg.SendMsgReq
|
var req msg.SendMsgReq
|
||||||
var msg sdkws.MsgData
|
var msg sdkws.MsgData
|
||||||
if notificationOpt.WithRpcGetUsername && s.getUserInfo != nil {
|
if notificationOpt.WithRpcGetUsername && s.getUserInfo != nil {
|
||||||
userInfo, err := s.getUserInfo(ctx, sendID)
|
var userInfo *sdkws.UserInfo
|
||||||
|
userInfo, err = s.getUserInfo(ctx, sendID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "getUserInfo failed", err, "sendID", sendID)
|
log.ZWarn(ctx, "getUserInfo failed", err, "sendID", sendID)
|
||||||
} else {
|
} else {
|
||||||
@ -267,6 +275,7 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,7 @@ func (c *ConversationNotificationSender) ConversationSetPrivateNotification(ctx
|
|||||||
IsPrivate: isPrivateChat,
|
IsPrivate: isPrivateChat,
|
||||||
ConversationID: conversationID,
|
ConversationID: conversationID,
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Notification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, tips)
|
return c.Notification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +51,7 @@ func (c *ConversationNotificationSender) ConversationChangeNotification(ctx cont
|
|||||||
UserID: userID,
|
UserID: userID,
|
||||||
ConversationIDList: conversationIDs,
|
ConversationIDList: conversationIDs,
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Notification(ctx, userID, userID, constant.ConversationChangeNotification, tips)
|
return c.Notification(ctx, userID, userID, constant.ConversationChangeNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,5 +67,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)
|
||||||
}
|
}
|
||||||
@ -57,6 +57,7 @@ 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
|
||||||
@ -75,6 +76,7 @@ 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
|
||||||
@ -91,6 +93,7 @@ func NewFriendNotificationSender(
|
|||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(f)
|
opt(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,22 +109,13 @@ 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
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FriendNotificationSender) getFromToUserNickname(
|
return result, nil
|
||||||
ctx context.Context,
|
|
||||||
fromUserID, toUserID string,
|
|
||||||
) (string, string, error) {
|
|
||||||
users, err := f.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
|
|
||||||
if err != nil {
|
|
||||||
return "", "", nil
|
|
||||||
}
|
|
||||||
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,6 +127,7 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +139,7 @@ func (f *FriendNotificationSender) FriendApplicationAgreedNotification(
|
|||||||
FromUserID: req.FromUserID,
|
FromUserID: req.FromUserID,
|
||||||
ToUserID: req.ToUserID,
|
ToUserID: req.ToUserID,
|
||||||
}, HandleMsg: req.HandleMsg}
|
}, HandleMsg: req.HandleMsg}
|
||||||
|
|
||||||
return f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips)
|
return f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,6 +151,7 @@ func (f *FriendNotificationSender) FriendApplicationRefusedNotification(
|
|||||||
FromUserID: req.FromUserID,
|
FromUserID: req.FromUserID,
|
||||||
ToUserID: req.ToUserID,
|
ToUserID: req.ToUserID,
|
||||||
}, HandleMsg: req.HandleMsg}
|
}, HandleMsg: req.HandleMsg}
|
||||||
|
|
||||||
return f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &tips)
|
return f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +176,7 @@ func (f *FriendNotificationSender) FriendAddedNotification(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return f.Notification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &tips)
|
return f.Notification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +185,7 @@ func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context
|
|||||||
FromUserID: req.OwnerUserID,
|
FromUserID: req.OwnerUserID,
|
||||||
ToUserID: req.FriendUserID,
|
ToUserID: req.FriendUserID,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
return f.Notification(ctx, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &tips)
|
return f.Notification(ctx, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +193,7 @@ func (f *FriendNotificationSender) FriendRemarkSetNotification(ctx context.Conte
|
|||||||
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 f.Notification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &tips)
|
return f.Notification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,6 +201,7 @@ func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, r
|
|||||||
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 f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &tips)
|
return f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +210,10 @@ func (f *FriendNotificationSender) BlackDeletedNotification(ctx context.Context,
|
|||||||
FromUserID: req.OwnerUserID,
|
FromUserID: req.OwnerUserID,
|
||||||
ToUserID: req.BlackUserID,
|
ToUserID: req.BlackUserID,
|
||||||
}}
|
}}
|
||||||
f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
|
err := f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendNotificationSender) FriendInfoUpdatedNotification(
|
func (f *FriendNotificationSender) FriendInfoUpdatedNotification(
|
||||||
@ -218,5 +222,8 @@ func (f *FriendNotificationSender) FriendInfoUpdatedNotification(
|
|||||||
needNotifiedUserID string,
|
needNotifiedUserID string,
|
||||||
) {
|
) {
|
||||||
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
|
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
|
||||||
f.Notification(ctx, mcontext.GetOpUserID(ctx), needNotifiedUserID, constant.FriendInfoUpdatedNotification, &tips)
|
err := f.Notification(ctx, mcontext.GetOpUserID(ctx), needNotifiedUserID, constant.FriendInfoUpdatedNotification, &tips)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
118
pkg/rpcclient/notification/group.go
Normal file → Executable file
118
pkg/rpcclient/notification/group.go
Normal file → Executable file
@ -60,6 +60,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(),
|
||||||
@ -68,6 +69,23 @@ func (g *GroupNotificationSender) getUser(ctx context.Context, userID string) (*
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberModel, appMangerLevel int32) *sdkws.GroupMemberFullInfo {
|
||||||
|
return &sdkws.GroupMemberFullInfo{
|
||||||
|
GroupID: member.GroupID,
|
||||||
|
UserID: member.UserID,
|
||||||
|
RoleLevel: member.RoleLevel,
|
||||||
|
JoinTime: member.JoinTime.UnixMilli(),
|
||||||
|
Nickname: member.Nickname,
|
||||||
|
FaceURL: member.FaceURL,
|
||||||
|
AppMangerLevel: appMangerLevel,
|
||||||
|
JoinSource: member.JoinSource,
|
||||||
|
OperatorUserID: member.OperatorUserID,
|
||||||
|
Ex: member.Ex,
|
||||||
|
MuteEndTime: member.MuteEndTime.UnixMilli(),
|
||||||
|
InviterUserID: member.InviterUserID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) {
|
func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) {
|
||||||
gm, err := g.db.TakeGroup(ctx, groupID)
|
gm, err := g.db.TakeGroup(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -81,6 +99,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,
|
||||||
@ -148,6 +167,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +179,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,48 +189,10 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) groupDB2PB(group *relation.GroupModel, ownerUserID string, memberCount uint32) *sdkws.GroupInfo {
|
|
||||||
return &sdkws.GroupInfo{
|
|
||||||
GroupID: group.GroupID,
|
|
||||||
GroupName: group.GroupName,
|
|
||||||
Notification: group.Notification,
|
|
||||||
Introduction: group.Introduction,
|
|
||||||
FaceURL: group.FaceURL,
|
|
||||||
OwnerUserID: ownerUserID,
|
|
||||||
CreateTime: group.CreateTime.UnixMilli(),
|
|
||||||
MemberCount: memberCount,
|
|
||||||
Ex: group.Ex,
|
|
||||||
Status: group.Status,
|
|
||||||
CreatorUserID: group.CreatorUserID,
|
|
||||||
GroupType: group.GroupType,
|
|
||||||
NeedVerification: group.NeedVerification,
|
|
||||||
LookMemberInfo: group.LookMemberInfo,
|
|
||||||
ApplyMemberFriend: group.ApplyMemberFriend,
|
|
||||||
NotificationUpdateTime: group.NotificationUpdateTime.UnixMilli(),
|
|
||||||
NotificationUserID: group.NotificationUserID,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberModel, appMangerLevel int32) *sdkws.GroupMemberFullInfo {
|
|
||||||
return &sdkws.GroupMemberFullInfo{
|
|
||||||
GroupID: member.GroupID,
|
|
||||||
UserID: member.UserID,
|
|
||||||
RoleLevel: member.RoleLevel,
|
|
||||||
JoinTime: member.JoinTime.UnixMilli(),
|
|
||||||
Nickname: member.Nickname,
|
|
||||||
FaceURL: member.FaceURL,
|
|
||||||
AppMangerLevel: appMangerLevel,
|
|
||||||
JoinSource: member.JoinSource,
|
|
||||||
OperatorUserID: member.OperatorUserID,
|
|
||||||
Ex: member.Ex,
|
|
||||||
MuteEndTime: member.MuteEndTime.UnixMilli(),
|
|
||||||
InviterUserID: member.InviterUserID,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
users, err := g.getUsersInfo(ctx, userIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -219,6 +202,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,21 +220,31 @@ func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
userID := mcontext.GetOpUserID(ctx)
|
userID := mcontext.GetOpUserID(ctx)
|
||||||
if groupID != "" {
|
getOpUser := func(g *GroupNotificationSender, groupID, userID string) (opUser *sdkws.GroupMemberFullInfo, err error) {
|
||||||
if authverify.IsManagerUserID(userID) {
|
if authverify.IsManagerUserID(userID) {
|
||||||
*opUser = &sdkws.GroupMemberFullInfo{
|
opUser = &sdkws.GroupMemberFullInfo{
|
||||||
GroupID: groupID,
|
GroupID: groupID,
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
RoleLevel: constant.GroupAdmin,
|
RoleLevel: constant.GroupAdmin,
|
||||||
AppMangerLevel: constant.AppAdmin,
|
AppMangerLevel: constant.AppAdmin,
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
member, err := g.db.TakeGroupMember(ctx, groupID, userID)
|
return opUser, nil
|
||||||
if err == nil {
|
}
|
||||||
*opUser = g.groupMemberDB2PB(member, 0)
|
var member *relation.GroupMemberModel
|
||||||
} else if !errs.ErrRecordNotFound.Is(err) {
|
member, err = g.db.TakeGroupMember(ctx, groupID, userID)
|
||||||
return err
|
if err == nil {
|
||||||
}
|
opUser = g.groupMemberDB2PB(member, 0)
|
||||||
|
} else if !errs.ErrRecordNotFound.Is(err) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return opUser, nil
|
||||||
|
}
|
||||||
|
if groupID != "" {
|
||||||
|
*opUser, err = getOpUser(g, groupID, userID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
user, err := g.getUser(ctx, userID)
|
user, err := g.getUser(ctx, userID)
|
||||||
@ -273,6 +267,7 @@ func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws
|
|||||||
(*opUser).FaceURL = user.FaceURL
|
(*opUser).FaceURL = user.FaceURL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,6 +281,7 @@ func (g *GroupNotificationSender) GroupCreatedNotification(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.GroupCreatedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupCreatedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,6 +295,7 @@ func (g *GroupNotificationSender) GroupInfoSetNotification(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.GroupInfoSetNotification, tips, rpcclient.WithRpcGetUserName())
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNotification, tips, rpcclient.WithRpcGetUserName())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,6 +309,7 @@ func (g *GroupNotificationSender) GroupInfoSetNameNotification(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), tips.Group.GroupID, constant.GroupInfoSetNameNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNameNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,6 +323,7 @@ func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(ctx 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), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, rpcclient.WithRpcGetUserName())
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, rpcclient.WithRpcGetUserName())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,6 +354,7 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,6 +370,7 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,7 +390,8 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, HandleMsg: req.HandledMsg, ReceiverAs: 1}
|
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, HandleMsg: req.HandledMsg, ReceiverAs: 1}
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
err = g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
||||||
@ -398,6 +400,7 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
|
|||||||
log.ZError(ctx, "failed", err)
|
log.ZError(ctx, "failed", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +420,8 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tips := &sdkws.GroupApplicationRejectedTips{Group: group, HandleMsg: req.HandledMsg}
|
tips := &sdkws.GroupApplicationRejectedTips{Group: group, HandleMsg: req.HandledMsg}
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
err = g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
||||||
@ -426,6 +430,7 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
|
|||||||
log.ZError(ctx, "failed", err)
|
log.ZError(ctx, "failed", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,6 +454,7 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,6 +468,7 @@ func (g *GroupNotificationSender) MemberKickedNotification(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.MemberKickedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.MemberKickedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,6 +494,7 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,6 +514,7 @@ func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, g
|
|||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,6 +528,7 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,6 +554,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,6 +577,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,6 +603,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,6 +629,7 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -638,6 +652,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,6 +675,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,6 +698,7 @@ func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx c
|
|||||||
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.GroupMemberSetToOrdinaryUserNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToOrdinaryUserNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,5 +710,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
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,7 @@ func (m *MsgNotificationSender) UserDeleteMsgsNotification(ctx context.Context,
|
|||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,5 +48,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)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,6 +52,7 @@ func WithUserFunc(
|
|||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
result = append(result, user)
|
result = append(result, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
u.getUsersInfo = f
|
u.getUsersInfo = f
|
||||||
@ -68,34 +69,37 @@ func NewUserNotificationSender(
|
|||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(f)
|
opt(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserNotificationSender) getUsersInfoMap(
|
// func (u *UserNotificationSender) getUsersInfoMap(
|
||||||
ctx context.Context,
|
// ctx context.Context,
|
||||||
userIDs []string,
|
// userIDs []string,
|
||||||
) (map[string]*sdkws.UserInfo, error) {
|
// ) (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
|
||||||
}
|
// }
|
||||||
result := make(map[string]*sdkws.UserInfo)
|
// result := make(map[string]*sdkws.UserInfo)
|
||||||
for _, user := range users {
|
// for _, user := range users {
|
||||||
result[user.GetUserID()] = user.(*sdkws.UserInfo)
|
// result[user.GetUserID()] = user.(*sdkws.UserInfo)
|
||||||
}
|
// }
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *UserNotificationSender) getFromToUserNickname(
|
// return result, nil
|
||||||
ctx context.Context,
|
// }
|
||||||
fromUserID, toUserID string,
|
|
||||||
) (string, string, error) {
|
// func (u *UserNotificationSender) getFromToUserNickname(
|
||||||
users, err := u.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
|
// ctx context.Context,
|
||||||
if err != nil {
|
// fromUserID, toUserID string,
|
||||||
return "", "", nil
|
// ) (string, string, error) {
|
||||||
}
|
// users, err := u.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
|
||||||
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
|
// if err != nil {
|
||||||
}
|
// return "", "", err
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return users[fromUserID].Nickname, users[toUserID].Nickname, nil
|
||||||
|
// }
|
||||||
|
|
||||||
func (u *UserNotificationSender) UserStatusChangeNotification(
|
func (u *UserNotificationSender) UserStatusChangeNotification(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
|
|||||||
@ -36,6 +36,7 @@ func NewPush(discov discoveryregistry.SvcDiscoveryRegistry) *Push {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Push{
|
return &Push{
|
||||||
discov: discov,
|
discov: discov,
|
||||||
conn: conn,
|
conn: conn,
|
||||||
|
|||||||
9
pkg/rpcclient/third.go
Normal file → Executable file
9
pkg/rpcclient/third.go
Normal file → Executable file
@ -42,14 +42,13 @@ func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
client := third.NewThirdClient(conn)
|
client := third.NewThirdClient(conn)
|
||||||
minioClient, err := minioInit()
|
minioClient, _ := 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{}
|
initUrl := config.Config.Object.Minio.Endpoint
|
||||||
var initUrl string
|
|
||||||
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
|
||||||
@ -63,9 +62,11 @@ func minioInit() (*minio.Client, error) {
|
|||||||
} else if minioUrl.Scheme == "https" {
|
} else if minioUrl.Scheme == "https" {
|
||||||
opts.Secure = true
|
opts.Secure = true
|
||||||
}
|
}
|
||||||
|
var minioClient *minio.Client
|
||||||
minioClient, err = minio.New(minioUrl.Host, opts)
|
minioClient, err = minio.New(minioUrl.Host, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return minioClient, nil
|
return minioClient, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,7 @@ func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
|
|||||||
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}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ type UserRpcClient User
|
|||||||
// NewUserRpcClientByUser initializes a UserRpcClient based on the provided User instance.
|
// NewUserRpcClientByUser initializes a UserRpcClient based on the provided User instance.
|
||||||
func NewUserRpcClientByUser(user *User) *UserRpcClient {
|
func NewUserRpcClientByUser(user *User) *UserRpcClient {
|
||||||
rpc := UserRpcClient(*user)
|
rpc := UserRpcClient(*user)
|
||||||
|
|
||||||
return &rpc
|
return &rpc
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +77,7 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +87,7 @@ func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return users[0], nil
|
return users[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,6 +97,7 @@ func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (
|
|||||||
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
|
||||||
@ -108,6 +113,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,
|
||||||
@ -124,6 +130,7 @@ func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return users[0], nil
|
return users[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +144,7 @@ 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
|
||||||
@ -150,6 +158,7 @@ func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID stri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.GlobalRecvMsgOpt, nil
|
return resp.GlobalRecvMsgOpt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +168,7 @@ func (u *UserRpcClient) Access(ctx context.Context, ownerUserID string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return authverify.CheckAccessV3(ctx, ownerUserID)
|
return authverify.CheckAccessV3(ctx, ownerUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +178,7 @@ func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumbe
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.UserIDs, nil
|
return resp.UserIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,5 +188,6 @@ func (u *UserRpcClient) SetUserStatus(ctx context.Context, userID string, status
|
|||||||
UserID: userID,
|
UserID: userID,
|
||||||
Status: status, PlatformID: int32(platformID),
|
Status: status, PlatformID: int32(platformID),
|
||||||
})
|
})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user