@@ -84,7 +84,8 @@ pub async fn post_compliance_form(
84
84
reference_id : String :: new ( ) ,
85
85
e_delivery_consented : false ,
86
86
tin_matched : false ,
87
- form_type : body. 0 . form_type ,
87
+ form_type : Some ( body. 0 . form_type ) ,
88
+ requires_manual_review : false ,
88
89
} ,
89
90
} ;
90
91
@@ -108,10 +109,10 @@ pub async fn post_compliance_form(
108
109
compliance. e_delivery_consented = false ;
109
110
compliance. tin_matched = false ;
110
111
compliance. signed = None ;
111
- compliance. form_type = body. 0 . form_type ;
112
+ compliance. form_type = Some ( body. 0 . form_type ) ;
112
113
compliance. last_checked = Utc :: now ( ) - COMPLIANCE_CHECK_DEBOUNCE ;
113
114
114
- compliance. upsert ( & mut * txn) . await ?;
115
+ compliance. upsert_partial ( & mut * txn) . await ?;
115
116
txn. commit ( ) . await ?;
116
117
117
118
Ok ( HttpResponse :: Ok ( ) . json ( toplevel) )
@@ -489,6 +490,8 @@ pub async fn create_payout(
489
490
) ) ;
490
491
}
491
492
493
+ let requires_manual_review;
494
+
492
495
if let Some ( threshold) = tax_compliance_payout_threshold ( ) {
493
496
let maybe_compliance = update_compliance_status ( & pool, user. id ) . await ?;
494
497
@@ -501,9 +504,14 @@ pub async fn create_payout(
501
504
let tin = model. tin_matched ;
502
505
let signed = model. signed . is_some ( ) ;
503
506
507
+ requires_manual_review = Some ( model. requires_manual_review ) ;
508
+
504
509
( tin, signed, true , compliance_api_check_failed)
505
510
}
506
- None => ( false , false , false , false ) ,
511
+ None => {
512
+ requires_manual_review = None ;
513
+ ( false , false , false , false )
514
+ }
507
515
} ;
508
516
509
517
if !( tin_matched && signed)
@@ -526,6 +534,23 @@ pub async fn create_payout(
526
534
_ => "Tax compliance form is required to withdraw more!" ,
527
535
} . to_owned ( ) ) ) ;
528
536
}
537
+ } else {
538
+ requires_manual_review = None ;
539
+ }
540
+
541
+ let requires_manual_review = if let Some ( r) = requires_manual_review {
542
+ r
543
+ } else {
544
+ users_compliance:: UserCompliance :: get_by_user_id ( & * * pool, user. id )
545
+ . await ?
546
+ . map ( |x| x. requires_manual_review )
547
+ . unwrap_or_default ( )
548
+ } ;
549
+
550
+ if requires_manual_review {
551
+ return Err ( ApiError :: InvalidInput (
552
+ "More information is required to proceed. Please contact support (https://support.modrinth.com, support@modrinth.com)" . to_string ( ) ,
553
+ ) ) ;
529
554
}
530
555
531
556
let payout_method = payouts_queue
@@ -953,8 +978,9 @@ pub async fn get_balance(
953
978
form_completion_status = Some (
954
979
update_compliance_status ( & pool, user. id . into ( ) )
955
980
. await ?
981
+ . filter ( |x| x. model . form_type . is_some ( ) )
956
982
. map_or ( FormCompletionStatus :: Unrequested , |compliance| {
957
- requested_form_type = Some ( compliance. model . form_type ) ;
983
+ requested_form_type = compliance. model . form_type . clone ( ) ;
958
984
959
985
if compliance. compliance_api_check_failed {
960
986
FormCompletionStatus :: Unknown
@@ -1060,6 +1086,7 @@ async fn update_compliance_status(
1060
1086
if ( compliance. signed . is_some ( ) && compliance. tin_matched )
1061
1087
|| Utc :: now ( ) . signed_duration_since ( compliance. last_checked )
1062
1088
< COMPLIANCE_CHECK_DEBOUNCE
1089
+ || compliance. form_type . is_none ( )
1063
1090
{
1064
1091
Ok ( Some ( ComplianceCheck {
1065
1092
model : compliance,
@@ -1087,7 +1114,10 @@ async fn update_compliance_status(
1087
1114
compliance. e_delivery_consented =
1088
1115
attributes. e_delivery_consented_at . is_some ( ) ;
1089
1116
1090
- if compliance. form_type . requires_domestic_tin_match ( ) {
1117
+ if compliance
1118
+ . form_type
1119
+ . is_some_and ( |x| x. requires_domestic_tin_match ( ) )
1120
+ {
1091
1121
compliance. tin_matched = attributes
1092
1122
. tin_match_status
1093
1123
. as_ref ( )
0 commit comments