feat(invitations): check contact grants on every read, cap pending invitations, and expire them at the deadline
This commit is contained in:
1 parent
676b3c6e24
commit
12a7213d4a
67 files changed
+4255
-149
No files matched your search
@@ -11,6 +11,7 @@ import (
|
||||
"lincodex/backend/internal/adapter/secondary/prometheus"
|
||||
"lincodex/backend/internal/port/inbound"
|
||||
"lincodex/backend/internal/usecase/assessment"
|
||||
"lincodex/backend/internal/usecase/invitation"
|
||||
"lincodex/backend/internal/worker/jobrunner"
|
||||
"lincodex/backend/internal/worker/retry"
|
||||
)
|
||||
@@ -32,10 +33,14 @@ var _ jobrunner.Metrics = (*prometheus.Metrics)(nil)
|
||||
// jobHandlers lists the scheduled job handlers, one per kind. A product
|
||||
// module adds its handler here, and the worker then claims jobs of that kind
|
||||
// with the next deployment. Jobs of a kind without a handler wait in the
|
||||
// database. The only kind now is the computation of the assessment review
|
||||
// band, which can never block or change a result.
|
||||
// database. The kinds are the computation of the assessment review band, which
|
||||
// can never block or change a result, and the expiry of an invitation at its
|
||||
// response deadline.
|
||||
func jobHandlers(logger *slog.Logger) []inbound.JobHandler {
|
||||
return []inbound.JobHandler{assessment.NewSignalReviewJob(logger)}
|
||||
return []inbound.JobHandler{
|
||||
assessment.NewSignalReviewJob(logger),
|
||||
invitation.NewResponseDeadlineJob(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
func newJobWorker(
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -55,10 +56,14 @@ func TestBuildJobWorkerSkipsWithoutWork(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBootstrapRegistersTheReviewJobKind(t *testing.T) {
|
||||
func TestBootstrapRegistersTheProductJobKinds(t *testing.T) {
|
||||
handlers := jobHandlers(slog.New(slog.DiscardHandler))
|
||||
if len(handlers) != 1 || handlers[0].JobKind() != "assessment.signal_review" {
|
||||
t.Fatalf("jobHandlers() = %v; update the documentation when the registered job kinds change", handlers)
|
||||
kinds := make([]string, 0, len(handlers))
|
||||
for _, handler := range handlers {
|
||||
kinds = append(kinds, handler.JobKind())
|
||||
}
|
||||
if !slices.Equal(kinds, []string{"assessment.signal_review", "invitation.response_deadline"}) {
|
||||
t.Fatalf("jobHandlers() kinds = %v; update the documentation when the registered job kinds change", kinds)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user