Skip to content

Commit

Permalink
check for allowed chat earlier to prevent logging of direct messages
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Mar 24, 2024
1 parent 44b5c95 commit 5348639
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/events/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ func (l *TelegramListener) procEvents(update tbapi.Update) error {
if errJSON != nil {
return fmt.Errorf("failed to marshal update.Message to json: %w", errJSON)
}
log.Printf("[DEBUG] %s", string(msgJSON))
msg := transform(update.Message)
fromChat := update.Message.Chat.ID

// ignore messages from other chats except the one we are monitor and ones from the test list
if !l.isChatAllowed(fromChat) {
return nil
}

log.Printf("[DEBUG] %s", string(msgJSON))
msg := transform(update.Message)

// ignore empty messages
if strings.TrimSpace(msg.Text) == "" && msg.Image == nil {
return nil
Expand Down

0 comments on commit 5348639

Please sign in to comment.