feat(notification): add Resend quota gate and waiting-for-reset state
This commit is contained in:
1 parent
3b917befa9
commit
b856d4ff54
40 files changed
+4116
-48
No files matched your search
@@ -80,6 +80,53 @@ func (q *Queries) GetDeliveryByID(ctx context.Context, id pgtype.UUID) (Delivery
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getLatestDeliveryStatus = `-- name: GetLatestDeliveryStatus :one
|
||||
SELECT
|
||||
id,
|
||||
kind,
|
||||
status,
|
||||
next_attempt_at,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM deliveries
|
||||
WHERE
|
||||
recipient_user_id = $1
|
||||
AND kind = $2
|
||||
ORDER BY created_at DESC, id DESC
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetLatestDeliveryStatusParams struct {
|
||||
RecipientUserID pgtype.UUID
|
||||
Kind string
|
||||
}
|
||||
|
||||
type GetLatestDeliveryStatusRow struct {
|
||||
ID pgtype.UUID
|
||||
Kind string
|
||||
Status string
|
||||
NextAttemptAt pgtype.Timestamptz
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// Reads the status of the newest delivery of a kind addressed to an account,
|
||||
// for the account's own view of its mail. It selects no address and no
|
||||
// content. The recipient index narrows the scan to the account's rows.
|
||||
func (q *Queries) GetLatestDeliveryStatus(ctx context.Context, arg GetLatestDeliveryStatusParams) (GetLatestDeliveryStatusRow, error) {
|
||||
row := q.db.QueryRow(ctx, getLatestDeliveryStatus, arg.RecipientUserID, arg.Kind)
|
||||
var i GetLatestDeliveryStatusRow
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Kind,
|
||||
&i.Status,
|
||||
&i.NextAttemptAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertDelivery = `-- name: InsertDelivery :execrows
|
||||
INSERT INTO deliveries (
|
||||
id,
|
||||
|
||||
Reference in new issue
Block a user