client: ignore messages in left channels

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-09-27 08:46:44 -06:00
parent 31397681f5
commit 23bb0febe9
2 changed files with 13 additions and 3 deletions
+10 -1
View File
@@ -83,12 +83,21 @@ func (t *TelegramClient) onUpdateChannel(ctx context.Context, update *tg.UpdateC
return nil
}
func (t *TelegramClient) onUpdateNewMessage(ctx context.Context, update IGetMessage) error {
func (t *TelegramClient) onUpdateNewMessage(ctx context.Context, channels map[int64]*tg.Channel, update IGetMessage) error {
log := zerolog.Ctx(ctx)
switch msg := update.GetMessage().(type) {
case *tg.Message:
sender := t.getEventSender(msg)
if channel, ok := msg.PeerID.(*tg.PeerChannel); ok {
if c, ok := channels[channel.ChannelID]; ok && c.Left {
log.Debug().
Int64("channel_id", channel.ChannelID).
Msg("Received message in left channel, ignoring")
return nil
}
}
go t.handleTelegramReactions(ctx, msg)
if media, ok := msg.GetMedia(); ok && media.TypeID() == tg.MessageMediaContactTypeID {