@@ -46,10 +46,10 @@ abstract class ConsentKind {
46
46
/// Represents the backend for the consent handling and authentication.
47
47
class ConsentBackend {
48
48
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 ),
53
53
};
54
54
55
55
ConsentBackend (this ._db);
@@ -316,6 +316,9 @@ abstract class ConsentAction {
316
316
317
317
/// Callbacks for package uploader consents.
318
318
class _PackageUploaderAction extends ConsentAction {
319
+ final DatastoreDB _db;
320
+ _PackageUploaderAction (this ._db);
321
+
319
322
@override
320
323
Future <void > onAccept (Consent consent) async {
321
324
final packageName = consent.args! [0 ];
@@ -335,7 +338,7 @@ class _PackageUploaderAction extends ConsentAction {
335
338
@override
336
339
Future <void > onReject (Consent consent, User ? user) async {
337
340
final packageName = consent.args! [0 ];
338
- await withRetryTransaction (dbService , (tx) async {
341
+ await withRetryTransaction (_db , (tx) async {
339
342
tx.insert (await AuditLogRecord .uploaderInviteRejected (
340
343
fromAgent: consent.fromAgent,
341
344
package: packageName,
@@ -348,7 +351,7 @@ class _PackageUploaderAction extends ConsentAction {
348
351
@override
349
352
Future <void > onExpire (Consent consent) async {
350
353
final packageName = consent.args! [0 ];
351
- await withRetryTransaction (dbService , (tx) async {
354
+ await withRetryTransaction (_db , (tx) async {
352
355
tx.insert (await AuditLogRecord .uploaderInviteExpired (
353
356
fromAgent: consent.fromAgent,
354
357
package: packageName,
@@ -386,6 +389,9 @@ class _PackageUploaderAction extends ConsentAction {
386
389
387
390
/// Callbacks for requesting permission to use e-mail as publisher contact.
388
391
class _PublisherContactAction extends ConsentAction {
392
+ final DatastoreDB _db;
393
+ _PublisherContactAction (this ._db);
394
+
389
395
@override
390
396
Future <void > onAccept (Consent consent) async {
391
397
final publisherId = consent.args! [0 ];
@@ -400,7 +406,7 @@ class _PublisherContactAction extends ConsentAction {
400
406
@override
401
407
Future <void > onReject (Consent consent, User ? user) async {
402
408
final publisherId = consent.args! [0 ];
403
- await withRetryTransaction (dbService , (tx) async {
409
+ await withRetryTransaction (_db , (tx) async {
404
410
tx.insert (await AuditLogRecord .publisherContactInviteRejected (
405
411
fromAgent: consent.fromAgent,
406
412
publisherId: publisherId,
@@ -414,7 +420,7 @@ class _PublisherContactAction extends ConsentAction {
414
420
@override
415
421
Future <void > onExpire (Consent consent) async {
416
422
final publisherId = consent.args! [0 ];
417
- await withRetryTransaction (dbService , (tx) async {
423
+ await withRetryTransaction (_db , (tx) async {
418
424
tx.insert (await AuditLogRecord .publisherContactInviteExpired (
419
425
fromAgent: consent.fromAgent,
420
426
publisherId: publisherId,
@@ -462,6 +468,9 @@ class _PublisherContactAction extends ConsentAction {
462
468
463
469
/// Callbacks for publisher member consents.
464
470
class _PublisherMemberAction extends ConsentAction {
471
+ final DatastoreDB _db;
472
+ _PublisherMemberAction (this ._db);
473
+
465
474
@override
466
475
Future <void > onAccept (Consent consent) async {
467
476
final publisherId = consent.args! [0 ];
@@ -479,7 +488,7 @@ class _PublisherMemberAction extends ConsentAction {
479
488
@override
480
489
Future <void > onReject (Consent consent, User ? user) async {
481
490
final publisherId = consent.args! [0 ];
482
- await withRetryTransaction (dbService , (tx) async {
491
+ await withRetryTransaction (_db , (tx) async {
483
492
tx.insert (await AuditLogRecord .publisherMemberInviteRejected (
484
493
fromAgent: consent.fromAgent,
485
494
publisherId: publisherId,
@@ -492,7 +501,7 @@ class _PublisherMemberAction extends ConsentAction {
492
501
@override
493
502
Future <void > onExpire (Consent consent) async {
494
503
final publisherId = consent.args! [0 ];
495
- await withRetryTransaction (dbService , (tx) async {
504
+ await withRetryTransaction (_db , (tx) async {
496
505
tx.insert (await AuditLogRecord .publisherMemberInviteExpired (
497
506
fromAgent: consent.fromAgent,
498
507
publisherId: publisherId,
0 commit comments