From bbdfd104303e6fde06b3fc3933efd72e47d96590 Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Sun, 15 Nov 2020 19:18:00 +0100 Subject: [PATCH] FIX(server): Prevent listeners from hearing all shouts Before this commit, the code on the server made sure that a ChannelListener would always receive audio that was being shouted to a channel. It didn't respect though if the shout was actually restricted to be received by only a specific group. This patch now makes sure that listeners are also checked for their group so that a listener that doesn't belong to the target group (if one is set) won't receive the audio either. --- src/murmur/Server.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 4cd023b73..f39a4bfef 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -1199,9 +1199,7 @@ void Server::processMsg(ServerUser *u, const char *data, int len) { } } - // Send audio to users in the linked channel but only if they - // haven't received the audio already (because they are listening - // to the original channel). + // Send audio to users in the linked channel foreach (User *p, l->qlUsers) { if (!ChannelListener::isListening(p->uiSession, c->iId)) { ServerUser *pDst = static_cast< ServerUser * >(p); @@ -1264,6 +1262,7 @@ void Server::processMsg(ServerUser *u, const char *data, int len) { if (ChanACL::hasPermission(u, tc, ChanACL::Whisper, &acCache)) { foreach (User *p, tc->qlUsers) { ServerUser *su = static_cast< ServerUser * >(p); + if (!group || Group::isMember(tc, tc, qsg, su)) { channel.insert(su); } @@ -1272,7 +1271,9 @@ void Server::processMsg(ServerUser *u, const char *data, int len) { foreach (unsigned int currentSession, ChannelListener::getListenersForChannel(tc)) { ServerUser *pDst = static_cast< ServerUser * >(qhUsers.value(currentSession)); - if (pDst) { + if (pDst && (!group || Group::isMember(tc, tc, qsg, pDst))) { + // Only send audio to listener if the user exists and it is in the group the speech is directed + // at (if any) listener << pDst; } }