Skip to content

Commit

Permalink
Attend review
Browse files Browse the repository at this point in the history
  • Loading branch information
axpoems committed Mar 6, 2025
1 parent d2f1e2b commit 4c1f984
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Optional<Citation> getCitation() {

String truncated = StringUtils.truncate(text, Citation.MAX_TEXT_LENGTH);
String chatMessageId = controller.model.chatMessageId;
return Optional.of(new Citation(userProfile.getId(), truncated, chatMessageId));
return Optional.of(new Citation(userProfile.getId(), truncated, Optional.of(chatMessageId)));
}

private static class Controller implements bisq.desktop.common.view.Controller {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void maybeSelectFirst() {
if (selectionService.getSelectedChannel().get() == null &&
!channelService.getChannels().isEmpty() &&
!model.getSortedList().isEmpty()) {
selectionService.selectChannel(model.getSortedList().getFirst().getChannel());
selectionService.selectChannel(model.getSortedList().get(0).getChannel());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ChatRulesView(ChatRulesModel model, ChatRulesController controller) {

root.setAlignment(Pos.TOP_LEFT);
root.setPrefWidth(OverlayModel.WIDTH);
root.setPrefHeight(490);
root.setPrefHeight(505);

root.setPadding(new Insets(30, 60, 30, 60));

Expand Down
19 changes: 14 additions & 5 deletions chat/src/main/java/bisq/chat/Citation.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,33 @@

package bisq.chat;

import bisq.common.annotation.ExcludeForHash;
import bisq.common.proto.NetworkProto;
import bisq.common.validation.NetworkDataValidation;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

import java.util.Optional;

@Getter
@ToString
@EqualsAndHashCode
public final class Citation implements NetworkProto {
public static final int MAX_TEXT_LENGTH = 1000;

private final String authorUserProfileId, text, chatMessageId;
private final String authorUserProfileId;
private final String text;

// Added with v2.1.7
@EqualsAndHashCode.Exclude
@ExcludeForHash
private final String chatMessageId;

public Citation(String authorUserProfileId, String text, String chatMessageId) {
public Citation(String authorUserProfileId, String text, Optional<String> chatMessageId) {
this.authorUserProfileId = authorUserProfileId;
this.text = text;
this.chatMessageId = chatMessageId;
this.chatMessageId = chatMessageId.orElse("");

verify();
}
Expand All @@ -60,12 +69,12 @@ public bisq.chat.protobuf.Citation toProto(boolean serializeForHash) {

public static Citation fromProto(bisq.chat.protobuf.Citation proto) {
return new Citation(proto.getAuthorUserProfileId(),
proto.getText(), proto.getChatMessageId());
proto.getText(), Optional.of(proto.getChatMessageId()));
}

public boolean isValid() {
return authorUserProfileId != null && !authorUserProfileId.isEmpty()
&& text != null && !text.isEmpty()
&& chatMessageId != null && !chatMessageId.isEmpty();
&& chatMessageId != null;
}
}
1 change: 1 addition & 0 deletions chat/src/main/proto/chat.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum ChatMessageType {
CHATMESSAGETYPE_LEAVE = 2;
CHATMESSAGETYPE_TAKE_BISQ_EASY_OFFER = 3;
CHATMESSAGETYPE_PROTOCOL_LOG_MESSAGE = 4;
CHATMESSAGETYPE_CHAT_RULES_WARNING = 5;
}

enum ChatChannelNotificationType {
Expand Down
3 changes: 2 additions & 1 deletion http-api/src/main/java/bisq/dto/DtoMappings.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Base64;
import java.util.Optional;
import java.util.stream.Collectors;

public class DtoMappings {
Expand Down Expand Up @@ -165,7 +166,7 @@ public static Citation toBisq2Model(CitationDto value) {
return new Citation(
value.authorUserProfileId(),
value.text(),
value.chatMessageId()
Optional.of(value.chatMessageId())
);
}

Expand Down
4 changes: 2 additions & 2 deletions i18n/src/main/resources/chat.properties
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ chat.chatRules.content=\
- No advertising: Avoid promoting commercial products, services, or posting promotional links.\
- No trolling: Disruptive behavior and intentional provocation are not welcome.\
- No impersonation: Do not use nicknames that mislead others into thinking you are a well-known person.\
- No fraud or scamming: Fraudulent activities are strictly forbidden.\
- No luring users out of the Bisq platform: Trading should be done using the Bisq protocol and network. \
- No scamming/zero tolerance: Any attempt at fraud will result in an immediate ban from the network.\
- Keep trades within Bisq: Bisq is built for secure trading. Asking peers to trade outside the platform increases the risk of fraud and will result in a network ban. \
- Respect privacy: Protect your and others' privacy; don't share trade details.\
- Report misconduct: Report rule violations or inappropriate behavior to the moderator.\
- Enjoy the chat: Engage in meaningful discussions, make friends, and have fun in a friendly and \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public CompletableFuture<SendMessageResult> contactUser(UserProfile userProfile,

if (channel.getChatMessages().isEmpty() && isReportingUser) {
return twoPartyPrivateChatChannelService.sendTextMessage(Res.get("authorizedRole.moderator.replyMsg"),
citationMessage.map(msg -> new Citation(userProfile.getId(), msg, "")),
citationMessage.map(msg -> new Citation(userProfile.getId(), msg, Optional.empty())),
channel);
} else {
return CompletableFuture.completedFuture(new SendMessageResult());
Expand Down

0 comments on commit 4c1f984

Please sign in to comment.