fix: Rich-Markup-Fehler bei leeren Styles + Telefonnummer-Normalisierung
- _render_message: leeren style-Tag vermieden (MarkupError bei inbound-Msgs) - Nachrichtentext: eckige Klammern werden escaped (kein Markup-Injection) - get_by_phone: sucht +49xxx und 49xxx gleichzeitig (Green API liefert ohne +)
This commit is contained in:
@@ -19,11 +19,14 @@ def get_by_telegram_id(db: Session, telegram_id: str) -> Contact | None:
|
||||
|
||||
|
||||
def get_by_phone(db: Session, phone: str) -> Contact | None:
|
||||
return (
|
||||
db.query(Contact)
|
||||
.filter((Contact.phone == phone) | (Contact.whatsapp_phone == phone))
|
||||
.first()
|
||||
)
|
||||
# Normalisierung: mit und ohne führendes + suchen
|
||||
variants = {phone, "+" + phone.lstrip("+"), phone.lstrip("+")}
|
||||
from sqlalchemy import or_
|
||||
conditions = or_(*(
|
||||
(Contact.phone == v) | (Contact.whatsapp_phone == v)
|
||||
for v in variants
|
||||
))
|
||||
return db.query(Contact).filter(conditions).first()
|
||||
|
||||
|
||||
def create(db: Session, data: ContactCreate) -> Contact:
|
||||
|
||||
Reference in New Issue
Block a user