style: add format

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong(cubxxw-openim)
2023-07-03 16:29:22 +08:00
parent 187ee9a375
commit 166ddb1e34
170 changed files with 4816 additions and 1279 deletions
+72 -16
View File
@@ -4,11 +4,12 @@ import (
"context"
"fmt"
"google.golang.org/grpc"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
"google.golang.org/grpc"
)
type Conversation struct {
@@ -32,12 +33,18 @@ func NewConversationRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) Con
return ConversationRpcClient(*NewConversation(discov))
}
func (c *ConversationRpcClient) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) error {
func (c *ConversationRpcClient) ModifyConversationField(
ctx context.Context,
req *pbConversation.ModifyConversationFieldReq,
) error {
_, err := c.Client.ModifyConversationField(ctx, req)
return err
}
func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(
ctx context.Context,
userID, conversationID string,
) (int32, error) {
var req pbConversation.GetConversationReq
req.OwnerUserID = userID
req.ConversationID = conversationID
@@ -49,21 +56,51 @@ func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Cont
}
func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID string) error {
_, err := c.Client.CreateSingleChatConversations(ctx, &pbConversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID})
_, err := c.Client.CreateSingleChatConversations(
ctx,
&pbConversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID},
)
return err
}
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(ctx context.Context, groupID string, userIDs []string) error {
_, err := c.Client.CreateGroupChatConversations(ctx, &pbConversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID})
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(
ctx context.Context,
groupID string,
userIDs []string,
) error {
_, err := c.Client.CreateGroupChatConversations(
ctx,
&pbConversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID},
)
return err
}
func (c *ConversationRpcClient) SetConversationMaxSeq(ctx context.Context, ownerUserIDs []string, conversationID string, maxSeq int64) error {
_, err := c.Client.SetConversationMaxSeq(ctx, &pbConversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq})
func (c *ConversationRpcClient) SetConversationMaxSeq(
ctx context.Context,
ownerUserIDs []string,
conversationID string,
maxSeq int64,
) error {
_, err := c.Client.SetConversationMaxSeq(
ctx,
&pbConversation.SetConversationMaxSeqReq{
OwnerUserID: ownerUserIDs,
ConversationID: conversationID,
MaxSeq: maxSeq,
},
)
return err
}
func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbConversation.ConversationReq) error {
_, err := c.Client.SetConversations(ctx, &pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
func (c *ConversationRpcClient) SetConversations(
ctx context.Context,
userIDs []string,
conversation *pbConversation.ConversationReq,
) error {
_, err := c.Client.SetConversations(
ctx,
&pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation},
)
return err
}
@@ -75,16 +112,28 @@ func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUse
return resp.ConversationIDs, nil
}
func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*pbConversation.Conversation, error) {
resp, err := c.Client.GetConversation(ctx, &pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID})
func (c *ConversationRpcClient) GetConversation(
ctx context.Context,
ownerUserID, conversationID string,
) (*pbConversation.Conversation, error) {
resp, err := c.Client.GetConversation(
ctx,
&pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID},
)
if err != nil {
return nil, err
}
return resp.Conversation, nil
}
func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*pbConversation.Conversation, error) {
resp, err := c.Client.GetConversationsByConversationID(ctx, &pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs})
func (c *ConversationRpcClient) GetConversationsByConversationID(
ctx context.Context,
conversationIDs []string,
) ([]*pbConversation.Conversation, error) {
resp, err := c.Client.GetConversationsByConversationID(
ctx,
&pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs},
)
if err != nil {
return nil, err
}
@@ -94,8 +143,15 @@ func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Con
return resp.Conversations, nil
}
func (c *ConversationRpcClient) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*pbConversation.Conversation, error) {
resp, err := c.Client.GetConversations(ctx, &pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs})
func (c *ConversationRpcClient) GetConversations(
ctx context.Context,
ownerUserID string,
conversationIDs []string,
) ([]*pbConversation.Conversation, error) {
resp, err := c.Client.GetConversations(
ctx,
&pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs},
)
if err != nil {
return nil, err
}