Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dispute agent to resend ticket. #6723

Merged
merged 1 commit into from Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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