Skip to content

Feat/channel invitation workflow part 5#809

Open
Pranav-d33 wants to merge 6 commits into
hyperledger-cello:mainfrom
Pranav-d33:feat/channel-invitation-workflow-part-5
Open

Feat/channel invitation workflow part 5#809
Pranav-d33 wants to merge 6 commits into
hyperledger-cello:mainfrom
Pranav-d33:feat/channel-invitation-workflow-part-5

Conversation

@Pranav-d33

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
Adds invitation endpoints to the Channel API — replaces the one-step `add_organization` flow with a proper Fabric channel update workflow.

### New Endpoints

- GET /invitations - List invitations visible to org (any member)
- POST /invitations - Create invitation + generate artifact (admin)
- GET /invitations/{id} - Retrieve invitation details (visibility-gated)
- POST /invitations/{id}/cancel - Cancel invitation (member-admin only)

### Design Decisions

- Admin-only mutations: create/cancel require is_admin
- Signature threshold: all current members by default, overridable
- Cancelable states: DRAFT, SIGNING, FAILED, READY
- Cancel vs Reject (PR 6): Cancel hard-stops the whole invitation. Reject is per-invitee decline.
- Who can cancel: Channel member admin only
- Duplicate protection: Rejects if invitee has PENDING invitee on active invitation
- Reinvite allowed after CANCELED or REJECTED

### Files

views.py: 3 @action methods + helpers
serializers.py: create calls agent, CancelSerializer, duplicate validation
service.py: create_invitation_artifact() agent call
tests.py: 12 endpoint tests (APIClient+JWT), 13 model tests with mocks

Test: 32/32 pass, flake8 clean.

Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
- Add msp_id field to Organization (auto-derives from name as fallback)
- Update create_invitation_artifact to pass o.msp_id instead of str(o.id)
- Update auth serializer and org service to accept msp_id
- Fix pre-existing enum metaclass crash on Python 3.13
- Fix missing max_length on Organization and Chaincode CharFields
- Add proper error handling for agent failures in view

Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
Adds POST /channels/{channel_name}/invitations/definition on the Fabric agent.

Service generates unsigned channel update artifact:
  1. Fetch + decode channel config
  2. Build org group entries (MSP + AnchorPeers) with base64 PEM certs
  3. Compute config update diff via configtxlator
  4. Wrap in unsigned envelope, encode to protobuf
  5. Return bytes, clean up temp files

Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
@Pranav-d33 Pranav-d33 requested a review from a team as a code owner June 19, 2026 08:42
@Pranav-d33 Pranav-d33 force-pushed the feat/channel-invitation-workflow-part-5 branch from 58cc347 to 38c4faa Compare June 19, 2026 09:02
- Fabric agent: sign_config_update() service, InvitationSignSerializer, invitation_sign endpoint
- API engine: sign_invitation_artifact() service, ChannelInvitationSignSerializer, sign_invitation endpoint
- Auto-transitions DRAFT->SIGNING->READY at signature threshold; FAILED on agent error
- 42 API engine tests pass (8 new sign tests + 34 existing)
- Fix: invitations POST returning 200 instead of 201 (pre-existing bug)
- Fix: sign endpoint returning 403 instead of 404 for non-members
- Add test_settings.py for SQLite-based local test runs

Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
Fabric agent:
- join_channel() service: submits signed config update, fetches block, joins peer
- InvitationJoinSerializer, invitation_join endpoint (POST .../invitations/join)

API engine:
- accept_invitation() service helper: contacts agent join endpoint
- ChannelInvitationAcceptSerializer: validates READY status + PENDING invitee,
  calls agent, adds org to channel, marks ACCEPTED
- ChannelInvitationRejectSerializer: validates READY status + PENDING invitee,
  marks REJECTED (no agent call)
- accept_invitation and reject_invitation view actions with 404/400/500 handling
- 49 channel tests pass (7 new accept/reject tests + 42 existing)

Signed-off-by: Pranav dhiran <dhiranpranav72@gmail.com>
@Pranav-d33 Pranav-d33 force-pushed the feat/channel-invitation-workflow-part-5 branch from 38c4faa to 2eee94c Compare June 19, 2026 09:20
@yeasy yeasy requested a review from YoungHypo June 30, 2026 12:07
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.

1 participant