move gotd fork into repo. (#111)

- update to latest telegram layer
- remove some references to fields in tg.Entities that don't exist in
the schema
- originally added here:
https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e
  - referenced here
-
https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3
-
https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
This commit is contained in:
Adam Van Ymeren
2025-06-27 20:03:37 -07:00
committed by GitHub
parent 0952df0244
commit 7a04f298d2
19264 changed files with 1539697 additions and 84 deletions
+66
View File
@@ -0,0 +1,66 @@
package mtproto
import (
"github.com/go-faster/errors"
"go.uber.org/zap"
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
"go.mau.fi/mautrix-telegram/pkg/gotd/mt"
"go.mau.fi/mautrix-telegram/pkg/gotd/proto"
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)
func (c *Conn) handleResult(b *bin.Buffer) error {
// Response to an RPC query.
var res proto.Result
if err := res.Decode(b); err != nil {
return errors.Wrap(err, "decode")
}
// Now b contains result message.
b.ResetTo(res.Result)
msgID := zap.Int64("msg_id", res.RequestMessageID)
c.logWithBuffer(b).Debug("Handle result", msgID)
// Handling gzipped results.
id, err := b.PeekID()
if err != nil {
return err
}
if id == proto.GZIPTypeID {
content, err := gzip(b)
if err != nil {
return errors.Wrap(err, "decompress")
}
// Replacing buffer so callback will deal with uncompressed data.
b = content
c.logWithBuffer(b).Debug("Decompressed", msgID)
// Replacing id with inner id if error is compressed for any reason.
if id, err = b.PeekID(); err != nil {
return errors.Wrap(err, "peek id")
}
}
if id == mt.RPCErrorTypeID {
var rpcErr mt.RPCError
if err := rpcErr.Decode(b); err != nil {
return errors.Wrap(err, "error decode")
}
c.log.Debug("Got error", msgID,
zap.Int("err_code", rpcErr.ErrorCode),
zap.String("err_msg", rpcErr.ErrorMessage),
)
c.rpc.NotifyError(res.RequestMessageID, tgerr.New(rpcErr.ErrorCode, rpcErr.ErrorMessage))
return nil
}
if id == mt.PongTypeID {
return c.handlePong(b)
}
return c.rpc.NotifyResult(res.RequestMessageID, b)
}