From 0b0467fbb77352dad07b99ea882be76b2e7e0a1d Mon Sep 17 00:00:00 2001 From: c0re100 Date: Sun, 14 Aug 2022 22:01:42 +0800 Subject: [PATCH] Remove forwardMessages handler Bad implementation and it should handled by client side --- client/client.go | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/client/client.go b/client/client.go index 16b589f..33a96d5 100644 --- a/client/client.go +++ b/client/client.go @@ -219,35 +219,6 @@ func (client *Client) Send(req Request) (*Response, error) { } } } - if response.Type != "error" && req.Type == "forwardMessages" { - ms, err := UnmarshalMessages(response.Data) - if err != nil { - return nil, err - } - - for _, m := range ms.Messages { - forwardCatcher := make(chan *Response, 1) - client.forwardMsgStore.Store(m.Id, forwardCatcher) - - defer (func() { - client.forwardMsgStore.Delete(m.Id) - close(forwardCatcher) - })() - - select { - case modResponse := <-forwardCatcher: - m2, err2 := UnmarshalUpdateMessageSendSucceeded(modResponse.Data) - if err2 != nil { - return response, nil - } - response.Data = bytes.ReplaceAll(response.Data, []byte("{\"@type\":\"messageSendingStatePending\"}"), []byte("{\"@type\":\"updateMessageSendSucceeded\"}")) - response.Data = bytes.Replace(response.Data, []byte("\"id\":"+strconv.FormatInt(m.Id, 10)), []byte("\"id\":"+strconv.FormatInt(m2.Message.Id, 10)), 1) - case <-time.After(10 * time.Second): - return response, nil - } - } - return response, nil - } return response, nil case <-ctx.Done(): return nil, errors.New("response catching timeout")