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,24 +175,21 @@ 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());
peerDisputeResult.setSellerPayoutAmount(disputeResult.getSellerPayoutAmount()); peerDisputeResult.setSellerPayoutAmount(disputeResult.getSellerPayoutAmount());
closeDisputeTicket(arbitrationManager, peerDispute, peerDisputeResult, null, () -> { closeDisputeTicket(arbitrationManager, peerDispute, peerDisputeResult, null, () -> {
arbitrationManager.requestPersistence(); arbitrationManager.requestPersistence();
}, (errMessage, err) -> {
throw new IllegalStateException(errMessage, err);
});
} else {
throw new IllegalStateException("could not find peer dispute");
}
}, (errMessage, err) -> { }, (errMessage, err) -> {
throw new IllegalStateException(errMessage, err); throw new IllegalStateException(errMessage, err);
}); });