diff --git a/bin/.bin/hungryroot-notifications b/bin/.bin/hungryroot-notifications index fd7d869..29ca8ea 100755 --- a/bin/.bin/hungryroot-notifications +++ b/bin/.bin/hungryroot-notifications @@ -21,14 +21,8 @@ FORWARDED_HEADER_RE = re.compile( re.IGNORECASE ) -TITLE_PREFIX_RE = re.compile( - r""" - ^\s* - (?:fwd:|fw:)\s* # optional forward prefix - (?:\[hungryroot/[^\]]+\]\s*)* # one or more [hungryroot/*] blocks - """, - re.IGNORECASE | re.VERBOSE, -) +PREFIX_RE = re.compile(r"^\s*(?:(?:re|fw|fwd)\s*:\s*)+", re.IGNORECASE) +HUNGRYROOT_REPOS_RE = re.compile(r"^\s*(?:\[hungryroot/[^\]]+\]\s*)+", re.IGNORECASE) GITHUB_URL_RE = re.compile(r"https://github\.com/[^\s>,]+") @@ -39,7 +33,7 @@ FOOTER_START_MARKERS = ( IMAP_HOST = os.environ.get("IMAP_HOST", "box.unbl.ink") IMAP_USER = os.environ.get("IMAP_USER", "hungryroot@unbl.ink") -IMAP_PASS = os.environ.get("IMAP_PASS", "Mainr0ot") +IMAP_PASS = os.environ.get("IMAP_PASS", "") NTFY_BASE = os.environ.get("NTFY_BASE", "https://ntfy.unbl.ink") NTFY_TOPIC = os.environ.get("NTFY_TOPIC", "hroot-notifications") @@ -90,9 +84,16 @@ def _sanitize_header(value: str) -> str: return " ".join(value.replace("\r", " ").replace("\n", " ").split()) def normalize_title(title: str) -> str: - # Remove CR/LF and collapse whitespace first (safe for headers) + # Unfold/sanitize any CRLF + weird spacing from forwarded headers title = " ".join(title.replace("\r", " ").replace("\n", " ").split()) - return TITLE_PREFIX_RE.sub("", title).strip() + + # Strip Re:/Fwd: chains like "Re: Re: Fwd:" + title = PREFIX_RE.sub("", title).strip() + + # Strip ONLY hungryroot repo prefix blocks, keep [BE-####] etc. + title = HUNGRYROOT_REPOS_RE.sub("", title).strip() + + return title def strip_github_footer(text: str) -> tuple[str, str | None]: """