Recipient preview
Status: implemented internal Ruby read operation with a Visitor staff preview; no confirmation, snapshot, dispatch, provider call or delivery. Preview is a point-in-time result and is not a reservation, authorization to send or proof of delivery. A future dispatch must revalidate the data and handle changes after preview explicitly.
Visitor integration
Section titled “Visitor integration”The caller authenticates the user, rechecks active membership and authorizes the
operation, then establishes TenantContext for the membership tenant. The
Visitor service additionally requires an admin or manager and ensures that
all requested resources are Visitor locations in that tenant. Resource IDs
must be explicit positive integers; empty input is rejected. An existing
location with no active links produces an empty preview.
result = TenantContext.with(membership.tenant_id) do Visitor::RecipientPreview.call( membership: membership, location_ids: authorized_location_ids, policy: :per_destination )endThis example assumes the caller has already rechecked and authorized the
membership and locations. It is not a public HTTP API. The service raises
SecurityError for insufficient role, ArgumentError for invalid input or
policy, and ActiveRecord::RecordNotFound if any requested location is absent,
belongs to another tenant or is not a Visitor location. It never silently
returns a partial selection.
Results and policies
Section titled “Results and policies”The result includes one entries item per active resource link, including the
source resource and link IDs, recipient ID, original name and phone,
normalization status, reason and normalization version. issues contains all
entries marked invalid or needs_review. A historical national-format
number without saved region is needs_review with reason region_required;
explicit + numbers are checked without guessing a region. Invalid input is
invalid, and an invalid recorded region is needs_review. Each link is kept,
even if multiple links have the same recipient or number.
groups describe potential logical deliveries and retain contributing
recipient IDs and link IDs:
:per_destinationgroups by normalized SMS destination.:per_recipientgroups by distinct recipient ID; two people with the same number can therefore produce two potential deliveries.
selected_link_count counts link entries, potential_delivery_count counts
groups, and unique_destination_count counts distinct valid normalized numbers.
Those counts are different concepts and none means a message has been accepted
or delivered. exclusion_confirmation_required? is true if there are issues;
it is a signal for a future workflow, not an operator decision. A future product
must prevent sending without explicit confirmation when excluding recipients,
and must not create a dispatch when no valid destinations remain. These rules
are not enforced by this read-only preview.
Boundary and caveats
Section titled “Boundary and caveats”Core::RecipientPreview groups a previously authorized selection using an
injected normalizer and does not depend on SMS or Visitor. The SMS adapter
Channels::Sms::PreviewNormalizer invokes the current phone-number normalizer
and supplies typed assessments. It revalidates the original phone with the
saved region rather than silently trusting previously stored normalized data;
it does not alter recipients. Metadata updates may therefore change previews.
The selection of resources, links and recipient attributes is performed in one SQL statement. This does not freeze presence: data can change immediately after that read. A snapshot, reporting changes since preview and concurrency semantics remain future work; presence changes alone must not block sending. Return values contain sensitive contact data: do not log results or expose them outside authorized product workflows. Format validation does not verify ownership, reachability or SMS capability.
Visitor staff view
Section titled “Visitor staff view”Admins and managers can open the preview from the visitors overview, choose
Visitor locations, and inspect the :per_destination results. The screen counts
distinct recipients, potential SMS destinations, grouped duplicates (eligible
distinct recipients minus unique destinations), and distinct recipients with
issues. Rows describe resource links, so the same recipient can appear once per
location. Phone and issue data is shown only in the authenticated tenant context;
HTTP and Turbo caching are disabled for the preview. No message is sent or
stored by opening it. The view currently renders all entries returned by the
preview and does not paginate them.