@@ -14,7 +14,10 @@ import express from 'express';
14
14
import { matchedData } from 'express-validator' ;
15
15
16
16
import { AddressRequest , BlockedCode } from '../types' ;
17
- import { create4xxResponse } from './helpers' ;
17
+ import {
18
+ create4xxResponse ,
19
+ handleInternalServerError ,
20
+ } from './helpers' ;
18
21
import { getIpAddr , isIndexerIp } from './utils' ;
19
22
20
23
/**
@@ -46,24 +49,34 @@ export async function complianceAndGeoCheck(
46
49
}
47
50
48
51
if ( address !== undefined ) {
49
- const updatedStatus : ComplianceStatusFromDatabase [ ] = await ComplianceStatusTable . findAll (
50
- { address : [ address ] } ,
51
- [ ] ,
52
- { readReplica : true } ,
53
- ) ;
54
- if ( updatedStatus . length > 0 ) {
55
- if ( updatedStatus [ 0 ] . status === ComplianceStatus . CLOSE_ONLY ||
56
- updatedStatus [ 0 ] . status === ComplianceStatus . FIRST_STRIKE_CLOSE_ONLY
57
- ) {
58
- return next ( ) ;
59
- } else if ( updatedStatus [ 0 ] . status === ComplianceStatus . BLOCKED ) {
60
- return create4xxResponse (
61
- res ,
62
- INDEXER_COMPLIANCE_BLOCKED_PAYLOAD ,
63
- 403 ,
64
- { code : BlockedCode . COMPLIANCE_BLOCKED } ,
65
- ) ;
52
+ try {
53
+ const updatedStatus : ComplianceStatusFromDatabase [ ] = await ComplianceStatusTable . findAll (
54
+ { address : [ address ] } ,
55
+ [ ] ,
56
+ { readReplica : true } ,
57
+ ) ;
58
+ if ( updatedStatus . length > 0 ) {
59
+ if ( updatedStatus [ 0 ] . status === ComplianceStatus . CLOSE_ONLY ||
60
+ updatedStatus [ 0 ] . status === ComplianceStatus . FIRST_STRIKE_CLOSE_ONLY
61
+ ) {
62
+ return next ( ) ;
63
+ } else if ( updatedStatus [ 0 ] . status === ComplianceStatus . BLOCKED ) {
64
+ return create4xxResponse (
65
+ res ,
66
+ INDEXER_COMPLIANCE_BLOCKED_PAYLOAD ,
67
+ 403 ,
68
+ { code : BlockedCode . COMPLIANCE_BLOCKED } ,
69
+ ) ;
70
+ }
66
71
}
72
+ } catch ( error ) {
73
+ return handleInternalServerError (
74
+ 'complianceAndGeoCheck' ,
75
+ 'complianceAndGeoCheck error' ,
76
+ error ,
77
+ req ,
78
+ res ,
79
+ ) ;
67
80
}
68
81
}
69
82
0 commit comments