Core recipient selection
Core::RecipientSelection.call(tenant_id:, resource_ids:) returns one entry per
active resource link for the selected resources. It is a read of current state,
not a frozen snapshot or an authorization check. The caller must authenticate,
authorize the operation and resources, and establish TenantContext for the
same tenant. Database RLS remains a separate isolation boundary.
The input must contain at least one positive integer resource ID. Duplicated
resource IDs are ignored. If any requested resource is missing or belongs to a
different tenant, the whole selection raises ActiveRecord::RecordNotFound;
it does not return a partial result. Resources without active links contribute
no entries. The operation validates resources and reads active links in one
database statement, with a consistent statement snapshot.
An entry contains resource_id, resource_link_id, recipient_id, name, phone and phone_input_region. Distinct
links can point to the same recipient, and distinct recipients can share a phone
number, so entries and numbers are intentionally not deduplicated. A phone is
not a verified or normalized delivery destination. Deduplication, destination
normalization and the meaning of recipient counts remain decisions for a later
dispatch and channel design. Selection data includes personal information and
must not be logged.
A future dispatch must freeze the selection transactionally; a preview can change as links start or end. This API does not create dispatches, snapshots, deliveries or messages and does not send communications.
Ruby example
Section titled “Ruby example”After the product has authenticated the caller and authorized the selected resources, the caller establishes the tenant context:
entries = TenantContext.with(authorized_tenant_id) do Core::RecipientSelection.call( tenant_id: authorized_tenant_id, resource_ids: [first_resource_id, second_resource_id] )end
entries.each do |entry| # entry.resource_id, entry.resource_link_id, entry.recipient_id, entry.name, entry.phone, entry.phone_input_region # Handle contact information only within an authorized workflow.endAll IDs above are authorized positive integers, not raw request parameters. The
return value is an array of Core::RecipientSelection::Entry values ordered by
resource ID and then resource-link ID. Each entry describes an active link. A
resource with no active links produces no entries. This call does not check the
user’s membership or product permissions and does not create an HTTP response.