feat: QR-Code für alle Kanäle (contact_id in ConversationResponse)
This commit is contained in:
@@ -20,14 +20,13 @@ def list_conversations(
|
||||
result = []
|
||||
for conv in convs:
|
||||
last_msg = conv.messages[-1] if conv.messages else None
|
||||
contact_id = conv.participants[0].id if conv.participants else None
|
||||
result.append(
|
||||
ConversationResponse(
|
||||
**{
|
||||
c.key: getattr(conv, c.key)
|
||||
for c in conv.__table__.columns
|
||||
},
|
||||
**{c.key: getattr(conv, c.key) for c in conv.__table__.columns},
|
||||
last_message=MessageResponse.model_validate(last_msg) if last_msg else None,
|
||||
unread_count=conversation_service.unread_count(db, conv.id),
|
||||
contact_id=contact_id,
|
||||
)
|
||||
)
|
||||
return result
|
||||
@@ -43,10 +42,12 @@ def get_conversation(
|
||||
if not conv:
|
||||
raise HTTPException(status_code=404, detail="Conversation not found")
|
||||
last_msg = conv.messages[-1] if conv.messages else None
|
||||
contact_id = conv.participants[0].id if conv.participants else None
|
||||
return ConversationResponse(
|
||||
**{c.key: getattr(conv, c.key) for c in conv.__table__.columns},
|
||||
last_message=MessageResponse.model_validate(last_msg) if last_msg else None,
|
||||
unread_count=conversation_service.unread_count(db, conv.id),
|
||||
contact_id=contact_id,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ class ConversationResponse(BaseModel):
|
||||
created_at: datetime
|
||||
last_message: Optional[MessageResponse] = None
|
||||
unread_count: int = 0
|
||||
contact_id: Optional[str] = None
|
||||
|
||||
|
||||
# ── Channel Status ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -289,17 +289,14 @@ class MainScreen(Screen):
|
||||
asyncio.create_task(self._generate_telegram_qr())
|
||||
|
||||
async def _generate_telegram_qr(self) -> None:
|
||||
if not self._current_conv:
|
||||
if not self._current_conv_id:
|
||||
self.notify("Bitte erst eine Konversation auswählen.", severity="warning")
|
||||
return
|
||||
conv = self._current_conv
|
||||
if conv.get("channel") != "telegram":
|
||||
self.notify("QR-Code nur für Telegram-Konversationen.", severity="warning")
|
||||
return
|
||||
conv = self._current_conv or {}
|
||||
contact_id = conv.get("contact_id")
|
||||
if not contact_id:
|
||||
try:
|
||||
details = await self._api.get_conversation(conv["id"])
|
||||
details = await self._api.get_conversation(self._current_conv_id)
|
||||
contact_id = (details or {}).get("contact_id")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user