Fixed POST /room (Git merge I will avenge you)

This commit is contained in:
Tommaso Rodolfo Masera 2020-03-04 17:01:09 +01:00
parent bff433e954
commit 3dfcd30f4e

View file

@ -9,7 +9,6 @@ import java.util.*;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.*;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;
@RestController
@ -36,12 +35,13 @@ public class RoomController {
private Room save(final RoomSaveRequest r, final Principal principal, boolean setWhenNull) {
Room newRoom = new Room();
final String username = ((UserDetails) principal).getUsername();
final String username = principal.getName();
final Long userId = userRepository.findByUsername(username).getId();
final String img = r.getImage();
final String icon = r.getIcon();
newRoom.setUserId(userId);
newRoom.setName(r.getName());
if (img != null) {
newRoom.setImage(img.getBytes());
} else if (setWhenNull) {