Skip to content

Implement community features: Document sharing, activity logs, webhooks, and expiry notifications#447

Merged
mftee merged 1 commit into
CodeGirlsInc:mainfrom
Mkalbani:feat/be-17-18-19-20-cmmty
Apr 26, 2026
Merged

Implement community features: Document sharing, activity logs, webhooks, and expiry notifications#447
mftee merged 1 commit into
CodeGirlsInc:mainfrom
Mkalbani:feat/be-17-18-19-20-cmmty

Conversation

@Mkalbani

@Mkalbani Mkalbani commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Community Features Implementation

Comprehensive implementation of four backend community features to enhance document management, user engagement, and system extensibility.

Issues Resolved

closes #343
closes #344
closes #345
closes #346

Features Implemented

1. [BE-17] Document Expiry Notification Cron Job

Issue: #343

Schedules a daily cron job that emails document owners when their documents have the EXPIRED_DOCUMENT risk flag.

Location: backend/cmmty/expiry-notifier/

Files:

  • expiry-notifier.module.ts - NestJS module with scheduler integration
  • expiry-notifier.service.ts - Daily cron job at 08:00 UTC to identify and notify expired documents
  • expiry-notification-log.entity.ts - Tracks sent notifications to prevent duplicates within 7 days
  • expiry-notifier.service.spec.ts - Unit tests for expiry detection logic

Key Features:

  • Daily scheduled execution at 08:00
  • Identifies documents with EXPIRED_DOCUMENT flag not notified in last 7 days
  • Sends email notifications to document owners via MailService
  • Maintains notification logs to prevent spam

2. [BE-18] User Activity Log Endpoint

Issue: #344

Returns a paginated log of a user's platform activity including logins, uploads, and verifications.

Location: backend/cmmty/user-activity/

Files:

  • user-activity.module.ts - Module configuration
  • user-activity.controller.ts - REST endpoints
  • user-activity.service.ts - Service logic for activity retrieval and filtering
  • user-activity.entity.ts - Activity log entity with action, timestamp, and metadata
  • dto/activity-query.dto.ts - Query parameters for filtering and pagination
  • user-activity.service.spec.ts - Unit tests

Endpoints:

  • GET /cmmty/users/me/activity (JWT protected) - Retrieve paginated activity log with optional action type filtering

Key Features:

  • Cursor-based pagination support
  • Filter by action type via query parameter
  • Captures actions: login, upload, verification, sharing, revocation, etc.
  • Metadata field for additional context

3. [BE-19] Webhook Notification System

Issue: #345

Allows external services to subscribe to SMALDA events and receive HTTP POST callbacks with HMAC-signed payloads.

Location: backend/cmmty/webhooks/

Files:

  • webhooks.module.ts - Module configuration with event integration
  • webhooks.controller.ts - REST endpoints for webhook management
  • webhooks.service.ts - Service with payload signing and delivery logic
  • webhook.entity.ts - Webhook configuration entity (id, url, events, secret, isActive, userId)
  • dto/create-webhook.dto.ts - Input validation DTO
  • webhooks.service.spec.ts - Unit tests for signing and delivery

Endpoints:

  • POST /cmmty/webhooks - Register new webhook
  • DELETE /cmmty/webhooks/:id - Remove webhook
  • Event delivery: HTTP POST with HMAC-SHA256 signature

Key Features:

  • HMAC-signed payloads for secure event delivery
  • Support for multiple subscribed events per webhook
  • Automatic retry mechanism (up to 3 attempts)
  • Active/inactive toggle for webhooks
  • Per-user webhook isolation

4. [BE-20] Document Sharing Between Users

Issue: #346

Allows users to share documents with other registered users, granting read-only access.

Location: backend/cmmty/document-sharing/

Files:

  • document-sharing.module.ts - Module configuration
  • document-sharing.controller.ts - REST endpoints
  • document-sharing.service.ts - Service logic for sharing operations
  • document-share.entity.ts - Share record entity (id, documentId, sharedWithUserId, sharedByUserId, createdAt)
  • dto/share-document.dto.ts - Input validation for sharing
  • dto/shared-documents-query.dto.ts - Query parameters for listing
  • document-sharing.service.spec.ts - Unit tests

Endpoints:

  • POST /cmmty/documents/:id/share - Share document by email
  • DELETE /cmmty/documents/:id/share/:userId - Revoke share access
  • GET /cmmty/documents/shared-with-me - List documents shared with current user

Key Features:

  • Email-based user lookup for sharing
  • Granular access tracking (sharedByUserId, createdAt)
  • Non-destructive revocation (maintains share history)
  • Pagination support for shared document listing

Testing

  • All modules include comprehensive unit test suites (.spec.ts files)
  • Tests cover core business logic: sharing, revocation, activity filtering, webhook delivery, and expiry detection
  • Tests verify proper data validation, error handling, and edge cases

Code Standards

  • All files located within backend/cmmty/ - no modifications outside this folder
  • Consistent NestJS patterns: module, controller, service, entity, DTO architecture
  • TypeScript strict mode compliance
  • Service layer handles all business logic
  • Controllers handle HTTP routing and request validation

Integration Notes

  • Expiry Notifier: Requires MailService integration and scheduler configuration
  • User Activity: Requires activity logging hooks throughout the application
  • Webhooks: Requires integration with application events
  • Document Sharing: Requires integration with document access control layer

Summary

This PR delivers four complementary features that significantly enhance the SMALDA platform:

  1. Proactive notifications for document expiration
  2. Activity visibility for user tracking and audit trails
  3. External integration capability through webhooks
  4. Collaborative features through document sharing

All features follow consistent architecture patterns and include full test coverage.

- [BE-17] Create document expiry notification cron job
- [BE-18] Add user activity log endpoint
- [BE-19] Build webhook notification system
- [BE-20] Implement document sharing between users
@vercel

vercel Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

@Mkalbani is attempting to deploy a commit to the Mftee's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Apr 25, 2026

Copy link
Copy Markdown

@Mkalbani Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mftee mftee merged commit e75ecf4 into CodeGirlsInc:main Apr 26, 2026
1 of 4 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

2 participants