Skip to content

Commit

Permalink
[fix]: Fixed bug with friends photos
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Kolovorotnyi committed Jul 14, 2023
1 parent b0bb1df commit a4801b2
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.rangiffler.service;


import com.rangiffler.model.*;
import com.rangiffler.model.CountryJson;
import com.rangiffler.model.FriendStatus;
import com.rangiffler.model.PhotoJson;
import com.rangiffler.model.PhotoServiceJson;
import com.rangiffler.service.configuration.PhotoServiceClient;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
Expand Down Expand Up @@ -42,17 +44,12 @@ public PhotoJson editPhoto(PhotoJson photoJson, UUID id) {
}

public List<PhotoJson> getAllFriendsPhotos(String username) {
List<PhotoJson> friendsPhoto = new ArrayList<>();
List<UserJson> friends = userService.receivePeopleAround(username)
return userService.receivePeopleAround(username)
.stream()
.filter(userJson -> userJson.getFriendStatus() == FriendStatus.FRIEND)
.toList();

for (UserJson userJson : friends) {
friendsPhoto.addAll(getAllUserPhotos(userJson.getUsername()));
}

return friendsPhoto;
.map(userJson -> getAllUserPhotos(userJson.getUsername()))
.findFirst()
.orElseGet(ArrayList::new);
}

public void deletePhoto(UUID photoId) {
Expand Down

0 comments on commit a4801b2

Please sign in to comment.