Skip to content

Commit

Permalink
refactor: LastMessageResponseDto.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladik-gif committed Sep 6, 2024
1 parent 7edae33 commit d3ba42e
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
@ToString
public class LastMessageResponseDto {

private static final int MAX_LENGTH = 20;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime timestamp;
private String sentFrom;
Expand All @@ -26,20 +24,10 @@ public class LastMessageResponseDto {
public LastMessageResponseDto(LocalDateTime timestamp,
String sentFrom,
String lastMessage,
UUID topicId
) {
UUID topicId) {
this.timestamp = timestamp;
this.sentFrom = sentFrom;
this.lastMessage = lastMessage;
this.topicId = topicId;
}

public void setLastMessage(String lastMessage) {
if (lastMessage.length() <= MAX_LENGTH) {
this.lastMessage = lastMessage;
} else {
this.lastMessage = lastMessage.substring(0, MAX_LENGTH) + "...";
}
}

}
}

0 comments on commit d3ba42e

Please sign in to comment.