Skip to content

Commit

Permalink
Merge pull request #6723 from jmacxx/resend_dispute_ticket
Browse files Browse the repository at this point in the history
Allow dispute agent to resend ticket.
  • Loading branch information
alejandrogarcia83 authored Jun 20, 2023
2 parents 5439108 + b486522 commit 153e578
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
22 changes: 22 additions & 0 deletions core/src/main/java/bisq/core/support/dispute/DisputeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,24 @@ public void maybeClearSensitiveData() {
// Message handler
///////////////////////////////////////////////////////////////////////////////////////////

public boolean agentCheckDisputeHealth(Dispute disputeToCheck) {
// checking from the agent perspective only
if (disputeToCheck.getChatMessages().stream().anyMatch(ChatMessage::isSenderIsTrader)) {
return true;
}
// consider only messages which have been transmitted
List<ChatMessage> transmittedMessages = disputeToCheck.getChatMessages().stream()
.filter(e -> !e.isSystemMessage())
.filter(e -> !e.getStoredInMailboxProperty().get())
.collect(Collectors.toList());
if (transmittedMessages.size() == 0) {
return true;
}
// dispute is healthy if any transmitted message has been ACKd by the peer
return transmittedMessages.stream()
.anyMatch(e -> e.acknowledgedProperty().get());
}

// dispute agent receives that from trader who opens dispute
protected void onOpenNewDisputeMessage(OpenNewDisputeMessage openNewDisputeMessage) {
T disputeList = getDisputeList();
Expand Down Expand Up @@ -694,8 +712,12 @@ private void doSendPeerOpenedDisputeMessage(Dispute disputeFromOpener,
dispute.addAndPersistChatMessage(chatMessage);

disputeList.add(dispute);
sendDisputeOpeningMsg(dispute);
}

public void sendDisputeOpeningMsg(Dispute dispute) {
// We mirrored dispute already!
ChatMessage chatMessage = dispute.getChatMessages().get(0);
Contract contract = dispute.getContract();
PubKeyRing peersPubKeyRing = dispute.isDisputeOpenerIsBuyer() ? contract.getBuyerPubKeyRing() : contract.getSellerPubKeyRing();
NodeAddress peersNodeAddress = dispute.isDisputeOpenerIsBuyer() ? contract.getBuyerNodeAddress() : contract.getSellerNodeAddress();
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,9 @@ support.warning.disputesWithInvalidDonationAddress=The delayed payout transactio
support.warning.disputesWithInvalidDonationAddress.mediator=\n\nDo you still want to close the dispute?
support.warning.disputesWithInvalidDonationAddress.refundAgent=\n\nYou must not do the payout.
support.warning.traderCloseOwnDisputeWarning=Traders can only self-close their support tickets when the trade has been paid out.
support.warning.ticketNotAcknowledged=Ticket not acknowledged.
support.resendTicket=This trader has not acknowledged receipt of the dispute ticket.\n\
Would you like to re-send the ticket?
support.info.disputedTradeUpdate=Disputed trade update: {0}

####################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ public void updateItem(final Dispute item, boolean empty) {
return column;
}

private void openChat(Dispute dispute) {
protected void openChat(Dispute dispute) {
chatPopup.openChat(dispute, getConcreteDisputeChatSession(dispute), getCounterpartyName());
dispute.setDisputeSeen(senderFlag());
newBadgeByDispute.get(dispute.getId()).setVisible(dispute.isNew());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,24 @@ protected void maybeAddProcessColumnsForAgent() {
tableView.getColumns().add(getChatColumn());
}

@Override
protected void openChat(Dispute dispute) {
if (disputeManager.agentCheckDisputeHealth(dispute)) {
super.openChat(dispute);
} else {
new Popup().headLine(Res.get("support.warning.ticketNotAcknowledged"))
.confirmation(Res.get("support.resendTicket"))
.actionButtonText(Res.get("shared.yes"))
.onAction(() -> {
disputeManager.sendDisputeOpeningMsg(dispute);
super.openChat(dispute);
})
.closeButtonText(Res.get("shared.no"))
.onClose(() -> super.openChat(dispute))
.show();
}
}

@Override
protected boolean senderFlag() {
return true;
Expand Down

0 comments on commit 153e578

Please sign in to comment.