Skip to content

Commit

Permalink
feat: add new user properties
Browse files Browse the repository at this point in the history
  • Loading branch information
borjom1 committed May 6, 2024
1 parent b7cef4f commit b16719c
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ public class UserDto {
private boolean isOnline;

private String avatarPath;

@JsonProperty("deleted")
private boolean isDeleted;

@JsonProperty("blocked")
private boolean isBlocked;

private String bio;

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public ChatDto createChat(@NonNull RequestInitiator initiator,
}

// check recipient existence
userServiceClient.getUser(recipientId, initiator.bearer());
final UserDto recipient = userServiceClient.getUser(recipientId, initiator.bearer());
if (recipient.isDeleted()) {
throw new BadCredentialsException("Invalid recipient id");
}

final Chat newChat;
try {
Expand Down Expand Up @@ -217,6 +220,7 @@ public Pair<Long, List<ChatDto>> getUserChats(@NonNull RequestInitiator initiato
if (user != null) { // if user is found, add user details
author.setUsername(user.getUsername());
author.setName(user.getName());
author.setDeleted(user.isDeleted());

if (chat instanceof DuoChatDto duoChat) {
duoChat.setAvatarAvailable(user.getAvatarPath() != null);
Expand Down Expand Up @@ -418,6 +422,9 @@ public ChatMemberDto addGroupChatMember(String chatId, @NonNull RequestInitiator

// check user existence
final UserDto user = userServiceClient.getUser(userId, initiator.bearer());
if (user.isDeleted()) {
throw new BadCredentialsException("Invalid user ID id");
}

final ChatMember newMember = groupChat.addMember(userId);
final var message = MemberMessage.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.linkwave.chatservice.chat;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

@NoArgsConstructor
Expand All @@ -13,4 +14,7 @@ public class MessageAuthorDto {
private String username;
private String name;

@JsonProperty("deleted")
private boolean isDeleted;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ public class CompanionDto {
@JsonProperty("online")
private boolean isOnline;

@JsonProperty("deleted")
private boolean isDeleted;

}
26 changes: 20 additions & 6 deletions backend/chat-service/src/main/resources/static/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,8 @@
"author": {
"id": 1,
"username": "@mathewmcc",
"name": "Matthew McConaughey"
"name": "Matthew McConaughey",
"deleted": false
},
"reactions": [],
"text": "Hi everyone!",
Expand Down Expand Up @@ -1182,7 +1183,8 @@
"username": "@emmtlor",
"name": "Emma Taylor",
"lastSeen": 1707606183.446933000,
"online": false
"online": false,
"deleted": false
},
"lastMessage": {
"id": "66055236cb761a59d173d978",
Expand All @@ -1191,7 +1193,8 @@
"author": {
"id": 1,
"username": "@mathewmcc",
"name": "Matthew McConaughey"
"name": "Matthew McConaughey",
"deleted": false
},
"reactions": [],
"text": "Hi everyone!",
Expand Down Expand Up @@ -1263,7 +1266,8 @@
"author": {
"id": 1,
"username": "@mathewmcc",
"name": "Matthew McConaughey"
"name": "Matthew McConaughey",
"deleted": false
},
"reactions": [],
"text": "Hi everyone!",
Expand Down Expand Up @@ -1515,12 +1519,17 @@
"name": {
"type": "string",
"nullable": true
},
"deleted": {
"type": "boolean",
"nullable": false
}
},
"example": {
"id": 1,
"username": "mathew",
"name": "Matthew McConaughey"
"name": "Matthew McConaughey",
"deleted": false
}
},
"MessageReaction": {
Expand Down Expand Up @@ -1631,14 +1640,19 @@
"online": {
"type": "boolean",
"nullable": false
},
"deleted": {
"type": "boolean",
"nullable": false
}
},
"example": {
"id": 22,
"username": "@emmtlor",
"name": "Emma Taylor",
"lastSeen": 1707606183.446933000,
"online": false
"online": false,
"deleted": false
}
}
},
Expand Down
16 changes: 16 additions & 0 deletions backend/user-service/src/main/resources/static/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
"lastSeen": 1707597104.417882000,
"avatarPath": null,
"bio": null,
"deleted": false,
"blocked": true,
"online": false
},
{
Expand All @@ -178,6 +180,8 @@
"lastSeen": 1707597134.622333000,
"avatarPath": null,
"bio": null,
"deleted": false,
"blocked": false,
"online": false
},
{
Expand All @@ -187,6 +191,8 @@
"lastSeen": 1707597134.622333000,
"avatarPath": null,
"bio": null,
"deleted": true,
"blocked": false,
"online": false
}
]
Expand Down Expand Up @@ -736,6 +742,14 @@
"type": "string",
"nullable": true
},
"deleted": {
"type": "boolean",
"nullable": false
},
"blocked": {
"type": "boolean",
"nullable": false
},
"bio": {
"type": "string",
"nullable": true
Expand All @@ -748,6 +762,8 @@
"createdAt": 1707606183.446933000,
"lastSeen": 1707606183.446933000,
"avatarPath": null,
"deleted": false,
"blocked": false,
"bio": null,
"online": false
}
Expand Down

0 comments on commit b16719c

Please sign in to comment.