map debug + coord backfill, remove email channel, countdown label
- Surface "X/Y passende Wohnungen mit Koordinaten" on the Karte view +
admin-only "Koordinaten nachladen" button (POST /actions/backfill-coords)
that geocodes missing flats via Google Maps directly from the web container
- Add googlemaps dep + GMAPS_API_KEY env to web service
- Light console.log in map.js ("rendering N/M markers", "building Leaflet…")
so the browser DevTools shows what's happening
- Drop e-mail channel from notifications UI, notify dispatcher, and _alert_status;
coerce legacy 'email' channel rows back to 'ui' on save
- Countdown said "Aktualisierung läuft…" next to "nächste Aktualisierung" →
shortened to "aktualisiere…"
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
51b6b02b24
commit
0c58242ce7
11 changed files with 149 additions and 58 deletions
|
|
@ -4,25 +4,14 @@ User-level notification dispatcher.
|
|||
Channels:
|
||||
- 'ui' → no-op (dashboard shows the events anyway)
|
||||
- 'telegram' → per-user bot token + chat id
|
||||
- 'email' → system SMTP (one outbox, per-user recipient)
|
||||
"""
|
||||
import logging
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from typing import Optional
|
||||
|
||||
import requests
|
||||
|
||||
import db
|
||||
from settings import (
|
||||
PUBLIC_URL,
|
||||
SMTP_FROM,
|
||||
SMTP_HOST,
|
||||
SMTP_PASSWORD,
|
||||
SMTP_PORT,
|
||||
SMTP_STARTTLS,
|
||||
SMTP_USERNAME,
|
||||
)
|
||||
from settings import PUBLIC_URL
|
||||
|
||||
logger = logging.getLogger("web.notifications")
|
||||
|
||||
|
|
@ -46,28 +35,6 @@ def _telegram_send(token: str, chat_id: str, text: str) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def _email_send(recipient: str, subject: str, body: str) -> bool:
|
||||
if not SMTP_HOST or not recipient:
|
||||
logger.info("email skipped (SMTP_HOST=%r recipient=%r)", SMTP_HOST, recipient)
|
||||
return False
|
||||
try:
|
||||
msg = MIMEText(body, _charset="utf-8")
|
||||
msg["Subject"] = subject
|
||||
msg["From"] = SMTP_FROM
|
||||
msg["To"] = recipient
|
||||
with smtplib.SMTP(SMTP_HOST, SMTP_PORT, timeout=15) as s:
|
||||
if SMTP_STARTTLS:
|
||||
s.starttls()
|
||||
if SMTP_USERNAME:
|
||||
s.login(SMTP_USERNAME, SMTP_PASSWORD)
|
||||
s.send_message(msg)
|
||||
logger.info("email sent to %s", recipient)
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.warning("email send failed: %s", e)
|
||||
return False
|
||||
|
||||
|
||||
def _should_notify(notif, event: EventType) -> bool:
|
||||
if event == "match":
|
||||
return bool(notif["notify_on_match"])
|
||||
|
|
@ -86,17 +53,11 @@ def notify_user(user_id: int, event: EventType, *,
|
|||
if not notif or not _should_notify(notif, event):
|
||||
return
|
||||
channel = notif["channel"] or "ui"
|
||||
if channel == "ui":
|
||||
return
|
||||
if channel == "telegram":
|
||||
token = notif["telegram_bot_token"]
|
||||
chat = notif["telegram_chat_id"]
|
||||
if token and chat:
|
||||
_telegram_send(token, chat, body_markdown or body_plain)
|
||||
elif channel == "email":
|
||||
addr = notif["email_address"]
|
||||
if addr:
|
||||
_email_send(addr, subject, body_plain)
|
||||
except Exception:
|
||||
logger.exception("notify_user failed for user=%s event=%s", user_id, event)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue