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 {
Set<String> participantPublicIds = participants.stream().map(Participant::getParticipantPublicId)
.collect(Collectors.toSet());
for (String to : toSet) {
if (participantPublicIds.contains(to)) {
if (participantPublicIds.containsAll(toSet)) {
for (String to : toSet) {
Optional<Participant> p = participants.stream().filter(x -> to.equals(x.getParticipantPublicId()))
.findFirst();
rpcNotificationService.sendNotification(p.get().getParticipantPrivateId(),
ProtocolElements.PARTICIPANTSENDMESSAGE_METHOD, params);
} else {
throw new OpenViduException(Code.SIGNAL_TO_INVALID_ERROR_CODE,
"Signal \"to\" field invalid format: Connection [" + to + "] does not exist");
}
} else {
throw new OpenViduException(Code.SIGNAL_TO_INVALID_ERROR_CODE,
"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) **/
body = "{'session':'CUSTOM_SESSION_ID','to':['wrongConnectionId']}";
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'}";
restClient.rest(HttpMethod.POST, "/api/signal", body, HttpStatus.SC_OK);
user.getEventManager().waitUntilEventReaches("signal", 2);