@@ -46,10 +46,10 @@ abstract class ConsentKind {
4646/// Represents the backend for the consent handling and authentication.
4747class ConsentBackend {
4848 final DatastoreDB _db;
49- final _actions = < String , ConsentAction > {
50- ConsentKind .packageUploader: _PackageUploaderAction (),
51- ConsentKind .publisherContact: _PublisherContactAction (),
52- ConsentKind .publisherMember: _PublisherMemberAction (),
49+ late final _actions = < String , ConsentAction > {
50+ ConsentKind .packageUploader: _PackageUploaderAction (_db ),
51+ ConsentKind .publisherContact: _PublisherContactAction (_db ),
52+ ConsentKind .publisherMember: _PublisherMemberAction (_db ),
5353 };
5454
5555 ConsentBackend (this ._db);
@@ -316,6 +316,9 @@ abstract class ConsentAction {
316316
317317/// Callbacks for package uploader consents.
318318class _PackageUploaderAction extends ConsentAction {
319+ final DatastoreDB _db;
320+ _PackageUploaderAction (this ._db);
321+
319322 @override
320323 Future <void > onAccept (Consent consent) async {
321324 final packageName = consent.args! [0 ];
@@ -335,7 +338,7 @@ class _PackageUploaderAction extends ConsentAction {
335338 @override
336339 Future <void > onReject (Consent consent, User ? user) async {
337340 final packageName = consent.args! [0 ];
338- await withRetryTransaction (dbService , (tx) async {
341+ await withRetryTransaction (_db , (tx) async {
339342 tx.insert (await AuditLogRecord .uploaderInviteRejected (
340343 fromAgent: consent.fromAgent,
341344 package: packageName,
@@ -348,7 +351,7 @@ class _PackageUploaderAction extends ConsentAction {
348351 @override
349352 Future <void > onExpire (Consent consent) async {
350353 final packageName = consent.args! [0 ];
351- await withRetryTransaction (dbService , (tx) async {
354+ await withRetryTransaction (_db , (tx) async {
352355 tx.insert (await AuditLogRecord .uploaderInviteExpired (
353356 fromAgent: consent.fromAgent,
354357 package: packageName,
@@ -386,6 +389,9 @@ class _PackageUploaderAction extends ConsentAction {
386389
387390/// Callbacks for requesting permission to use e-mail as publisher contact.
388391class _PublisherContactAction extends ConsentAction {
392+ final DatastoreDB _db;
393+ _PublisherContactAction (this ._db);
394+
389395 @override
390396 Future <void > onAccept (Consent consent) async {
391397 final publisherId = consent.args! [0 ];
@@ -400,7 +406,7 @@ class _PublisherContactAction extends ConsentAction {
400406 @override
401407 Future <void > onReject (Consent consent, User ? user) async {
402408 final publisherId = consent.args! [0 ];
403- await withRetryTransaction (dbService , (tx) async {
409+ await withRetryTransaction (_db , (tx) async {
404410 tx.insert (await AuditLogRecord .publisherContactInviteRejected (
405411 fromAgent: consent.fromAgent,
406412 publisherId: publisherId,
@@ -414,7 +420,7 @@ class _PublisherContactAction extends ConsentAction {
414420 @override
415421 Future <void > onExpire (Consent consent) async {
416422 final publisherId = consent.args! [0 ];
417- await withRetryTransaction (dbService , (tx) async {
423+ await withRetryTransaction (_db , (tx) async {
418424 tx.insert (await AuditLogRecord .publisherContactInviteExpired (
419425 fromAgent: consent.fromAgent,
420426 publisherId: publisherId,
@@ -462,6 +468,9 @@ class _PublisherContactAction extends ConsentAction {
462468
463469/// Callbacks for publisher member consents.
464470class _PublisherMemberAction extends ConsentAction {
471+ final DatastoreDB _db;
472+ _PublisherMemberAction (this ._db);
473+
465474 @override
466475 Future <void > onAccept (Consent consent) async {
467476 final publisherId = consent.args! [0 ];
@@ -479,7 +488,7 @@ class _PublisherMemberAction extends ConsentAction {
479488 @override
480489 Future <void > onReject (Consent consent, User ? user) async {
481490 final publisherId = consent.args! [0 ];
482- await withRetryTransaction (dbService , (tx) async {
491+ await withRetryTransaction (_db , (tx) async {
483492 tx.insert (await AuditLogRecord .publisherMemberInviteRejected (
484493 fromAgent: consent.fromAgent,
485494 publisherId: publisherId,
@@ -492,7 +501,7 @@ class _PublisherMemberAction extends ConsentAction {
492501 @override
493502 Future <void > onExpire (Consent consent) async {
494503 final publisherId = consent.args! [0 ];
495- await withRetryTransaction (dbService , (tx) async {
504+ await withRetryTransaction (_db , (tx) async {
496505 tx.insert (await AuditLogRecord .publisherMemberInviteExpired (
497506 fromAgent: consent.fromAgent,
498507 publisherId: publisherId,
0 commit comments