Skip to content

Messaging#79

Merged
A1L13N merged 2 commits into
alphaonelabs:mainfrom
Ananya44444:message
Jul 23, 2026
Merged

Messaging#79
A1L13N merged 2 commits into
alphaonelabs:mainfrom
Ananya44444:message

Conversation

@Ananya44444

@Ananya44444 Ananya44444 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-07-23.195701.mp4

Summary

Extends the platform's messaging capabilities with a privacy-focused direct messaging system. Users can initiate direct message requests via exact email lookup or through shared activity enrollment. Reuses existing encrypted record storage (legacy_records) with model aliasing (web.Message / web.PeerMessage).

Key Changes

  • Database & Schema:
    • Added message_requests table ([schema.sql], [migrations/0012_add_message_requests.sql], [src/worker.py]) with indexes on target user, sender, and activity.
  • Backend API Endpoints ([src/worker.py]):
    • POST /api/messages/request: Email-initiated request with HMAC blind index lookup, 5 req/hr rate limiting, and neutral privacy response.
    • PATCH /api/messages/request/:id: Accept or decline incoming message requests.
    • GET /api/messages/requests: List pending requests for authenticated recipient showing sender name.
    • GET /api/messages/threads: List active accepted conversation threads with unread indicators.
    • GET /api/messages/threads/:id: Fetch decrypted message history and mark thread notifications as read.
    • POST /api/messages/threads/:id/send: Send AES-256-GCM encrypted direct messages.
    • GET /api/activities/:id/contacts & POST /api/activities/:id/message/:user_id: Enable activity participants and creators to connect directly.
  • Frontend UI ([public/messages.html], [public/js/messaging.js], [public/activity-detail.html]):
    • Added New Message Email Request form and Pending Requests list.
    • Added Active Conversations section with pulsing red dot unread indicators.
    • Interactive chat modal displaying left-aligned received messages and right-aligned sent messages ("You").
    • Auto-polling every 4s for real-time chat updates.
    • "Message" / "View conversation" buttons on activity participant cards.
  • Tests ([tests/test_messaging.py]):
    • Added 7 unit tests covering request flows, neutral privacy responses, rate limits, acceptance, listing, and messaging. All pass.

Summary

Adds a privacy-focused direct messaging system with request-based communication, encrypted conversations, and activity participant messaging.

Key changes

  • Added message_requests schema, indexes, and privacy-preserving email lookup with rate limiting.
  • Introduced APIs for sending/responding to requests, listing conversations, retrieving history, and sending encrypted messages.
  • Added activity-based contact discovery and messaging actions.
  • Reworked the Messages page with pending requests, active conversations, unread indicators, polling, and chat modal UI.
  • Added seven unit tests covering authentication, privacy responses, rate limits, request acceptance, listings, and message sending.

User impact

Users can initiate and manage direct conversations by email or through activities, with privacy-neutral responses and encrypted message storage.

Copilot AI review requested due to automatic review settings July 23, 2026 16:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Ananya44444, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository: alphaonelabs/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3a738707-3379-430b-8050-52f6fb2cab5b

📥 Commits

Reviewing files that changed from the base of the PR and between dcd2fd2 and c1d03b4.

⛔ Files ignored due to path filters (1)
  • migrations/0012_add_message_requests.sql is excluded by !**/migrations/**
📒 Files selected for processing (6)
  • public/activity-detail.html
  • public/js/messaging.js
  • public/messages.html
  • schema.sql
  • src/worker.py
  • tests/test_messaging.py

Walkthrough

Adds privacy-first direct messaging with request storage, authenticated request and thread APIs, activity participant contact actions, a Messages page chat interface, encrypted legacy-record persistence, notifications, and endpoint tests.

Changes

Privacy-first messaging

Layer / File(s) Summary
Messaging storage and record compatibility
schema.sql, src/worker.py
Adds the message_requests table and indexes, marks message models as sensitive, and aliases newer message models to legacy peer-message records.
Messaging API and routing
src/worker.py
Adds request, activity-contact, thread, history, and send handlers with authentication, rate limiting, encrypted persistence, notifications, and dispatcher routes.
Activity and direct messaging UI
public/activity-detail.html, public/messages.html, public/js/messaging.js
Adds activity contact actions, request management, active conversations, chat history, message sending, email-based requests, and periodic refresh behavior.
Messaging endpoint validation
tests/test_messaging.py
Tests authentication, neutral unknown-email responses, rate limiting, request acceptance, request listing, thread listing, and thread message sending.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant MessagesPage
  participant MessagingAPI
  participant MessageRequests
  participant MessageThreads
  User->>MessagesPage: Submit message request
  MessagesPage->>MessagingAPI: POST request
  MessagingAPI->>MessageRequests: Create pending request
  User->>MessagesPage: Accept request
  MessagesPage->>MessagingAPI: PATCH request
  MessagingAPI->>MessageRequests: Update status
  User->>MessagesPage: Send chat message
  MessagesPage->>MessagingAPI: POST thread message
  MessagingAPI->>MessageThreads: Store encrypted message
  MessagesPage->>MessagingAPI: GET thread history
  MessagingAPI->>MessageThreads: Decrypt and return messages
Loading

Suggested reviewers: a1l13n, ghanshyam2005singh

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is too generic to describe the substantial direct messaging changes in this PR. Rename it to something specific like "Add direct messaging requests and conversations".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Ananya44444

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@public/js/messaging.js`:
- Around line 317-331: Improve the polling interval in the DOMContentLoaded
handler so it skips loadActiveThreads, loadPendingRequests, and
refreshChatHistory when document.hidden is true, preventing unnecessary
background requests and DOM replacement while the tab is hidden.

In `@public/messages.html`:
- Line 48: Both inputs in public/messages.html need accessible names: update the
recipient email input at lines 48-48 and the chat message input at lines 96-101
with an aria-label or visually hidden label, using descriptive text such as
“Recipient email address” and “Type a message.”
- Around line 85-103: Update the chat modal container in public/messages.html
lines 85-103 with role="dialog", aria-modal="true", and
aria-labelledby="chat-title". In the chat modal open/close behavior around
public/js/messaging.js lines 220-261, add Escape-key dismissal, move focus into
the modal when opened, and restore focus to the previously focused element when
closed; optionally support closing by clicking the backdrop.

In `@schema.sql`:
- Around line 151-161: Strengthen the message_requests schema by enforcing one
request per user pair at the database level with a partial unique index that
normalizes from_user_id and to_user_id and excludes any intended non-active or
deleted states. Add an activity_id foreign key referencing the activities table
with the appropriate delete behavior, while preserving the existing user foreign
keys and defaults.

In `@src/worker.py`:
- Around line 6771-6789: Replace the per-row user lookups in
api_list_message_requests (src/worker.py lines 6771-6789), api_activity_contacts
(src/worker.py lines 6836-6859), and api_list_message_threads (src/worker.py
lines 6992-7016) with batched users queries using the collected IDs, then build
ID-to-display-name maps before assembling responses; for
api_list_message_threads, also consider aggregating the per-thread unread check.
- Around line 6817-6859: Restrict the contact-discovery flow after the access
check so users admitted solely through their interest cannot enumerate activity
participants or receive decrypted names. Update the gate and surrounding logic
to require verified enrollment or host status for participant lookup, or
otherwise withhold names until the relevant message request is mutually
accepted; preserve existing behavior for hosts and enrollees.
- Around line 6900-6903: Update the auto-created message request in the activity
flow to preserve recipient consent: insert it with a pending status instead of
accepted, while keeping the existing request identifiers, participants, source,
activity, and timestamp unchanged. Ensure the recipient must explicitly accept
before the thread becomes open and writable.
- Around line 6746-6755: Update api_respond_to_message_request so its
message_requests UPDATE only matches rows whose current status is 'pending'. Use
the update result to detect when no pending row was changed and return the
appropriate existing not-found or no-op response, preventing accepted or
declined requests from transitioning again.
- Around line 7057-7090: Update the legacy message-history fallback around the
query and row-processing logic to persist or otherwise expose each record’s
thread identifier as a queryable legacy_records column, then filter by the
requested thread_id in SQL before decrypting rows. Remove the
sender/receiver-only fallback that can mix messages from other threads, combine
the equivalent is_match conditions, and replace the per-row blind exception
suppression with explicit handling that preserves the existing outer
missing-table behavior while surfacing decryption or parsing failures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: alphaonelabs/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0b08d79c-3323-4489-97d9-3741295b37b3

📥 Commits

Reviewing files that changed from the base of the PR and between 01c9528 and dcd2fd2.

⛔ Files ignored due to path filters (1)
  • migrations/0012_add_message_requests.sql is excluded by !**/migrations/**
📒 Files selected for processing (6)
  • public/activity-detail.html
  • public/js/messaging.js
  • public/messages.html
  • schema.sql
  • src/worker.py
  • tests/test_messaging.py

Comment thread public/js/messaging.js
Comment thread public/messages.html Outdated
Comment thread public/messages.html Outdated
Comment thread schema.sql
Comment thread src/worker.py
Comment thread src/worker.py Outdated
Comment thread src/worker.py Outdated
Comment thread src/worker.py
Comment thread src/worker.py
@A1L13N
A1L13N merged commit 747ff17 into alphaonelabs:main Jul 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants