Skip to content

[BE-39] In-app messaging: backend #1225

Description

@yusuftomilola

Overview

Members and admins have no direct communication channel within the platform. Members can only contact the hub via the public contact form which has no thread history. In-app messaging enables member-to-admin and member-to-member communication with full history.

Context

  • NotificationsModule: backend/src/notifications/ — emit real-time event on new message
  • WebSocket gateway (BE-01): backend/src/notifications/gateway/notifications.gateway.ts
  • User entity: backend/src/users/entities/user.entity.ts

Tasks

  • Create MessageThread entity: id, participantIds (JSON array of User IDs), lastMessageAt (timestamptz), createdAt
  • Create Message entity: id, threadId (FK), senderUserId (FK), body (text), isRead (bool, default false), sentAt (timestamptz)
  • POST /messages/threads — start a thread by specifying one or more participant user IDs (authenticated member or admin)
  • GET /messages/threads — list the current user's threads, sorted by lastMessageAt desc, each including the last message preview
  • GET /messages/threads/:id/messages — paginated message history for a thread (participants only)
  • POST /messages/threads/:id/messages — send a message; updates lastMessageAt on the thread; emits a new-message WebSocket event to all participants
  • PATCH /messages/threads/:id/read — mark all unread messages in the thread as read (for current user)
  • GET /messages/unread-count — returns total unread message count for the current user (for badge display)

Files to Modify / Create

  • New: backend/src/messaging/ (module, entities, controller, service, providers)
  • backend/src/app.module.ts

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions