Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Details optimization #1293

Merged
merged 3 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions internal/msggateway/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (c *Client) readMessage() {
return
}
log.ZDebug(c.ctx, "readMessage", "messageType", messageType)
if c.closed == true { // 连接刚置位已经关闭,但是协程还没退出的场景
if c.closed { // 连接刚置位已经关闭,但是协程还没退出的场景
c.closedErr = ErrConnClosed
return
}
Expand Down Expand Up @@ -282,10 +282,10 @@ func (c *Client) KickOnlineMessage() error {
func (c *Client) writeBinaryMsg(resp Resp) error {
c.w.Lock()
defer c.w.Unlock()
if c.closed == true {
if c.closed {
return nil
}
encodedBuf := bufferPool.Get().([]byte)

resultBuf := bufferPool.Get().([]byte)
encodedBuf, err := c.longConnServer.Encode(resp)
if err != nil {
Expand All @@ -307,9 +307,12 @@ func (c *Client) writeBinaryMsg(resp Resp) error {
func (c *Client) writePongMsg() error {
c.w.Lock()
defer c.w.Unlock()
if c.closed == true {
if c.closed {
return nil
}
_ = c.conn.SetWriteDeadline(writeWait)
err := c.conn.SetWriteDeadline(writeWait)
if err != nil {
return utils.Wrap(err, "")
}
return c.conn.WriteMessage(PongMessage, nil)
}
4 changes: 3 additions & 1 deletion internal/msggateway/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func (c *UserConnContext) GetOperationID() string {
}

func (c *UserConnContext) SetOperationID(operationID string) {
c.Req.URL.Query().Set(OperationID, operationID)
values := c.Req.URL.Query()
values.Set(OperationID, operationID)
c.Req.URL.RawQuery = values.Encode()
}

func (c *UserConnContext) GetToken() string {
Expand Down
10 changes: 4 additions & 6 deletions internal/rpc/msg/message_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@
func MessageHasReadEnabled(_ context.Context, req *msg.SendMsgReq) (*sdkws.MsgData, error) {
switch {
case req.MsgData.ContentType == constant.HasReadReceipt && req.MsgData.SessionType == constant.SingleChatType:
if config.Config.SingleMessageHasReadReceiptEnable {
return req.MsgData, nil
} else {
if !config.Config.SingleMessageHasReadReceiptEnable {
return nil, errs.ErrMessageHasReadDisable.Wrap()
}
return req.MsgData, nil

Check failure on line 36 in internal/rpc/msg/message_interceptor.go

View workflow job for this annotation

GitHub Actions / lint

return with no blank line before (nlreturn)
case req.MsgData.ContentType == constant.HasReadReceipt && req.MsgData.SessionType == constant.SuperGroupChatType:
if config.Config.GroupMessageHasReadReceiptEnable {
return req.MsgData, nil
} else {
if !config.Config.GroupMessageHasReadReceiptEnable {
return nil, errs.ErrMessageHasReadDisable.Wrap()
}
return req.MsgData, nil

Check failure on line 41 in internal/rpc/msg/message_interceptor.go

View workflow job for this annotation

GitHub Actions / lint

return with no blank line before (nlreturn)
}
return req.MsgData, nil
}
5 changes: 2 additions & 3 deletions pkg/msgprocessor/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@
l := strings.Split(conversationID, "_")
if len(l) > 1 {
l[0] = "n"
return strings.Join(l, "_")
} else {
return ""
return conversationID

Check failure on line 121 in pkg/msgprocessor/conversation.go

View workflow job for this annotation

GitHub Actions / lint

return with no blank line before (nlreturn)
}
return ""

Check failure on line 123 in pkg/msgprocessor/conversation.go

View workflow job for this annotation

GitHub Actions / lint

return with no blank line before (nlreturn)
}

func GetNotificationConversationID(sessionType int, ids ...string) string {
Expand Down
Loading