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
+41 -8
View File
@@ -4,6 +4,9 @@ import (
"context"
"encoding/json"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
@@ -11,8 +14,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
// "google.golang.org/protobuf/proto"
)
@@ -134,7 +135,10 @@ func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqRe
return resp, err
}
func (m *MessageRpcClient) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
func (m *MessageRpcClient) PullMessageBySeqList(
ctx context.Context,
req *sdkws.PullMessageBySeqsReq,
) (*sdkws.PullMessageBySeqsResp, error) {
resp, err := m.Client.PullMessageBySeqs(ctx, req)
return resp, err
}
@@ -155,7 +159,9 @@ type NotificationSender struct {
type NewNotificationSenderOptions func(*NotificationSender)
func WithLocalSendMsg(sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error)) NewNotificationSenderOptions {
func WithLocalSendMsg(
sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error),
) NewNotificationSenderOptions {
return func(s *NotificationSender) {
s.sendMsg = sendMsg
}
@@ -168,18 +174,39 @@ func WithRpcClient(msgRpcClient *MessageRpcClient) NewNotificationSenderOptions
}
func NewNotificationSender(opts ...NewNotificationSenderOptions) *NotificationSender {
notificationSender := &NotificationSender{contentTypeConf: newContentTypeConf(), sessionTypeConf: newSessionTypeConf()}
notificationSender := &NotificationSender{
contentTypeConf: newContentTypeConf(),
sessionTypeConf: newSessionTypeConf(),
}
for _, opt := range opts {
opt(notificationSender)
}
return notificationSender
}
func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string, contentType, sesstionType int32, m proto.Message, opts ...utils.OptionsOpt) (err error) {
func (s *NotificationSender) NotificationWithSesstionType(
ctx context.Context,
sendID, recvID string,
contentType, sesstionType int32,
m proto.Message,
opts ...utils.OptionsOpt,
) (err error) {
n := sdkws.NotificationElem{Detail: utils.StructToJsonString(m)}
content, err := json.Marshal(&n)
if err != nil {
log.ZError(ctx, "MsgClient Notification json.Marshal failed", err, "sendID", sendID, "recvID", recvID, "contentType", contentType, "msg", m)
log.ZError(
ctx,
"MsgClient Notification json.Marshal failed",
err,
"sendID",
sendID,
"recvID",
recvID,
"contentType",
contentType,
"msg",
m,
)
return err
}
var req msg.SendMsgReq
@@ -214,6 +241,12 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
return err
}
func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message, opts ...utils.OptionsOpt) error {
func (s *NotificationSender) Notification(
ctx context.Context,
sendID, recvID string,
contentType int32,
m proto.Message,
opts ...utils.OptionsOpt,
) error {
return s.NotificationWithSesstionType(ctx, sendID, recvID, contentType, s.sessionTypeConf[contentType], m, opts...)
}