From f5bfe421d15f898a04a757fa1de8f02fc715a38b Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 31 Jul 2025 14:12:14 +0300 Subject: [PATCH] handletelegram: stop returning unnecessary errors --- pkg/connector/reactions.go | 3 ++- pkg/connector/telegram.go | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/connector/reactions.go b/pkg/connector/reactions.go index f0f5deea..c3d6a8ac 100644 --- a/pkg/connector/reactions.go +++ b/pkg/connector/reactions.go @@ -135,7 +135,8 @@ func (t *TelegramClient) handleTelegramReactions(ctx context.Context, msg *tg.Me emojiID, emoji, err := computeEmojiAndID(reaction.Reaction, customEmojis) if err != nil { - return fmt.Errorf("failed to compute emoji and ID: %w", err) + log.Err(err).Msg("Failed to compute emoji and ID for reaction") + continue } users[userID].Reactions = append(users[userID].Reactions, &bridgev2.BackfillReaction{ diff --git a/pkg/connector/telegram.go b/pkg/connector/telegram.go index f5aff3b1..63cf84de 100644 --- a/pkg/connector/telegram.go +++ b/pkg/connector/telegram.go @@ -92,9 +92,9 @@ func (t *TelegramClient) onUpdateChannel(ctx context.Context, e tg.Entities, upd if tgerr.Is(err, tg.ErrChannelInvalid, tg.ErrChannelPrivate) { return t.selfLeaveChat(portalKey) } - return fmt.Errorf("failed to get channel: %w", err) + log.Err(err).Msg("Failed to get channel info after UpdateChannel event") } else if len(chats.GetChats()) != 1 { - return fmt.Errorf("expected 1 chat, got %d", len(chats.GetChats())) + log.Warn().Int("chat_count", len(chats.GetChats())).Msg("Got more than 1 chat in GetChannels response") } else if channel, ok := chats.GetChats()[0].(*tg.Channel); !ok { log.Error().Type("chat_type", chats.GetChats()[0]).Msg("Expected channel, got something else. Leaving the channel.") return t.selfLeaveChat(portalKey) @@ -404,7 +404,8 @@ func (t *TelegramClient) onUpdateNewMessage(ctx context.Context, entities tg.Ent case tg.PhoneCallDiscardReasonBusyTypeID: body.WriteString("rejected") default: - return fmt.Errorf("unknown call end reason %T", action.Reason) + log.Warn().Stringer("end_reason", action.Reason).Msg("Unknown call end reason") + return nil } if action.Duration > 0 { @@ -1236,7 +1237,8 @@ func (t *TelegramClient) onPeerBlocked(ctx context.Context, e tg.Entities, updat if peer, ok := update.PeerID.(*tg.PeerUser); ok { userID = ids.MakeUserID(peer.UserID) } else { - return fmt.Errorf("unexpected peer type in peer blocked update %T", update.PeerID) + zerolog.Ctx(ctx).Warn().Type("peer_type", update.PeerID).Msg("Unexpected peer type in peer blocked update") + return nil } // Update the ghost @@ -1279,7 +1281,8 @@ func (t *TelegramClient) onPhoneCall(ctx context.Context, e tg.Entities, update log.Info().Type("type", update.PhoneCall).Msg("Unhandled phone call update class") return nil } else if call.ParticipantID != t.telegramUserID { - return fmt.Errorf("received phone call for user that is not us") + log.Warn().Msg("Received phone call for user that is not us") + return nil } var body strings.Builder