fix for Partey, new streaming preparations

This commit is contained in:
_Bastler 2021-11-17 19:35:43 +01:00
parent fad01fc0d7
commit 3bcc0efe0d
5 changed files with 75 additions and 19 deletions

View File

@ -63,16 +63,19 @@ public class RoomController extends DebugLogger {
*/ */
@GetMapping("/access") @GetMapping("/access")
public MemberData access(@RequestParam("userIdentifier") String userIdentifier, public MemberData access(@RequestParam("userIdentifier") String userIdentifier,
@RequestParam("roomId") String roomId, HttpServletRequest request) { @RequestParam("roomId") Optional<String> roomId,
@RequestParam("ipAddress") Optional<String> ipAddress, HttpServletRequest request) {
parteyApiAuthentication.authenticateRequest(request); parteyApiAuthentication.authenticateRequest(request);
debugPrintRequest(request); debugPrintRequest(request);
Room room = parteyMapManager.parseRoom(roomId, request); if (roomId.isPresent()) {
Room room = parteyMapManager.parseRoom(roomId.get(), request);
if (!worldMapCache.contains(room.getUrl())) { if (!worldMapCache.contains(room.getUrl())) {
worldMapCache.add(room.getUrl()); worldMapCache.add(room.getUrl());
} }
}
MemberData memberData = new MemberData(); MemberData memberData = new MemberData();
memberData.setUserUuid(userIdentifier); memberData.setUserUuid(userIdentifier);

View File

@ -12,12 +12,14 @@ import org.springframework.util.StringUtils;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.validation.Validator; import org.springframework.validation.Validator;
import com.google.common.collect.Lists;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import de.bstly.we.businesslogic.SystemPropertyManager; import de.bstly.we.businesslogic.SystemPropertyManager;
import de.bstly.we.partey.timeslot.businesslogic.TimeslotManager; import de.bstly.we.partey.timeslot.businesslogic.TimeslotManager;
import de.bstly.we.partey.timeslot.model.QTimeslot; import de.bstly.we.partey.timeslot.model.QTimeslot;
import de.bstly.we.partey.timeslot.model.Timeslot; import de.bstly.we.partey.timeslot.model.Timeslot;
import de.bstly.we.partey.timeslot.model.TimeslotType;
import de.bstly.we.partey.timeslot.repository.TimeslotRepository; import de.bstly.we.partey.timeslot.repository.TimeslotRepository;
/** /**
@ -34,7 +36,6 @@ public class TimeslotValidator implements Validator {
private SystemPropertyManager systemPropertyManager; private SystemPropertyManager systemPropertyManager;
private QTimeslot qTimeslot = QTimeslot.timeslot; private QTimeslot qTimeslot = QTimeslot.timeslot;
/* /*
* @see org.springframework.validation.Validator#supports(java.lang.Class) * @see org.springframework.validation.Validator#supports(java.lang.Class)
*/ */
@ -43,9 +44,9 @@ public class TimeslotValidator implements Validator {
return clazz.isAssignableFrom(Timeslot.class); return clazz.isAssignableFrom(Timeslot.class);
} }
/* /*
* @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors) * @see org.springframework.validation.Validator#validate(java.lang.Object,
* org.springframework.validation.Errors)
*/ */
@Override @Override
public void validate(Object target, Errors errors) { public void validate(Object target, Errors errors) {
@ -80,6 +81,19 @@ public class TimeslotValidator implements Validator {
// same type // same type
timeQuery.and(qTimeslot.type.eq(timeslot.getType())); timeQuery.and(qTimeslot.type.eq(timeslot.getType()));
switch (timeslot.getType()) {
case AUDIO:
case AUDIO_STREAM:
timeQuery.and(qTimeslot.type
.in(Lists.newArrayList(TimeslotType.AUDIO, TimeslotType.AUDIO_STREAM)));
break;
case VIDEO:
case VIDEO_STREAM:
timeQuery.and(qTimeslot.type
.in(Lists.newArrayList(TimeslotType.VIDEO, TimeslotType.VIDEO_STREAM)));
break;
}
// ends after start // ends after start
timeQuery timeQuery
.and(qTimeslot.ends.after(timeslot.getStarts().minus( .and(qTimeslot.ends.after(timeslot.getStarts().minus(
@ -128,10 +142,16 @@ public class TimeslotValidator implements Validator {
switch (timeslot.getType()) { switch (timeslot.getType()) {
case AUDIO: case AUDIO:
validateTypeAudio(timeslot, errors); validateShare(timeslot, errors);
break; break;
case VIDEO: case VIDEO:
validateTypeVideo(timeslot, errors); validateShare(timeslot, errors);
break;
case AUDIO_STREAM:
validateTypeAudioStream(timeslot, errors);
break;
case VIDEO_STREAM:
validateTypeVideoStream(timeslot, errors);
break; break;
} }
@ -143,8 +163,24 @@ public class TimeslotValidator implements Validator {
* @param timeslot the timeslot * @param timeslot the timeslot
* @param errors the errors * @param errors the errors
*/ */
public void validateTypeAudio(Timeslot timeslot, Errors errors) { public void validateShare(Timeslot timeslot, Errors errors) {
timeslot.setStream(null); timeslot.setStream(null);
timeslot.setSecret(null);
if (!StringUtils.hasText(timeslot.getShare())) {
errors.rejectValue("share", "REQUIRED");
}
}
/**
* Validate type audio.
*
* @param timeslot the timeslot
* @param errors the errors
*/
public void validateTypeAudioStream(Timeslot timeslot, Errors errors) {
timeslot.setStream(null);
timeslot.setShare(null);
if (timeslot.getId() != null && timeslotRepository.existsById(timeslot.getId())) { if (timeslot.getId() != null && timeslotRepository.existsById(timeslot.getId())) {
Timeslot existing = timeslotRepository.findById(timeslot.getId()).get(); Timeslot existing = timeslotRepository.findById(timeslot.getId()).get();
timeslot.setSecret(existing.getSecret()); timeslot.setSecret(existing.getSecret());
@ -161,8 +197,9 @@ public class TimeslotValidator implements Validator {
* @param timeslot the timeslot * @param timeslot the timeslot
* @param errors the errors * @param errors the errors
*/ */
public void validateTypeVideo(Timeslot timeslot, Errors errors) { public void validateTypeVideoStream(Timeslot timeslot, Errors errors) {
timeslot.setSecret(null); timeslot.setSecret(null);
timeslot.setShare(null);
if (!StringUtils.hasText(timeslot.getStream())) { if (!StringUtils.hasText(timeslot.getStream())) {
errors.rejectValue("stream", "REQUIRED"); errors.rejectValue("stream", "REQUIRED");
} }

View File

@ -46,6 +46,8 @@ public class Timeslot implements UserData {
@Column(name = "description", nullable = true) @Column(name = "description", nullable = true)
@Lob @Lob
private String description; private String description;
@Column(name = "share", nullable = true)
private String share;
@Column(name = "stream", nullable = true) @Column(name = "stream", nullable = true)
private String stream; private String stream;
@Column(name = "secret", nullable = true) @Column(name = "secret", nullable = true)
@ -199,6 +201,20 @@ public class Timeslot implements UserData {
this.description = description; this.description = description;
} }
/**
* @return the share
*/
public String getShare() {
return share;
}
/**
* @param share the share to set
*/
public void setShare(String share) {
this.share = share;
}
/** /**
* Gets the stream. * Gets the stream.
* *

View File

@ -7,5 +7,5 @@ package de.bstly.we.partey.timeslot.model;
* The Enum TimeslotType. * The Enum TimeslotType.
*/ */
public enum TimeslotType { public enum TimeslotType {
VIDEO, AUDIO VIDEO, AUDIO, VIDEO_STREAM, AUDIO_STREAM
} }

View File

@ -12,7 +12,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version> <java.version>11</java.version>
<revision>1.4.0-SNAPSHOT</revision> <revision>1.4.1-SNAPSHOT</revision>
</properties> </properties>
<parent> <parent>