Skip to content

Feat/channel invitation workflow part 3#804

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

Feat/channel invitation workflow part 3#804
Pranav-d33 wants to merge 4 commits into
hyperledger-cello:mainfrom
Pranav-d33:feat/channel-invitation-workflow-part-3

Conversation

@Pranav-d33

Copy link
Copy Markdown
Contributor

Adds invitation endpoints to the Channel API — replaces the one-step add_organization flow with a proper Fabric channel update workflow where current members create artifacts, collect signatures, and invitees join.

What's Implemented

New Endpoints (on /api/v1/channels/{channel_id})

Method URL Action Auth
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 Admin or invited org

Design Decisions

Question Decision
Admin-only mutations? Yes — create/cancel require is_admin. List/retrieve is any member (visibility-gated).
Signature threshold All current members by default. Creator can override via required_signatures.
One or multiple invitees? Multipleorganization_ids accepts a list.
Retry on failure? No — cancel and re-create.
Cancelable states? DRAFT, SIGNING, FAILED, READY — not once ACCEPTED/REJECTED/CANCELED.
Cancel vs Reject (PR 6)? Cancel hard-stops the whole invitation. Reject is per-invitee decline.
Who can cancel? Channel member admin (any org) or invited org (only their own invitation).

Key Logic

  • Artifact generation: create_invitation_artifact() calls the creator org's agent at POST /channels/{name}/invitations/definition to produce the unsigned channel update artifact. Agent endpoint TBD (PR 4) — service function is written and tested with mocks.
  • No partial state: Agent is called first (outside transaction). DB records created only on success.
  • Duplicate protection: Rejects creation if any invitee org already has a PENDING invitee record on an active (DRAFT/SIGNING/READY) invitation.
  • Visibility: Members see all invitations on their channels. Invitees see only READY+/ACCEPTED/REJECTED/FAILED. Unrelated orgs see nothing.

Files Changed

File Change
src/api-engine/channel/views.py 3 @action methods on ChannelViewSet
src/api-engine/channel/serializers.py Updated ChannelInvitationCreateBody.create(), new ChannelInvitationCancelSerializer
src/api-engine/channel/service.py New create_invitation_artifact() agent call
src/api-engine/channel/tests.py 12 endpoint tests (APIClient + JWT)

How to Test

cd src/api-engine
python manage.py test channel
Stacking
This PR is stacked on feat/channel-invitation-workflow-part-2 (models + serializers). The PR diff against main shows only the new endpoint changes. Next in stack: PR 4 (Fabric agent artifact generation endpoints). 

@Pranav-d33 Pranav-d33 force-pushed the feat/channel-invitation-workflow-part-3 branch from 85d0c52 to b7b29f0 Compare June 10, 2026 11:42
@ryjones ryjones force-pushed the feat/channel-invitation-workflow-part-3 branch from b7b29f0 to 51c4561 Compare June 17, 2026 21:57
@ryjones ryjones requested a review from a team June 17, 2026 22:08
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>
@ryjones ryjones force-pushed the feat/channel-invitation-workflow-part-3 branch from 51c4561 to 53f5365 Compare June 18, 2026 08:24
- 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>
@Pranav-d33 Pranav-d33 force-pushed the feat/channel-invitation-workflow-part-3 branch from a132ce6 to 2aa1f85 Compare June 18, 2026 18:59
@yeasy yeasy requested a review from YoungHypo June 30, 2026 12:03
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.

2 participants