all: respect/propagate errors from QueueRemoteEvent (#110)

This commit is contained in:
Adam Van Ymeren
2025-06-26 13:43:35 -07:00
committed by GitHub
parent 8ac519d1e5
commit 0952df0244
6 changed files with 170 additions and 64 deletions
+11 -3
View File
@@ -53,7 +53,10 @@ import (
"go.mau.fi/mautrix-telegram/pkg/connector/util"
)
var ErrNoAuthKey = errors.New("user does not have auth key")
var (
ErrNoAuthKey = errors.New("user does not have auth key")
ErrFailToQueueEvent = errors.New("failed to queue event")
)
type TelegramClient struct {
main *TelegramConnector
@@ -237,8 +240,8 @@ func NewTelegramClient(ctx context.Context, tc *TelegramConnector, login *bridge
dispatcher.OnPhoneCall(client.onPhoneCall)
client.updatesManager = updates.New(updates.Config{
OnChannelTooLong: func(channelID int64) {
tc.Bridge.QueueRemoteEvent(login, &simplevent.ChatResync{
OnChannelTooLong: func(channelID int64) error {
res := tc.Bridge.QueueRemoteEvent(login, &simplevent.ChatResync{
EventMeta: simplevent.EventMeta{
Type: bridgev2.RemoteEventChatResync,
LogContext: func(c zerolog.Context) zerolog.Context {
@@ -248,6 +251,11 @@ func NewTelegramClient(ctx context.Context, tc *TelegramConnector, login *bridge
},
CheckNeedsBackfillFunc: func(ctx context.Context, latestMessage *database.Message) (bool, error) { return true, nil },
})
if !res.Success {
return ErrFailToQueueEvent
}
return nil
},
Handler: dispatcher,
Logger: zaplog.Named("gaps"),