-
Notifications
You must be signed in to change notification settings - Fork 152
Disable Telegram Link Previews by Default #506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
pkg/providers/telegram/telegram.go (1)
44-45
:p.counter++
is racy under concurrentSend
calls
Send
mutates 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 anint64
guarded 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
: DefaultingTelegramParseMode
to the literal string"None"
may break formatting
shoutrrr
expects 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
preview
query 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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