fix(channels): preserve global progress defaults
This commit is contained in:
1 parent
332c159b93
commit
bd8d3ad5b6
4 files changed
+47
-9
No files matched your search
@@ -101,6 +101,14 @@ class BaseChannel(ABC):
|
||||
"""
|
||||
pass
|
||||
|
||||
def progress_transport_defaults(self) -> tuple[bool, bool] | None:
|
||||
"""Return channel-owned defaults for progress and tool-hint messages.
|
||||
|
||||
``None`` keeps the global channel policy. Channels should override this
|
||||
only when their transport requires different defaults.
|
||||
"""
|
||||
return None
|
||||
|
||||
def should_retry_send_error(self, error: Exception) -> bool:
|
||||
"""Return whether the channel manager may retry a failed delivery.
|
||||
|
||||
|
||||
@@ -187,15 +187,9 @@ class ChannelManager:
|
||||
channel = cls(section, self.bus, **kwargs)
|
||||
if runtime_name and runtime_name != channel.name:
|
||||
channel.name = runtime_name
|
||||
# Channel-owned config models may deliberately choose safer transport
|
||||
# defaults than the global channel policy (for example, a quota-limited
|
||||
# platform can disable progress messages). Preserve those defaults
|
||||
# while still letting an explicit per-channel value win below.
|
||||
progress_default = getattr(
|
||||
channel.config, "send_progress", self.config.channels.send_progress,
|
||||
)
|
||||
tool_hints_default = getattr(
|
||||
channel.config, "send_tool_hints", self.config.channels.send_tool_hints,
|
||||
progress_default, tool_hints_default = channel.progress_transport_defaults() or (
|
||||
self.config.channels.send_progress,
|
||||
self.config.channels.send_tool_hints,
|
||||
)
|
||||
channel.send_progress = self._resolve_bool_override(
|
||||
section, "send_progress", progress_default,
|
||||
|
||||
@@ -339,6 +339,9 @@ class WeixinChannel(BaseChannel):
|
||||
self._reply_run_ids: dict[str, str] = {}
|
||||
self._reply_progress_counts: dict[str, int] = {}
|
||||
|
||||
def progress_transport_defaults(self) -> tuple[bool, bool]:
|
||||
return self.config.send_progress, self.config.send_tool_hints
|
||||
|
||||
def should_retry_send_error(self, error: Exception) -> bool:
|
||||
if isinstance(error, WeixinAPIError):
|
||||
return error.retryable
|
||||
|
||||
Reference in new issue
Block a user