Commit 94dae93c authored by Daniel Gerhardt's avatar Daniel Gerhardt

Keep moderators when a full room update is done

Fixes arsnova-backend#59.
parent 132b9a9f
......@@ -396,6 +396,7 @@ public class Room extends Entity {
private String description;
private boolean closed;
private Set<Moderator> moderators;
private boolean moderatorsInitialized;
private Settings settings;
private Author author;
private PoolProperties poolProperties;
......@@ -475,6 +476,11 @@ public class Room extends Entity {
@JsonView(View.Persistence.class)
public void setModerators(final Set<Moderator> moderators) {
this.moderators = moderators;
moderatorsInitialized = true;
}
public boolean isModeratorsInitialized() {
return moderatorsInitialized;
}
@JsonView({View.Persistence.class, View.Public.class})
......
......@@ -45,6 +45,7 @@ import org.springframework.validation.Validator;
import de.thm.arsnova.connector.client.ConnectorClient;
import de.thm.arsnova.connector.model.Course;
import de.thm.arsnova.event.BeforeDeletionEvent;
import de.thm.arsnova.event.BeforeFullUpdateEvent;
import de.thm.arsnova.event.FlipFlashcardsEvent;
import de.thm.arsnova.model.Room;
import de.thm.arsnova.model.UserProfile;
......@@ -152,6 +153,13 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R
this.connectorClient = connectorClient;
}
@EventListener
public void handleRoomUpdate(final BeforeFullUpdateEvent<Room> event) {
if (!event.getEntity().isModeratorsInitialized()) {
event.getEntity().setModerators(event.getOldEntity().getModerators());
}
}
@EventListener
@Secured({"ROLE_USER", "RUN_AS_SYSTEM"})
public void handleUserDeletion(final BeforeDeletionEvent<UserProfile> event) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment