Disable Telegram Link Previews by Default#506
Disable Telegram Link Previews by Default#506zy9ard3 wants to merge 1 commit intoprojectdiscovery:mainfrom
Conversation
WalkthroughThe change updates the construction of the Telegram notification URL in the codebase by appending the query parameter Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
pkg/providers/telegram/telegram.go (1)
44-45:p.counter++is racy under concurrentSendcalls
Sendmutates a shared field without synchronisation; if multiple goroutines callSend, the increment is subject to data races and the counter can be corrupted.
Replace the plain int with anatomic.Int64(Go 1.19+) or anint64guarded bysync/atomic. Example fix:-import ( - "fmt" +import ( + "fmt" + "sync/atomic" @@ -type Provider struct { - Telegram []*Options `yaml:"telegram,omitempty"` - counter int +type Provider struct { + Telegram []*Options `yaml:"telegram,omitempty"` + counter atomic.Int64 } @@ - p.counter++ + current := p.counter.Add(1) @@ - msg := utils.FormatMessage(message, utils.SelectFormat(CliFormat, pr.TelegramFormat), p.counter) + msg := utils.FormatMessage(message, utils.SelectFormat(CliFormat, pr.TelegramFormat), int(current))
🧹 Nitpick comments (1)
pkg/providers/telegram/telegram.go (1)
47-49: DefaultingTelegramParseModeto the literal string"None"may break formatting
shoutrrrexpects recognised values (markdown,html, or empty). Setting"None"introduces an unsupported value every time the field is blank. Consider leaving it empty or validating against the allowed list before sending.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/providers/telegram/telegram.go(1 hunks)
🔇 Additional comments (1)
pkg/providers/telegram/telegram.go (1)
50-50: Confirm Shoutrrr parameter name & casingShoutrrr’s Telegram service uses a
previewquery parameter, but the accepted values are lowercaseyes/no(see project docs). SupplyingNo(capital “N”) may silently fall back to the default (yes) and re-enable previews.
Please verify the expected value/case and adjust if necessary.
| pr.TelegramParseMode = "None" | ||
| } | ||
| url := fmt.Sprintf("telegram://%s@telegram?channels=%s&parsemode=%s", pr.TelegramAPIKey, pr.TelegramChatID, pr.TelegramParseMode) | ||
| url := fmt.Sprintf("telegram://%s@telegram?channels=%s&parsemode=%s&preview=No", pr.TelegramAPIKey, pr.TelegramChatID, pr.TelegramParseMode) |
There was a problem hiding this comment.
I've already committed the same 👍
It would be better to disable telegram link previews by default for various privacy & security reasons.
Reference:
https://github.com/containrrr/shoutrrr/blob/main/docs/services/telegram.md#optional-parameters
Summary by CodeRabbit