Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-19162-hub-customer-match.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Hub: per-hive customer match endpoint, consent only** ([#19162](https://github.com/hivecommons/hive/issues/19162)). `POST /api/customers/match` lets a hive, under its own per-hive heartbeat bearer, post salted hashes of its confirmed customers' GitHub logins and get back real name, organization and country only for people who consented to that hive, only for values they entered themselves, checked at answer time. Unknown and unconsented people get the same empty answer; a `cleared` entry is sent only after an earlier delivery. Batch, body, response and rate limits are named constants, deliveries are stamped on the consent record, and the route does not exist while `HIVE_HUB_CUSTOMERS_SHARE_ENABLED` is off. No spoke calls it yet.
5 changes: 5 additions & 0 deletions src/pkg/hub/customer_consent.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ func (s *HubServer) registerCustomerSharingRoutes() {
s.mux.HandleFunc("GET /api/saas/me/profile-share/consents", s.requireCustomerSharing(s.handleListCustomerConsents))
s.mux.HandleFunc("POST /api/saas/me/profile-share/consents/{id}", s.requireCustomerSharing(s.handleChangeCustomerConsent))
s.mux.HandleFunc("DELETE /api/saas/me/profile-share/consents/{id}", s.requireCustomerSharing(s.handleChangeCustomerConsent))
// Hive-facing: per-hive bearer, not a session. The handler answers 404
// while the sharing switch is off, like the routes above (#19162).
s.mux.HandleFunc("POST "+customerMatchPath, s.handleCustomerMatch)
}

type customerConsentHive struct {
Expand Down Expand Up @@ -217,6 +220,8 @@ func (s *HubServer) handleChangeCustomerConsent(w http.ResponseWriter, r *http.R
s.customerConsentError(w, err)
return
}
// A new grant must not wait out the match index cache.
invalidateCustomerMatchIndex()
s.logger.Info("audit: customer consent "+action, "person", consent.Person, "hive", hiveID, "fields", auditFields.names())
w.WriteHeader(http.StatusNoContent)
}
Expand Down
10 changes: 7 additions & 3 deletions src/pkg/hub/customer_consent_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ type customerConsent struct {
GrantedAt time.Time `json:"granted_at"`
UpdatedAt time.Time `json:"updated_at"`
WithdrawnAt *time.Time `json:"withdrawn_at,omitempty"`
// Only the delivery path (phase 2) may stamp these times.
FirstDeliveredAt *time.Time `json:"first_delivered_at,omitempty"`
LastDeliveredAt *time.Time `json:"last_delivered_at,omitempty"`
// Only the delivery path (stampCustomerDelivery, customer_match.go) may
// stamp these. DeliveredFields is the union of every field ever sent to
// this hive; DeliveredRev is the rev of the last answer.
FirstDeliveredAt *time.Time `json:"first_delivered_at,omitempty"`
LastDeliveredAt *time.Time `json:"last_delivered_at,omitempty"`
DeliveredFields *customerConsentFields `json:"delivered_fields,omitempty"`
DeliveredRev string `json:"delivered_rev,omitempty"`
}

func (c customerConsent) discardable(now time.Time) bool {
Expand Down
Loading
Loading