Skip to content

feat(consents): implement comprehensive consents API with GDPR and HB 805 support#132

Merged
erkinalp merged 1 commit intodefaultfrom
devin/1770139695-consents-api
Feb 4, 2026
Merged

feat(consents): implement comprehensive consents API with GDPR and HB 805 support#132
erkinalp merged 1 commit intodefaultfrom
devin/1770139695-consents-api

Conversation

@devin-ai-integration
Copy link

Summary

Implements a comprehensive consents API that supports both GDPR compliance and North Carolina HB 805 requirements for multi-person content consent. The API provides:

  • Extended UserConsent entity with new fields: consent_type, status, item_id, target_user_id (for HB 805 pairwise consents), basis_document_url/hash (for off-platform consent references), and extra_data for extensibility
  • New ConsentGrant entity for GNAP-like (RFC 9635) grant negotiation flows with status tracking, continuation tokens, and access tokens
  • New consent-grants routes (/users/@me/consent-grants/) for interactive consent negotiation: request, approve, deny, continue, and cancel operations
  • Updated consent routes with filtering by item_id and target_user_id to support per-item pairwise consent model
  • PostgreSQL migration for the new schema

Key design decisions:

  • HB 805 pairwise consents are O(n²) where n is number of persons - each person must consent to each other person for each specific item
  • GDPR compliance: consent retraction is as easy as granting (status changes to RETRACTED, record retained for audit)
  • Uses extra_data field name instead of metadata to avoid TypeORM BaseClass property conflict

Review & Testing Checklist for Human

  • Database migration safety: Verify the migration handles existing consent data correctly, especially the unique index change from (user_id, service_id) to (user_id, service_id, consent_type, item_id, target_user_id) with nullable fields
  • Request body schemas: The routes reference schemas (ConsentGrantRequestSchema, UserConsentGrantSchema, etc.) that may need to be created in src/schemas/ for proper validation
  • Multi-database support: Only PostgreSQL migration is included - MySQL/MariaDB/SQLite migrations should be added before production use
  • GNAP flow testing: Test the full grant negotiation flow: POST request → GET status → POST approve/deny → verify UserConsent created
  • HB 805 pairwise model: Test creating multiple consent records for the same item with different target_user_id values

Recommended test plan:

  1. Run the PostgreSQL migration on a test database
  2. Create a consent with target_user_id for HB 805 pairwise model
  3. Test the grant negotiation flow: request → approve → verify consent created
  4. Test consent retraction and verify status changes to RETRACTED

Notes

… 805 support

- Add ConsentType enum (MEDIA_ITEM, MESSAGE_ITEM, EXTERNAL_DATA_PROCESSING, BOTS_AI, CUSTOM)
- Add ConsentStatus enum (PENDING, GRANTED, PROVISIONAL, RETRACTED)
- Extend UserConsent entity with target_user_id for HB 805 pairwise consents (O(n²))
- Add basis_document_url/hash fields for off-platform consent references
- Create ConsentGrant entity for GNAP-like grant negotiation (RFC 9635)
- Add consent-grants routes for interactive consent negotiation flow
- Update consent routes to support item_id and target_user_id filtering
- Add UNKNOWN_CONSENT and UNKNOWN_CONSENT_GRANT errors to Constants
- Add PostgreSQL migration for new consent fields and consent_grants table

Co-authored-by: Erkin Alp Güney <erkinalp9035@gmail.com>
@devin-ai-integration
Copy link
Author

Original prompt from Erkin
Implement a consents API in the `anticensor` repository. The API should be designed to handle various types of consents, such as media (per-item), messages (per-item), external data processing, and bots&AI, and be extensible to accommodate future consent types.

- The implementation must be compatible with GDPR, allowing users to retract their consent as easily as they grant it.
- The implementation must also be compatible with North Carolina 2025 HB 832, including functionality for provisional consent grants and retractions.
- Refer to the specifications outlined in https://github.com/spacebarchat/server/issues/1003 for detailed requirements.

Submit your work as a pull request. Ensure all tests pass and the code is linted.

You only need to look in the following repo: erkinalp/anticensor

@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@erkinalp erkinalp requested review from deffcolony and removed request for erkinalp February 3, 2026 17:49
@erkinalp erkinalp assigned deffcolony and unassigned erkinalp Feb 3, 2026
@erkinalp erkinalp merged commit 01402ba into default Feb 4, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants