fix(tools): point email home-channel error at EMAIL_HOME_ADDRESS
The no-home-channel error for send_message derived the env var name generically as <PLATFORM>_HOME_CHANNEL, producing EMAIL_HOME_CHANNEL for the email platform. But gateway/config.py reads EMAIL_HOME_ADDRESS, so a user following the error's guidance would set a variable that is never consulted. Add a per-platform override map so the email hint names the variable actually read; all other platforms keep the generic hint.
This commit is contained in:
@@ -44,6 +44,11 @@ _E164_TARGET_RE = re.compile(r"^\s*\+(\d{7,15})\s*$")
|
||||
# an explicit target for the email platform, not fall through to channel-name
|
||||
# resolution which has no way to resolve a raw address.
|
||||
_EMAIL_TARGET_RE = re.compile(r"^\s*[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\s*$")
|
||||
# Most platforms read their home channel from "<PLATFORM>_HOME_CHANNEL", but a
|
||||
# few diverge. Email reads EMAIL_HOME_ADDRESS (see gateway/config.py), so the
|
||||
# generic "<PLATFORM>_HOME_CHANNEL" hint would point users at a variable that is
|
||||
# never read. Map the exceptions so the error guidance is actually actionable.
|
||||
_HOME_CHANNEL_ENV_OVERRIDES = {"email": "EMAIL_HOME_ADDRESS"}
|
||||
_IMAGE_EXTS = {".jpg", ".jpeg", ".png", ".webp", ".gif"}
|
||||
_VIDEO_EXTS = {".mp4", ".mov", ".avi", ".mkv", ".3gp"}
|
||||
_AUDIO_EXTS = {".ogg", ".opus", ".mp3", ".wav", ".m4a", ".flac"}
|
||||
@@ -269,10 +274,13 @@ def _handle_send(args):
|
||||
chat_id = home.chat_id
|
||||
used_home_channel = True
|
||||
else:
|
||||
home_env = _HOME_CHANNEL_ENV_OVERRIDES.get(
|
||||
platform_name, f"{platform_name.upper()}_HOME_CHANNEL"
|
||||
)
|
||||
return json.dumps({
|
||||
"error": f"No home channel set for {platform_name} to determine where to send the message. "
|
||||
f"Either specify a channel directly with '{platform_name}:CHANNEL_NAME', "
|
||||
f"or set a home channel via: hermes config set {platform_name.upper()}_HOME_CHANNEL <channel_id>"
|
||||
f"or set a home channel via: hermes config set {home_env} <channel_id>"
|
||||
})
|
||||
|
||||
duplicate_skip = _maybe_skip_cron_duplicate_send(platform_name, chat_id, thread_id)
|
||||
|
||||
Reference in New Issue
Block a user