refactor(gateway/platforms): signal/bluebubbles — reuse utils.TRUTHY_STRINGS

This commit is contained in:
Teknium
2026-09-02 19:47:37 -07:00
parent f46a9d4341
commit 4f322d04a9
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -26,6 +26,7 @@ from gateway.platforms.base import (
cache_image_from_bytes, cache_audio_from_bytes, cache_document_from_bytes)
from .media_cache import ext_for_mime
from gateway.platforms.helpers import compile_mention_patterns, strip_markdown
from utils import TRUTHY_STRINGS
# Historical BlueBubbles mime→ext maps, preserved verbatim as overrides for
# the shared dispatch in gateway.platforms.media_cache. Both maps are
@@ -68,7 +69,6 @@ _ADDRESS_RE = re.compile(r"^\+\d+")
_GUID_CACHE_SIZE = 500 # LRU cap for resolved chat-GUID lookups
_LOCAL_HOSTS = {"0.0.0.0", "127.0.0.1", "localhost", "::"}
_TRUTHY = {"true", "1", "yes", "on"}
def _redact(text: str) -> str:
@@ -135,7 +135,7 @@ class BlueBubblesAdapter(BasePlatformAdapter):
_require_mention = extra.get("require_mention")
if _require_mention is None:
_require_mention = os.getenv("BLUEBUBBLES_REQUIRE_MENTION")
self.require_mention = str(_require_mention).strip().lower() in _TRUTHY
self.require_mention = str(_require_mention).strip().lower() in TRUTHY_STRINGS
self._mention_patterns = self._compile_mention_patterns(
extra["mention_patterns"] if "mention_patterns" in extra else os.getenv("BLUEBUBBLES_MENTION_PATTERNS")
)
+2 -2
View File
@@ -39,6 +39,7 @@ from gateway.platforms.signal_rate_limit import (
SignalRateLimitError, _extract_retry_after_seconds, _format_wait, _is_signal_rate_limit_error,
_signal_send_timeout, get_scheduler)
from gateway.platforms._shared import get_scoped_secret as _sig_secret
from utils import TRUTHY_STRINGS
logger = logging.getLogger(__name__)
@@ -56,7 +57,6 @@ _MEDIA_TYPE_BY_MIME_PREFIX = (
_OUTCOME_REACTION = {ProcessingOutcome.SUCCESS: "✅", ProcessingOutcome.FAILURE: "❌"}
_QUOTE_AUTHOR_KEYS = (
"author", "authorNumber", "authorUuid", "authorAci", "authorServiceId", "authorServiceIdString")
_TRUTHY = ("true", "1", "yes", "on")
def _parse_comma_list(value: str) -> List[str]:
@@ -195,7 +195,7 @@ class SignalAdapter(BasePlatformAdapter):
_rm_cfg = extra.get("require_mention")
self.require_mention = (
bool(_rm_cfg) if _rm_cfg is not None
else os.getenv("SIGNAL_REQUIRE_MENTION", "false").lower() in _TRUTHY)
else os.getenv("SIGNAL_REQUIRE_MENTION", "false").lower() in TRUTHY_STRINGS)
# DM allowlist mirrors run.py's SIGNAL_ALLOWED_USERS so reaction hooks (which fire
# before run.py's auth gate) can skip unauthorized senders. "*" = open.
self.dm_allow_from = set(_parse_comma_list(_sig_secret("SIGNAL_ALLOWED_USERS", "*")))