feat(notifications): send product notifications with a rights check right before each send
This commit is contained in:
1 parent
a856066316
commit
623d41b969
59 files changed
+4125
-1126
No files matched your search
@@ -0,0 +1,86 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: notification_rights.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getInvitationNoticeStanding = `-- 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 = $1
|
||||
AND hidden.organization_id = $2
|
||||
)::boolean AS organization_hidden,
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM candidate_effective_publications AS publication
|
||||
WHERE publication.user_id = $1
|
||||
)::boolean AS publication_published
|
||||
FROM (SELECT $1::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 = $3
|
||||
AND invitation.candidate_id = target.user_id
|
||||
AND invitation.organization_id = $2
|
||||
`
|
||||
|
||||
type GetInvitationNoticeStandingParams struct {
|
||||
RecipientUserID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
InvitationID pgtype.UUID
|
||||
}
|
||||
|
||||
type GetInvitationNoticeStandingRow struct {
|
||||
RecipientFound bool
|
||||
RecipientEmailVerified bool
|
||||
RecipientEmailKey string
|
||||
InvitationFound bool
|
||||
InvitationOrganizationID pgtype.UUID
|
||||
InvitationState string
|
||||
InvitationResponseDeadlineAt pgtype.Timestamptz
|
||||
OrganizationHidden bool
|
||||
PublicationPublished bool
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (q *Queries) GetInvitationNoticeStanding(ctx context.Context, arg GetInvitationNoticeStandingParams) (GetInvitationNoticeStandingRow, error) {
|
||||
row := q.db.QueryRow(ctx, getInvitationNoticeStanding, arg.RecipientUserID, arg.OrganizationID, arg.InvitationID)
|
||||
var i GetInvitationNoticeStandingRow
|
||||
err := row.Scan(
|
||||
&i.RecipientFound,
|
||||
&i.RecipientEmailVerified,
|
||||
&i.RecipientEmailKey,
|
||||
&i.InvitationFound,
|
||||
&i.InvitationOrganizationID,
|
||||
&i.InvitationState,
|
||||
&i.InvitationResponseDeadlineAt,
|
||||
&i.OrganizationHidden,
|
||||
&i.PublicationPublished,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
Reference in new issue
Block a user