openvidu-server: POST /api/signal return 406 if any connectionId wrong

pull/375/head
pabloFuente 2019-09-16 14:42:54 +02:00
parent eb57d02188
commit 19d30558d8
2 changed files with 7 additions and 5 deletions

View File

@ -356,16 +356,16 @@ public class SessionEventsHandler {
} else { } else {
Set<String> participantPublicIds = participants.stream().map(Participant::getParticipantPublicId) Set<String> participantPublicIds = participants.stream().map(Participant::getParticipantPublicId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
if (participantPublicIds.containsAll(toSet)) {
for (String to : toSet) { for (String to : toSet) {
if (participantPublicIds.contains(to)) {
Optional<Participant> p = participants.stream().filter(x -> to.equals(x.getParticipantPublicId())) Optional<Participant> p = participants.stream().filter(x -> to.equals(x.getParticipantPublicId()))
.findFirst(); .findFirst();
rpcNotificationService.sendNotification(p.get().getParticipantPrivateId(), rpcNotificationService.sendNotification(p.get().getParticipantPrivateId(),
ProtocolElements.PARTICIPANTSENDMESSAGE_METHOD, params); ProtocolElements.PARTICIPANTSENDMESSAGE_METHOD, params);
}
} else { } else {
throw new OpenViduException(Code.SIGNAL_TO_INVALID_ERROR_CODE, throw new OpenViduException(Code.SIGNAL_TO_INVALID_ERROR_CODE,
"Signal \"to\" field invalid format: Connection [" + to + "] does not exist"); "Signal \"to\" field invalid format: some connectionId does not exist in this session");
}
} }
} }

View File

@ -2579,6 +2579,8 @@ public class OpenViduTestAppE2eTest {
/** POST /api/signal (ACTIVE SESSION) **/ /** POST /api/signal (ACTIVE SESSION) **/
body = "{'session':'CUSTOM_SESSION_ID','to':['wrongConnectionId']}"; body = "{'session':'CUSTOM_SESSION_ID','to':['wrongConnectionId']}";
restClient.rest(HttpMethod.POST, "/api/signal", body, HttpStatus.SC_NOT_ACCEPTABLE); // No valid connectionId restClient.rest(HttpMethod.POST, "/api/signal", body, HttpStatus.SC_NOT_ACCEPTABLE); // No valid connectionId
body = "{'session':'CUSTOM_SESSION_ID','to':['" + connectionId + "','wrongConnectionId']}";
restClient.rest(HttpMethod.POST, "/api/signal", body, HttpStatus.SC_NOT_ACCEPTABLE); // No valid connectionId
body = "{'session':'CUSTOM_SESSION_ID'}"; body = "{'session':'CUSTOM_SESSION_ID'}";
restClient.rest(HttpMethod.POST, "/api/signal", body, HttpStatus.SC_OK); restClient.rest(HttpMethod.POST, "/api/signal", body, HttpStatus.SC_OK);
user.getEventManager().waitUntilEventReaches("signal", 2); user.getEventManager().waitUntilEventReaches("signal", 2);