@@ -18,15 +18,17 @@ use academy_core_user_contracts::{
1818 UserVerifyEmailError , UserVerifyNewsletterSubscriptionError ,
1919} ;
2020use academy_di:: Build ;
21- use academy_extern_contracts:: { internal :: InternalApiService , vat:: VatApiService } ;
21+ use academy_extern_contracts:: vat:: VatApiService ;
2222use academy_models:: {
2323 auth:: { AccessToken , Login } ,
2424 email_address:: EmailAddress ,
2525 session:: DeviceName ,
2626 user:: { UserComposite , UserIdOrSelf , UserInvoiceInfoPatch , UserPassword , UserPatchRef } ,
2727 RecaptchaResponse , VerificationCode ,
2828} ;
29- use academy_persistence_contracts:: { user:: UserRepository , Database , Transaction } ;
29+ use academy_persistence_contracts:: {
30+ coin:: CoinRepository , user:: UserRepository , Database , Transaction ,
31+ } ;
3032use academy_shared_contracts:: captcha:: { CaptchaCheckError , CaptchaService } ;
3133use academy_utils:: {
3234 patch:: { Patch , PatchValue } ,
@@ -47,25 +49,25 @@ pub struct UserFeatureServiceImpl<
4749 Auth ,
4850 Captcha ,
4951 VatApi ,
50- InternalApi ,
5152 User ,
5253 UserEmailConfirmation ,
5354 UserUpdate ,
5455 Session ,
5556 OAuth2Registration ,
5657 UserRepo ,
58+ CoinRepo ,
5759> {
5860 db : Db ,
5961 auth : Auth ,
6062 captcha : Captcha ,
6163 vat_api : VatApi ,
62- internal_api : InternalApi ,
6364 user : User ,
6465 user_email_confirmation : UserEmailConfirmation ,
6566 user_update : UserUpdate ,
6667 session : Session ,
6768 oauth2_registration : OAuth2Registration ,
6869 user_repo : UserRepo ,
70+ coin_repo : CoinRepo ,
6971}
7072
7173#[ derive( Debug , Clone ) ]
@@ -84,39 +86,39 @@ impl<
8486 Auth ,
8587 Captcha ,
8688 VatApi ,
87- InternalApi ,
8889 UserS ,
8990 UserEmailConfirmation ,
9091 UserUpdate ,
9192 Session ,
9293 OAuth2RegistrationS ,
9394 UserRepo ,
95+ CoinRepo ,
9496 > UserFeatureService
9597 for UserFeatureServiceImpl <
9698 Db ,
9799 Auth ,
98100 Captcha ,
99101 VatApi ,
100- InternalApi ,
101102 UserS ,
102103 UserEmailConfirmation ,
103104 UserUpdate ,
104105 Session ,
105106 OAuth2RegistrationS ,
106107 UserRepo ,
108+ CoinRepo ,
107109 >
108110where
109111 Db : Database ,
110112 Auth : AuthService < Db :: Transaction > ,
111113 Captcha : CaptchaService ,
112114 VatApi : VatApiService ,
113- InternalApi : InternalApiService ,
114115 UserS : UserService < Db :: Transaction > ,
115116 UserEmailConfirmation : UserEmailConfirmationService < Db :: Transaction > ,
116117 UserUpdate : UserUpdateService < Db :: Transaction > ,
117118 Session : SessionService < Db :: Transaction > ,
118119 OAuth2RegistrationS : OAuth2RegistrationService ,
119120 UserRepo : UserRepository < Db :: Transaction > ,
121+ CoinRepo : CoinRepository < Db :: Transaction > ,
120122{
121123 #[ trace_instrument( skip( self ) ) ]
122124 async fn list_users (
@@ -439,10 +441,6 @@ where
439441 commit = true ;
440442 }
441443
442- if commit {
443- txn. commit ( ) . await ?;
444- }
445-
446444 let user_composite = UserComposite {
447445 user,
448446 profile,
@@ -451,12 +449,16 @@ where
451449 } ;
452450
453451 if invoice_info_updated && user_composite. can_receive_coins ( ) {
454- self . internal_api
455- . release_coins ( user_composite . user . id )
452+ self . coin_repo
453+ . release_coins ( & mut txn , user_id )
456454 . await
457455 . context ( "Failed to release coins" ) ?;
458456 }
459457
458+ if commit {
459+ txn. commit ( ) . await ?;
460+ }
461+
460462 Ok ( user_composite)
461463 }
462464
0 commit comments