Skip to content

Commit 7e6f60e

Browse files
are friends method updated
1 parent 1873f36 commit 7e6f60e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/org/spacehub/service/Friend/FriendService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,21 +358,23 @@ private void sendFriendListUpdate(User target, User newFriend) {
358358
}
359359

360360
public boolean areFriends(String email1, String email2) {
361-
if (email1 == null || email1.isBlank() || email2 == null || email2.isBlank() || email1.equalsIgnoreCase(email2)) {
361+
if (email1 == null || email1.isBlank() ||
362+
email2 == null || email2.isBlank() ||
363+
email1.equalsIgnoreCase(email2)) {
362364
return true;
363365
}
364366

365367
User user1 = userRepository.findByEmail(email1).orElse(null);
366368
User user2 = userRepository.findByEmail(email2).orElse(null);
367369

368370
if (user1 == null || user2 == null) {
369-
return true;
371+
return false;
370372
}
371373

372374
boolean oneWay = friendsRepository.findByUserAndFriendAndStatus(user1, user2, "accepted").isPresent();
373375
boolean otherWay = friendsRepository.findByUserAndFriendAndStatus(user2, user1, "accepted").isPresent();
374376

375-
return !oneWay && !otherWay;
377+
return oneWay || otherWay;
376378
}
377379

378380
}

0 commit comments

Comments
 (0)