Task 3 — Conversation & message service layer (Python)
Title: service: implement server-side conversation/message service (persistence + helpers)
Description
-
Implement a Python service module (e.g., messaging.services) that:
- Creates/loads conversations (create if not exists on first message).
- Persists messages to Mongo.
- Updates
conversations.last_message_at.
- Provides recent message fetch (pagination), unread count per conversation, and mark-as-read helper.
-
Expose simple functions used by REST endpoints and Channels consumers:
create_message(conversation_id, sender_id, body, attachments, meta) -> message_doc
get_conversation(conversation_id, page, page_size)
list_conversations_for_user(user_id, page, page_size)
mark_messages_read(conversation_id, user_id)
Acceptance
- Unit tests for each function using a test Mongo fixture.
- Service functions documented and used later by REST & Channels layers.
Dependencies
- Task 2 Mongo schema, Auth, Uploads.
Notes
- Validate participant membership in conversation before persisting messages.
Task 3 — Conversation & message service layer (Python)
Title: service: implement server-side conversation/message service (persistence + helpers)
Description
Implement a Python service module (e.g.,
messaging.services) that:conversations.last_message_at.Expose simple functions used by REST endpoints and Channels consumers:
create_message(conversation_id, sender_id, body, attachments, meta) -> message_docget_conversation(conversation_id, page, page_size)list_conversations_for_user(user_id, page, page_size)mark_messages_read(conversation_id, user_id)Acceptance
Dependencies
Notes