mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 18:45:58 +08:00
feat: Integrate Comprehensive E2E Testing for GoChat (#1906)
* feat: create e2e test readme Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: fix markdown file * feat: add openim make lint * feat: add git chglog pull request * feat: add git chglog pull request * fix: fix openim api err code * fix: fix openim api err code * fix: fix openim api err code * feat: Improve CICD * feat: Combining GitHub and Google Workspace for Effective Project Management' * feat: fix openim tools error code * feat: fix openim tools error code * feat: add openim error handle * feat: add openim error handle * feat: optimize tim white prom code return err * feat: fix openim tools error code * style: format openim server code style * feat: add openim optimize commit code * feat: add openim optimize commit code * feat: add openim auto format code * feat: add openim auto format code * feat: add openim auto format code * feat: add openim auto format code * feat: add openim auto format code * feat: format openim code * feat: Some of the notes were translated * feat: Some of the notes were translated * feat: update openim server code * feat: optimize openim reset code * feat: optimize openim reset code --------- Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
@@ -23,12 +23,13 @@ import (
|
||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
||||
)
|
||||
|
||||
func NewAuth(discov discoveryregistry.SvcDiscoveryRegistry) *Auth {
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
util.ExitWithError(err)
|
||||
}
|
||||
client := auth.NewAuthClient(conn)
|
||||
return &Auth{discov: discov, conn: conn, Client: client}
|
||||
|
||||
@@ -24,6 +24,8 @@ import (
|
||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
|
||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
)
|
||||
|
||||
@@ -36,7 +38,7 @@ type Conversation struct {
|
||||
func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry) *Conversation {
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImConversationName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
util.ExitWithError(err)
|
||||
}
|
||||
client := pbconversation.NewConversationClient(conn)
|
||||
return &Conversation{discov: discov, conn: conn, Client: client}
|
||||
@@ -114,11 +116,7 @@ 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) {
|
||||
func (c *ConversationRpcClient) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*pbconversation.Conversation, error) {
|
||||
if len(conversationIDs) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
||||
)
|
||||
|
||||
type Friend struct {
|
||||
@@ -35,7 +36,7 @@ type Friend struct {
|
||||
func NewFriend(discov discoveryregistry.SvcDiscoveryRegistry) *Friend {
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
util.ExitWithError(err)
|
||||
}
|
||||
client := friend.NewFriendClient(conn)
|
||||
return &Friend{discov: discov, conn: conn, Client: client}
|
||||
@@ -62,7 +63,7 @@ func (f *FriendRpcClient) GetFriendsInfo(
|
||||
return
|
||||
}
|
||||
|
||||
// possibleFriendUserID是否在userID的好友中.
|
||||
// possibleFriendUserID Is PossibleFriendUserId's friends.
|
||||
func (f *FriendRpcClient) IsFriend(ctx context.Context, possibleFriendUserID, userID string) (bool, error) {
|
||||
resp, err := f.Client.IsFriend(ctx, &friend.IsFriendReq{UserID1: userID, UserID2: possibleFriendUserID})
|
||||
if err != nil {
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
||||
)
|
||||
|
||||
type Group struct {
|
||||
@@ -39,7 +40,7 @@ type Group struct {
|
||||
func NewGroup(discov discoveryregistry.SvcDiscoveryRegistry) *Group {
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
util.ExitWithError(err)
|
||||
}
|
||||
client := group.NewGroupClient(conn)
|
||||
return &Group{discov: discov, conn: conn, Client: client}
|
||||
|
||||
+19
-3
@@ -147,14 +147,24 @@ func NewMessageRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) MessageR
|
||||
return MessageRpcClient(*NewMessage(discov))
|
||||
}
|
||||
|
||||
// SendMsg sends a message through the gRPC client and returns the response.
|
||||
// It wraps any encountered error for better error handling and context understanding.
|
||||
func (m *MessageRpcClient) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) {
|
||||
resp, err := m.Client.SendMsg(ctx, req)
|
||||
return resp, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetMaxSeq retrieves the maximum sequence number from the gRPC client.
|
||||
// Errors during the gRPC call are wrapped to provide additional context.
|
||||
func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqReq) (*sdkws.GetMaxSeqResp, error) {
|
||||
resp, err := m.Client.GetMaxSeq(ctx, req)
|
||||
return resp, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (m *MessageRpcClient) GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) {
|
||||
@@ -181,9 +191,15 @@ func (m *MessageRpcClient) GetMsgByConversationIDs(ctx context.Context, docIDs [
|
||||
return resp.MsgDatas, err
|
||||
}
|
||||
|
||||
// PullMessageBySeqList retrieves messages by their sequence numbers using the gRPC client.
|
||||
// It directly forwards the request to the gRPC client and returns the response along with any error encountered.
|
||||
func (m *MessageRpcClient) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
|
||||
resp, err := m.Client.PullMessageBySeqs(ctx, req)
|
||||
return resp, err
|
||||
if err != nil {
|
||||
// Wrap the error to provide more context if the gRPC call fails.
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (m *MessageRpcClient) GetConversationMaxSeq(ctx context.Context, conversationID string) (int64, error) {
|
||||
|
||||
@@ -31,7 +31,7 @@ func NewConversationNotificationSender(msgRpcClient *rpcclient.MessageRpcClient)
|
||||
return &ConversationNotificationSender{rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient))}
|
||||
}
|
||||
|
||||
// SetPrivate调用.
|
||||
// SetPrivate invote.
|
||||
func (c *ConversationNotificationSender) ConversationSetPrivateNotification(ctx context.Context, sendID, recvID string,
|
||||
isPrivateChat bool, conversationID string,
|
||||
) error {
|
||||
@@ -45,7 +45,6 @@ func (c *ConversationNotificationSender) ConversationSetPrivateNotification(ctx
|
||||
return c.Notification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, tips)
|
||||
}
|
||||
|
||||
// 会话改变.
|
||||
func (c *ConversationNotificationSender) ConversationChangeNotification(ctx context.Context, userID string, conversationIDs []string) error {
|
||||
tips := &sdkws.ConversationUpdateTips{
|
||||
UserID: userID,
|
||||
@@ -55,7 +54,6 @@ func (c *ConversationNotificationSender) ConversationChangeNotification(ctx cont
|
||||
return c.Notification(ctx, userID, userID, constant.ConversationChangeNotification, tips)
|
||||
}
|
||||
|
||||
// 会话未读数同步.
|
||||
func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(
|
||||
ctx context.Context,
|
||||
userID, conversationID string,
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
|
||||
type FriendNotificationSender struct {
|
||||
*rpcclient.NotificationSender
|
||||
// 找不到报错
|
||||
// Target not found err
|
||||
getUsersInfo func(ctx context.Context, userIDs []string) ([]CommonUser, error)
|
||||
// db controller
|
||||
db controller.FriendDatabase
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
||||
)
|
||||
|
||||
type Push struct {
|
||||
@@ -34,7 +35,7 @@ type Push struct {
|
||||
func NewPush(discov discoveryregistry.SvcDiscoveryRegistry) *Push {
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImPushName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
util.ExitWithError(err)
|
||||
}
|
||||
return &Push{
|
||||
discov: discov,
|
||||
@@ -49,9 +50,6 @@ 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)
|
||||
}
|
||||
|
||||
+24
-15
@@ -24,8 +24,10 @@ import (
|
||||
|
||||
"github.com/OpenIMSDK/protocol/third"
|
||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
||||
)
|
||||
|
||||
type Third struct {
|
||||
@@ -38,35 +40,42 @@ type Third struct {
|
||||
func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImThirdName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
util.ExitWithError(err)
|
||||
}
|
||||
client := third.NewThirdClient(conn)
|
||||
minioClient, err := minioInit()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
util.ExitWithError(err)
|
||||
}
|
||||
return &Third{discov: discov, Client: client, conn: conn, MinioClient: minioClient}
|
||||
}
|
||||
|
||||
func minioInit() (*minio.Client, error) {
|
||||
minioClient := &minio.Client{}
|
||||
initUrl := config.Config.Object.Minio.Endpoint
|
||||
minioUrl, err := url.Parse(initUrl)
|
||||
// Retrieve MinIO configuration details
|
||||
endpoint := config.Config.Object.Minio.Endpoint
|
||||
accessKeyID := config.Config.Object.Minio.AccessKeyID
|
||||
secretAccessKey := config.Config.Object.Minio.SecretAccessKey
|
||||
|
||||
// Parse the MinIO URL to determine if the connection should be secure
|
||||
minioURL, err := url.Parse(endpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errs.Wrap(err, "minioInit: failed to parse MinIO endpoint URL")
|
||||
}
|
||||
|
||||
// Determine the security of the connection based on the scheme
|
||||
secure := minioURL.Scheme == "https"
|
||||
|
||||
// Setup MinIO client options
|
||||
opts := &minio.Options{
|
||||
Creds: credentials.NewStaticV4(config.Config.Object.Minio.AccessKeyID, config.Config.Object.Minio.SecretAccessKey, ""),
|
||||
// Region: config.Config.Credential.Minio.Location,
|
||||
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),
|
||||
Secure: secure,
|
||||
}
|
||||
if minioUrl.Scheme == "http" {
|
||||
opts.Secure = false
|
||||
} else if minioUrl.Scheme == "https" {
|
||||
opts.Secure = true
|
||||
}
|
||||
minioClient, err = minio.New(minioUrl.Host, opts)
|
||||
|
||||
// Initialize MinIO client
|
||||
minioClient, err := minio.New(minioURL.Host, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errs.Wrap(err, "minioInit: failed to create MinIO client")
|
||||
}
|
||||
|
||||
return minioClient, nil
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||
util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
@@ -42,7 +43,7 @@ type User struct {
|
||||
func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
util.ExitWithError(err)
|
||||
}
|
||||
client := user.NewUserClient(conn)
|
||||
return &User{Discov: discov, Client: client, conn: conn}
|
||||
|
||||
Reference in New Issue
Block a user