Feat/channel invitation workflow part 3#804
Open
Pranav-d33 wants to merge 4 commits into
Open
Conversation
85d0c52 to
b7b29f0
Compare
b7b29f0 to
51c4561
Compare
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>
51c4561 to
53f5365
Compare
- 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>
a132ce6 to
2aa1f85
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds invitation endpoints to the Channel API — replaces the one-step
add_organizationflow 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})/invitations/invitations/invitations/{id}/invitations/{id}/cancelDesign Decisions
is_admin. List/retrieve is any member (visibility-gated).required_signatures.organization_idsaccepts a list.Key Logic
create_invitation_artifact()calls the creator org's agent atPOST /channels/{name}/invitations/definitionto produce the unsigned channel update artifact. Agent endpoint TBD (PR 4) — service function is written and tested with mocks.Files Changed
src/api-engine/channel/views.py@actionmethods onChannelViewSetsrc/api-engine/channel/serializers.pyChannelInvitationCreateBody.create(), newChannelInvitationCancelSerializersrc/api-engine/channel/service.pycreate_invitation_artifact()agent callsrc/api-engine/channel/tests.pyHow to Test