-- Reads the standing of an invitation notice in one statement, for the rights -- check before the send. The recipient is matched by ID; the invitation must -- be addressed to that recipient and belong to the organization of the -- subject, otherwise it is not found. It reads no address and no contact: -- the recipient address is returned only as its comparison key. The hiding -- is the candidate's own current state. The publication is read through the -- effective view, so a publication whose C2 consent was revoked does not count -- as current. A missing account or invitation gives false flags and NULL -- columns. -- name: GetInvitationNoticeStanding :one SELECT (recipient.id IS NOT NULL)::boolean AS recipient_found, coalesce(recipient.email_verified_at IS NOT NULL, false)::boolean AS recipient_email_verified, coalesce(recipient.email_normalized, '')::text AS recipient_email_key, (invitation.id IS NOT NULL)::boolean AS invitation_found, invitation.organization_id AS invitation_organization_id, coalesce(invitation.state, '')::text AS invitation_state, invitation.response_deadline_at AS invitation_response_deadline_at, EXISTS ( SELECT 1 FROM candidate_hidden_organizations AS hidden WHERE hidden.user_id = sqlc.arg(recipient_user_id) AND hidden.organization_id = sqlc.arg(organization_id) )::boolean AS organization_hidden, EXISTS ( SELECT 1 FROM candidate_effective_publications AS publication WHERE publication.user_id = sqlc.arg(recipient_user_id) )::boolean AS publication_published FROM (SELECT sqlc.arg(recipient_user_id)::uuid AS user_id) AS target LEFT JOIN users AS recipient ON recipient.id = target.user_id LEFT JOIN invitations AS invitation ON invitation.id = sqlc.arg(invitation_id) AND invitation.candidate_id = target.user_id AND invitation.organization_id = sqlc.arg(organization_id);