Reset stale ABDM request flow after bridge 404
This commit is contained in:
parent
0048cb1eff
commit
3b6ed76a3c
|
|
@ -1594,6 +1594,7 @@ class Patient extends BaseController
|
|||
'phase' => 'REQUESTED',
|
||||
// Avoid repeated not-found polling loops against bridge.
|
||||
'poll_again' => 0,
|
||||
'reset_request_id' => 1,
|
||||
'request_id' => $flowRefId,
|
||||
'message' => 'Consent status not found on bridge for this request yet. Please retry sync after 1-2 minutes.',
|
||||
'data' => [
|
||||
|
|
@ -2950,6 +2951,7 @@ class Patient extends BaseController
|
|||
'updated_at' => '',
|
||||
'operation' => '',
|
||||
'status' => '',
|
||||
'restart_required' => false,
|
||||
];
|
||||
|
||||
$abhaAddress = trim($abhaAddress);
|
||||
|
|
@ -3102,6 +3104,11 @@ class Patient extends BaseController
|
|||
$snapshot['updated_at'] = (string) ($best['updated_at'] ?? '');
|
||||
$snapshot['operation'] = (string) ($best['operation'] ?? '');
|
||||
$snapshot['status'] = (string) ($best['status'] ?? '');
|
||||
$snapshot['restart_required'] = (bool) (
|
||||
($snapshot['phase'] === 'REQUESTED')
|
||||
&& ($snapshot['status'] === 'failed')
|
||||
&& stripos((string) ($snapshot['message'] ?? ''), 'not found on bridge') !== false
|
||||
);
|
||||
|
||||
return $snapshot;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -408,6 +408,7 @@ $(function() {
|
|||
var autoFlowRequestId = '';
|
||||
var autoFlowAttempts = 0;
|
||||
var autoFlowMaxAttempts = 15;
|
||||
var autoFlowNeedsFreshRequest = false;
|
||||
|
||||
var zoom = 1;
|
||||
var minZoom = 0.5;
|
||||
|
|
@ -609,7 +610,8 @@ $(function() {
|
|||
|
||||
var lastSync = data.last_sync || null;
|
||||
if (lastSync && (lastSync.request_id || '').toString().trim() !== '') {
|
||||
autoFlowRequestId = (lastSync.request_id || '').toString().trim();
|
||||
autoFlowRequestId = lastSync.restart_required ? '' : (lastSync.request_id || '').toString().trim();
|
||||
autoFlowNeedsFreshRequest = !!lastSync.restart_required;
|
||||
}
|
||||
|
||||
var lastPhase = lastSync ? (lastSync.phase || '').toString().toUpperCase() : '';
|
||||
|
|
@ -694,6 +696,7 @@ $(function() {
|
|||
autoFlowRequestId = (data.request_id || autoFlowRequestId || '').toString();
|
||||
var phase = (data.phase || '').toString();
|
||||
var msg = (data.message || '').toString();
|
||||
var resetRequestId = Number(data.reset_request_id || 0) === 1;
|
||||
var info = msg !== '' ? msg : ('Phase: ' + (phase || 'UNKNOWN'));
|
||||
|
||||
if (phase === 'COMPLETED') {
|
||||
|
|
@ -706,6 +709,16 @@ $(function() {
|
|||
|
||||
$('#abdmStatusBox').removeClass('text-danger').addClass('text-muted').text(info + (autoFlowRequestId ? (' | Request ID: ' + autoFlowRequestId) : ''));
|
||||
|
||||
if (resetRequestId) {
|
||||
autoFlowNeedsFreshRequest = true;
|
||||
autoFlowRequestId = '';
|
||||
if (autoFlowAttempts < autoFlowMaxAttempts) {
|
||||
autoFlowAttempts += 1;
|
||||
autoFlowTimer = setTimeout(runAutoFlowStep, 1200);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var shouldPoll = Number(data.poll_again || 0) === 1;
|
||||
if (shouldPoll && autoFlowAttempts < autoFlowMaxAttempts) {
|
||||
autoFlowAttempts += 1;
|
||||
|
|
@ -771,6 +784,10 @@ $(function() {
|
|||
}
|
||||
stopAutoFlowLoop();
|
||||
autoFlowAttempts = 0;
|
||||
if (autoFlowNeedsFreshRequest) {
|
||||
autoFlowRequestId = '';
|
||||
autoFlowNeedsFreshRequest = false;
|
||||
}
|
||||
setFlowProgress(1);
|
||||
$btn.prop('disabled', true).text('Sync Running...');
|
||||
$('#abdmStatusBox').removeClass('text-danger').addClass('text-muted').text('Starting one-click sync flow...');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user