Skip to content

Commit

Permalink
added route to fetch shared emails
Browse files Browse the repository at this point in the history
  • Loading branch information
GodReaper committed Oct 29, 2024
1 parent 2dac7bd commit 532a62b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/modules/conversations/access/access_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ async def share_chat(self, conversation_id: str, recipient_emails: List[str] = N
return conversation_id
return conversation_id

async def get_shared_emails(self, conversation_id: str) -> List[str]:
chat = self.db.query(Conversation).filter_by(id=conversation_id).first()
if not chat:
raise ShareChatServiceError("Chat not found.")

return chat.shared_with_emails or []
12 changes: 12 additions & 0 deletions app/modules/conversations/conversations_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,15 @@ async def share_chat(
)
except ShareChatServiceError as e:
raise HTTPException(status_code=400, detail=str(e))

@router.get("/conversations/{conversation_id}/shared-emails", response_model=List[str])
async def get_shared_emails(
conversation_id: str,
db: Session = Depends(get_db),
):
service = ShareChatService(db)
try:
shared_emails = await service.get_shared_emails(conversation_id)
return shared_emails
except ShareChatServiceError as e:
raise HTTPException(status_code=404, detail=str(e))

0 comments on commit 532a62b

Please sign in to comment.