send dispute closed messages independently

This commit is contained in:
woodser 2023-01-20 11:16:48 -05:00
parent e6baf0260a
commit 533639bd19

View File

@ -142,6 +142,7 @@ public class CoreDisputesService {
} }
} }
// TODO: does not wait for success or error response
public void resolveDispute(String tradeId, DisputeResult.Winner winner, DisputeResult.Reason reason, String summaryNotes, long customWinnerAmount) { public void resolveDispute(String tradeId, DisputeResult.Winner winner, DisputeResult.Reason reason, String summaryNotes, long customWinnerAmount) {
try { try {
@ -174,12 +175,15 @@ public class CoreDisputesService {
// close dispute ticket // close dispute ticket
closeDisputeTicket(arbitrationManager, winningDispute, disputeResult, null, () -> { closeDisputeTicket(arbitrationManager, winningDispute, disputeResult, null, () -> {
arbitrationManager.requestPersistence(); arbitrationManager.requestPersistence();
}, (errMessage, err) -> {
throw new IllegalStateException(errMessage, err);
});
// close peer's dispute ticket // close peer's dispute ticket
var peersDisputeOptional = arbitrationManager.getDisputesAsObservableList().stream() var peersDisputeOptional = arbitrationManager.getDisputesAsObservableList().stream()
.filter(d -> tradeId.equals(d.getTradeId()) && winningDispute.getTraderId() != d.getTraderId()) .filter(d -> tradeId.equals(d.getTradeId()) && winningDispute.getTraderId() != d.getTraderId())
.findFirst(); .findFirst();
if (peersDisputeOptional.isPresent()) { if (!peersDisputeOptional.isPresent()) throw new IllegalStateException("could not find peer dispute");
var peerDispute = peersDisputeOptional.get(); var peerDispute = peersDisputeOptional.get();
var peerDisputeResult = createDisputeResult(peerDispute, winner, reason, summaryNotes, closeDate); var peerDisputeResult = createDisputeResult(peerDispute, winner, reason, summaryNotes, closeDate);
peerDisputeResult.setBuyerPayoutAmount(disputeResult.getBuyerPayoutAmount()); peerDisputeResult.setBuyerPayoutAmount(disputeResult.getBuyerPayoutAmount());
@ -189,12 +193,6 @@ public class CoreDisputesService {
}, (errMessage, err) -> { }, (errMessage, err) -> {
throw new IllegalStateException(errMessage, err); throw new IllegalStateException(errMessage, err);
}); });
} else {
throw new IllegalStateException("could not find peer dispute");
}
}, (errMessage, err) -> {
throw new IllegalStateException(errMessage, err);
});
} }
} catch (Exception e) { } catch (Exception e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);