Merge branch '20-put-post-on-room-does-not-move-room-name-in-dto' into 'dev'

Resolve "PUT/POST on room does not move room name in DTO"

Closes #20

See merge request sa4-2020/the-sanmarinoes/backend!24
This commit is contained in:
Claudio Maggioni 2020-03-04 17:15:05 +01:00
commit 6d2f7a25fb

View file

@ -10,7 +10,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
@ -37,12 +36,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) {