Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #956 from SE-TINF22B6/backend
Browse files Browse the repository at this point in the history
Hotfix: image check
  • Loading branch information
denniskp authored Jun 13, 2024
2 parents faf0720 + 38acba6 commit ce7b12c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/de/tinf22b6/dhbwhub/service/PostServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,20 @@ public Post create(PostProposal proposal) {
public HomepagePostPreviewProposal create(CreatePostProposal proposal) {
// Creating the Post itself
User user = userRepository.findByAccountId(proposal.getAccountId());
if(user == null){
if (user == null) {
throw new NoSuchEntryException("User with the AccountId " + proposal.getAccountId() + " does not exist!");
}
Picture picture = !proposal.getPostImage().isEmpty() ?
pictureRepository.save(PictureMapper.mapToModelPost(proposal.getPostImage())): null;

Post post = repository.save(PostMapper.mapToModel(proposal,user,picture));
Picture picture = proposal.getPostImage() != null ?
pictureRepository.save(PictureMapper.mapToModelPost(proposal.getPostImage())) : null;

Post post = repository.save(PostMapper.mapToModel(proposal, user, picture));

// Creating Tags after the Post is created
Arrays.stream(proposal.getTags()).forEach(t -> {
PostTag postTag = new PostTag(post, t);
postTagRepository.save(postTag);
} );
});

return getPostHomepageView(post.getId());
}
Expand Down

0 comments on commit ce7b12c

Please sign in to comment.