|
@@ -16,6 +16,7 @@ import java.net.URISyntaxException;
|
16
|
16
|
|
17
|
17
|
import java.util.List;
|
18
|
18
|
import java.util.Optional;
|
|
19
|
+import java.util.stream.Collectors;
|
19
|
20
|
|
20
|
21
|
/**
|
21
|
22
|
* REST controller for managing Post.
|
|
@@ -116,4 +117,19 @@ public class PostResource {
|
116
|
117
|
postRepository.deleteById(id);
|
117
|
118
|
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
|
118
|
119
|
}
|
|
120
|
+
|
|
121
|
+ @GetMapping("/timeline")
|
|
122
|
+ @Timed
|
|
123
|
+ public List<Post> getPostsForUserTimeline() {
|
|
124
|
+ log.debug("REST request to get all Posts");
|
|
125
|
+ return postRepository.findAll().stream()
|
|
126
|
+ .filter(this::isViewable)
|
|
127
|
+ .collect(Collectors.toList());
|
|
128
|
+ }
|
|
129
|
+
|
|
130
|
+ private boolean isViewable(Post post) {
|
|
131
|
+ return (post.getPrivacySetting().isPublicView()) ||
|
|
132
|
+ (post.getPrivacySetting().isCohortView() && post.getPoster().getCohort().equals(thisUserProfile.getCohort())) ||
|
|
133
|
+ (post.getPrivacySetting().isEmployerView() && post.getPoster().getEmployer().equals(thisUserProfile.getEmployer()));
|
|
134
|
+ }
|
119
|
135
|
}
|