mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-09 03:25:59 +08:00
fix: Fix Bug related issues with OpenIM actions PR (#921)
* feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add test changelog file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add scripts test and format Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
pbConversation "github.com/OpenIMSDK/protocol/conversation"
|
||||
pbconversation "github.com/OpenIMSDK/protocol/conversation"
|
||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
type Conversation struct {
|
||||
Client pbConversation.ConversationClient
|
||||
Client pbconversation.ConversationClient
|
||||
conn grpc.ClientConnInterface
|
||||
discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
@@ -38,7 +38,7 @@ func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry) *Conversatio
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := pbConversation.NewConversationClient(conn)
|
||||
client := pbconversation.NewConversationClient(conn)
|
||||
return &Conversation{discov: discov, conn: conn, Client: client}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func NewConversationRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) Con
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
|
||||
var req pbConversation.GetConversationReq
|
||||
var req pbconversation.GetConversationReq
|
||||
req.OwnerUserID = userID
|
||||
req.ConversationID = conversationID
|
||||
conversation, err := c.Client.GetConversation(ctx, &req)
|
||||
@@ -60,46 +60,46 @@ 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})
|
||||
_, 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})
|
||||
_, 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
|
||||
}
|
||||
|
||||
func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUserID string) ([]string, error) {
|
||||
resp, err := c.Client.GetConversationIDs(ctx, &pbConversation.GetConversationIDsReq{UserID: ownerUserID})
|
||||
resp, err := c.Client.GetConversationIDs(ctx, &pbconversation.GetConversationIDsReq{UserID: ownerUserID})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
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) {
|
||||
func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*pbconversation.Conversation, error) {
|
||||
if len(conversationIDs) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
resp, err := c.Client.GetConversationsByConversationID(ctx, &pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs})
|
||||
resp, err := c.Client.GetConversationsByConversationID(ctx, &pbconversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -113,13 +113,13 @@ func (c *ConversationRpcClient) GetConversations(
|
||||
ctx context.Context,
|
||||
ownerUserID string,
|
||||
conversationIDs []string,
|
||||
) ([]*pbConversation.Conversation, error) {
|
||||
) ([]*pbconversation.Conversation, error) {
|
||||
if len(conversationIDs) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
resp, err := c.Client.GetConversations(
|
||||
ctx,
|
||||
&pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs},
|
||||
&pbconversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -20,12 +20,12 @@ import (
|
||||
"github.com/OpenIMSDK/tools/mcontext"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
pbFriend "github.com/OpenIMSDK/protocol/friend"
|
||||
pbfriend "github.com/OpenIMSDK/protocol/friend"
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||
)
|
||||
|
||||
@@ -46,7 +46,7 @@ func WithFriendDB(db controller.FriendDatabase) friendNotificationSenderOptions
|
||||
}
|
||||
|
||||
func WithDBFunc(
|
||||
fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error),
|
||||
fn func(ctx context.Context, userIDs []string) (users []*relationtb.UserModel, err error),
|
||||
) friendNotificationSenderOptions {
|
||||
return func(s *FriendNotificationSender) {
|
||||
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
|
||||
@@ -127,7 +127,7 @@ func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Conte
|
||||
|
||||
func (f *FriendNotificationSender) FriendApplicationAddNotification(
|
||||
ctx context.Context,
|
||||
req *pbFriend.ApplyToAddFriendReq,
|
||||
req *pbfriend.ApplyToAddFriendReq,
|
||||
) error {
|
||||
tips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.FromUserID,
|
||||
@@ -138,7 +138,7 @@ func (f *FriendNotificationSender) FriendApplicationAddNotification(
|
||||
|
||||
func (f *FriendNotificationSender) FriendApplicationAgreedNotification(
|
||||
ctx context.Context,
|
||||
req *pbFriend.RespondFriendApplyReq,
|
||||
req *pbfriend.RespondFriendApplyReq,
|
||||
) error {
|
||||
tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.FromUserID,
|
||||
@@ -149,7 +149,7 @@ func (f *FriendNotificationSender) FriendApplicationAgreedNotification(
|
||||
|
||||
func (f *FriendNotificationSender) FriendApplicationRefusedNotification(
|
||||
ctx context.Context,
|
||||
req *pbFriend.RespondFriendApplyReq,
|
||||
req *pbfriend.RespondFriendApplyReq,
|
||||
) error {
|
||||
tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.FromUserID,
|
||||
@@ -182,7 +182,7 @@ func (f *FriendNotificationSender) FriendAddedNotification(
|
||||
return f.Notification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &tips)
|
||||
}
|
||||
|
||||
func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) error {
|
||||
func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *pbfriend.DeleteFriendReq) error {
|
||||
tips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.OwnerUserID,
|
||||
ToUserID: req.FriendUserID,
|
||||
@@ -197,14 +197,14 @@ func (f *FriendNotificationSender) FriendRemarkSetNotification(ctx context.Conte
|
||||
return f.Notification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &tips)
|
||||
}
|
||||
|
||||
func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) error {
|
||||
func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *pbfriend.AddBlackReq) error {
|
||||
tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
tips.FromToUserID.FromUserID = req.OwnerUserID
|
||||
tips.FromToUserID.ToUserID = req.BlackUserID
|
||||
return f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &tips)
|
||||
}
|
||||
|
||||
func (f *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) {
|
||||
func (f *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, req *pbfriend.RemoveBlackReq) {
|
||||
blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{
|
||||
FromUserID: req.OwnerUserID,
|
||||
ToUserID: req.BlackUserID,
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
pbGroup "github.com/OpenIMSDK/protocol/group"
|
||||
pbgroup "github.com/OpenIMSDK/protocol/group"
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
@@ -317,7 +317,7 @@ func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(ctx conte
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, rpcclient.WithRpcGetUserName())
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) (err error) {
|
||||
func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbgroup.JoinGroupReq) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
@@ -362,7 +362,7 @@ 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 {
|
||||
@@ -390,7 +390,7 @@ 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) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
@@ -418,7 +418,7 @@ 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) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||
)
|
||||
|
||||
@@ -41,7 +41,7 @@ func WithUserDB(db controller.UserDatabase) userNotificationSenderOptions {
|
||||
}
|
||||
|
||||
func WithUserFunc(
|
||||
fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error),
|
||||
fn func(ctx context.Context, userIDs []string) (users []*relationtb.UserModel, err error),
|
||||
) userNotificationSenderOptions {
|
||||
return func(u *UserNotificationSender) {
|
||||
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
|
||||
|
||||
+15
-3
@@ -31,12 +31,14 @@ import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
// User represents a structure holding connection details for the User RPC client.
|
||||
type User struct {
|
||||
conn grpc.ClientConnInterface
|
||||
Client user.UserClient
|
||||
Discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
// NewUser initializes and returns a User instance based on the provided service discovery registry.
|
||||
func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
|
||||
if err != nil {
|
||||
@@ -46,17 +48,21 @@ func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
|
||||
return &User{Discov: discov, Client: client, conn: conn}
|
||||
}
|
||||
|
||||
// UserRpcClient represents the structure for a User RPC client.
|
||||
type UserRpcClient User
|
||||
|
||||
// NewUserRpcClientByUser initializes a UserRpcClient based on the provided User instance.
|
||||
func NewUserRpcClientByUser(user *User) *UserRpcClient {
|
||||
rpc := UserRpcClient(*user)
|
||||
return &rpc
|
||||
}
|
||||
|
||||
// NewUserRpcClient initializes a UserRpcClient based on the provided service discovery registry.
|
||||
func NewUserRpcClient(client discoveryregistry.SvcDiscoveryRegistry) UserRpcClient {
|
||||
return UserRpcClient(*NewUser(client))
|
||||
}
|
||||
|
||||
// GetUsersInfo retrieves information for multiple users based on their user IDs.
|
||||
func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error) {
|
||||
resp, err := u.Client.GetDesignateUsers(ctx, &user.GetDesignateUsersReq{
|
||||
UserIDs: userIDs,
|
||||
@@ -72,6 +78,7 @@ func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*
|
||||
return resp.UsersInfo, nil
|
||||
}
|
||||
|
||||
// GetUserInfo retrieves information for a single user based on the provided user ID.
|
||||
func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.UserInfo, error) {
|
||||
users, err := u.GetUsersInfo(ctx, []string{userID})
|
||||
if err != nil {
|
||||
@@ -80,6 +87,7 @@ func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.
|
||||
return users[0], nil
|
||||
}
|
||||
|
||||
// GetUsersInfoMap retrieves a map of user information indexed by their user IDs.
|
||||
func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
|
||||
users, err := u.GetUsersInfo(ctx, userIDs)
|
||||
if err != nil {
|
||||
@@ -90,6 +98,7 @@ func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (
|
||||
}), nil
|
||||
}
|
||||
|
||||
// GetPublicUserInfos retrieves public information for multiple users based on their user IDs.
|
||||
func (u *UserRpcClient) GetPublicUserInfos(
|
||||
ctx context.Context,
|
||||
userIDs []string,
|
||||
@@ -109,6 +118,7 @@ func (u *UserRpcClient) GetPublicUserInfos(
|
||||
}), nil
|
||||
}
|
||||
|
||||
// GetPublicUserInfo retrieves public information for a single user based on the provided user ID.
|
||||
func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) {
|
||||
users, err := u.GetPublicUserInfos(ctx, []string{userID}, true)
|
||||
if err != nil {
|
||||
@@ -117,6 +127,7 @@ func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*
|
||||
return users[0], nil
|
||||
}
|
||||
|
||||
// GetPublicUserInfoMap retrieves a map of public user information indexed by their user IDs.
|
||||
func (u *UserRpcClient) GetPublicUserInfoMap(
|
||||
ctx context.Context,
|
||||
userIDs []string,
|
||||
@@ -131,16 +142,15 @@ func (u *UserRpcClient) GetPublicUserInfoMap(
|
||||
}), nil
|
||||
}
|
||||
|
||||
// GetUserGlobalMsgRecvOpt retrieves the global message receive option for a user based on the provided user ID.
|
||||
func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID string) (int32, error) {
|
||||
resp, err := u.Client.GetGlobalRecvMessageOpt(ctx, &user.GetGlobalRecvMessageOptReq{
|
||||
UserID: userID,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return resp.GlobalRecvMsgOpt, err
|
||||
}
|
||||
|
||||
// Access verifies the access rights for the provided user ID.
|
||||
func (u *UserRpcClient) Access(ctx context.Context, ownerUserID string) error {
|
||||
_, err := u.GetUserInfo(ctx, ownerUserID)
|
||||
if err != nil {
|
||||
@@ -149,6 +159,7 @@ func (u *UserRpcClient) Access(ctx context.Context, ownerUserID string) error {
|
||||
return authverify.CheckAccessV3(ctx, ownerUserID)
|
||||
}
|
||||
|
||||
// GetAllUserIDs retrieves all user IDs with pagination options.
|
||||
func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumber int32) ([]string, error) {
|
||||
resp, err := u.Client.GetAllUserID(ctx, &user.GetAllUserIDReq{Pagination: &sdkws.RequestPagination{PageNumber: pageNumber, ShowNumber: showNumber}})
|
||||
if err != nil {
|
||||
@@ -157,6 +168,7 @@ func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumbe
|
||||
return resp.UserIDs, nil
|
||||
}
|
||||
|
||||
// SetUserStatus sets the status for a user based on the provided user ID, status, and platform ID.
|
||||
func (u *UserRpcClient) SetUserStatus(ctx context.Context, userID string, status int32, platformID int) error {
|
||||
_, err := u.Client.SetUserStatus(ctx, &user.SetUserStatusReq{StatusList: []*user.OnlineStatus{{UserID: userID, Status: status, PlatformIDs: []int32{int32(platformID)}}}})
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user