fix: update channel.go fix #1641 - #1647
Conversation
…ner-intro 🤝 docs(README): Introduction to New Partners
WalkthroughAdds an early guard in service/channel.go: DisableChannel now checks channelError.AutoBan. If false, it optionally logs a debug message and returns without changing status or notifying. If true, it proceeds to set the channel to AutoDisabled and notifies the root user on success. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Service as ChannelService
participant Store as ChannelStore
participant Notifier as RootNotifier
Note over Service: DisableChannel()
Caller->>Service: DisableChannel(channelID, channelError)
alt AutoBan = false
Note over Service: Debug log (if enabled)
Service-->>Caller: return (no status change, no notify)
else AutoBan = true
Service->>Store: UpdateChannelStatus(channelID, AutoDisabled)
alt Update OK
Service->>Notifier: Notify root with formatted message
Notifier-->>Service: ack
Service-->>Caller: return success
else Update Failed
Service-->>Caller: return error
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ 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. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
service/channel.go (1)
23-25: Include the disable reason in the debug log for better forensics.Adding
reasonhelps correlate the skipped action with the triggering condition during incident review.Apply this diff:
- if common.DebugEnabled { - common.SysLog(fmt.Sprintf("通道「%s」(#%d)未启用自动禁用功能,跳过禁用操作", channelError.ChannelName, channelError.ChannelId)) - } + if common.DebugEnabled { + common.SysLog(fmt.Sprintf("通道「%s」(#%d)未启用自动禁用功能,跳过禁用操作。原因:%s", channelError.ChannelName, channelError.ChannelId, reason)) + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
service/channel.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
service/channel.go (2)
common/constants.go (1)
DebugEnabled(70-70)common/logger.go (1)
SysLog(50-53)
🔇 Additional comments (2)
service/channel.go (2)
22-27: AutoBan guard aligns behavior with PR intent.Early-return when
channelError.AutoBanis false cleanly prevents unintended auto-disables on channels that opted out. Side-effects (status change + notifications) are correctly avoided. LGTM.
22-27: ReviewChannelError.AutoBanInitializationSummary:
- The
ChannelErrorstruct intypes/channel_error.godefines anAutoBan boolfield.- There is a
NewChannelError(..., autoBan bool)constructor that takes anautoBanparameter and builds aChannelError.- In
controller/channel-billing.go, calls toDisableChanneluse*types.NewChannelError(..., channel.GetAutoBan()), soAutoBanis explicitly populated.- In
controller/relay.go,DisableChannelis invoked with achannelErrorvariable—ensure that thischannelErrorwas originally constructed viaNewChannelError(or otherwise set) so thatAutoBanreflects the intended value.Action items:
- Confirm that
NewChannelErroractually assigns theAutoBan: autoBanfield in its returned struct.- Trace the origin of the
channelErrorpassed intocontroller/relay.go(likely earlier in that handler) and verify it’s constructed with the correctautoBanvalue.
fix: update channel.go fix QuantumNous#1641
DisableChannel禁用渠道时会先判断渠道AutoBan设置,如果未允许自动禁用则不进行任何操作。
Summary by CodeRabbit