feat(invitations): accept invitations with C4 consent and contact grants; share the E0 quota across holdings

This commit is contained in:
shira committed 2026-10-09 18:03:35 +03:00
1 parent a5990d3fc6
commit 676b3c6e24
59 files changed
+4926 -194

No files matched your search

@@ -9,6 +9,7 @@ import (
"fmt"
"net/http"
"net/http/httptest"
"slices"
"strings"
"testing"
"time"
@@ -254,9 +255,25 @@ func TestCandidateInvitationViewAndDeclineOverHTTP(t *testing.T) {
read := request(http.MethodGet, myPath(sent.ID), "", sessionTarget, "")
opened := decodeCandidateInvitationHTTP(t, read, http.StatusOK)
requireNoCandidateData("candidate read", read.Body.String())
// While an acceptance is possible the read offers the consent C4 with
// the kinds that the profile holds, and no grant exists yet.
var offer struct {
Text struct {
TextVersion string `json:"text_version"`
Text string `json:"text"`
} `json:"text"`
AvailableFields []string `json:"available_fields"`
}
if err := json.Unmarshal(opened.ContactConsent, &offer); err != nil {
t.Fatalf("decode contact consent %s: %v", opened.ContactConsent, err)
}
if strings.Contains(offer.Text.Text, "{organization}") || !strings.Contains(offer.Text.Text, nameA) ||
offer.Text.TextVersion != "c4-2026-10-01" || !slices.Equal(offer.AvailableFields, []string{"full_name", "email"}) {
t.Fatalf("contact consent = %+v, want the C4 text for the organization and the held kinds", offer)
}
if opened.State != "delivered" || opened.Version != sent.Version || opened.ViewedAt != nil || opened.Organization.ID != orgA ||
opened.Organization.Name != nameA || opened.ResponseDeadlineAt != *sent.ResponseDeadlineAt || opened.Decline != nil ||
string(opened.ContactConsent) != "null" || string(opened.ContactGrant) != "null" || len(opened.Terms) == 0 {
string(opened.ContactGrant) != "null" || len(opened.Terms) == 0 {
t.Fatalf("read = %+v, want the delivered invitation with its terms and no side effect", opened)
}
// A read records nothing: it is free of side effects by contract.