Commit f5c1fa9b authored by Johannes Barthel's avatar Johannes Barthel
Browse files

handle third edge case (new caller in locked meeting)

parent bd96c73c
# senfsip-moderated-mute
this tool fixes two issues where meeting permissions don't work for (or rather, against) telephone users in bbb conferences
this tool fixes three issues where meeting permissions don't work for (or rather, against) telephone users in bbb conferences
* phone users can unmute themselves, even when moderators restrict the microphone permission
* phone users are not muted when the microphone permission is disabled
* phone users joining a meeting where microphone permissions are disabled can still talk
you need to make one change in the dialplan for this to work. in the file `/opt/freeswitch/etc/freeswitch/autoload_configs/conference.conf.xml`, change the line
```xml
......
......@@ -71,31 +71,46 @@ class ModeratedMic:
# start main loop
self.fs.process_events()
def run_as_permissions_change_handler(self):
def run_as_redis_handler(self):
conn = redis.Redis()
ps = conn.pubsub()
ps.subscribe("to-akka-apps-redis-channel")
ps.subscribe("from-akka-apps-redis-channel")
l = ps.listen()
# main loop iterates over redis events
for msg in l:
if msg["type"] != 'message':
continue
msg = json.loads(msg["data"].decode("utf-8"))["core"]
if msg["header"]["name"] != "ChangeLockSettingsInMeetingCmdMsg":
if not msg["header"]["name"] in ["ChangeLockSettingsInMeetingCmdMsg", "UserJoinedVoiceConfToClientEvtMsg"]:
continue
print(msg)
meeting_id = msg["header"]["meetingId"]
mics_disabled = msg["body"]["disableMic"]
print("meeting {} is now {}".format(meeting_id, "locked" if mics_disabled else "unlocked"))
meeting = self.db.meetings.find_one({"meetingId": meeting_id})
if msg["header"]["name"] == "ChangeLockSettingsInMeetingCmdMsg":
# if we change the lock settings, use the value from the message
# because state in mongo will not have been updated yet
mics_disabled = msg["body"]["disableMic"]
# but we need all existing users from mongo
users = self.db.voiceUsers.find({"joined":True, "meetingId": meeting["meetingId"]})
else:
# if we are handling a new user, so use the existing lock settings from mongo
mics_disabled = meeting["lockSettingsProps"]["disableMic"]
# but use the callerNum from the message, because the user isn't yet in mongo
users = [{"callerNum": msg["body"]["callerNum"]}]
# note: this will mute mics "again" if they were already muted
# and some other permission change caused the event to fire.
print("meeting {} is {}".format(meeting_id, "locked" if mics_disabled else "unlocked"))
if not mics_disabled:
print("mics are open, not doing anything")
continue
print("muting users")
print(users)
# note: this will mute mics "again" if they were already muted
# and some other permission change caused the event to fire.
meeting = self.db.meetings.find_one({"meetingId": meeting_id})
#print("meeting",meeting)
conference_id = meeting["voiceProp"]["voiceConf"]
for user in self.db.voiceUsers.find({"joined":True, "meetingId": meeting["meetingId"]}):
for user in users:
#print("user")
#print(user)
if user["callerNum"].startswith("w_"):
......@@ -109,16 +124,16 @@ if __name__ == "__main__":
if len(sys.argv) == 1:
os.chdir(os.path.dirname(sys.argv[0]))
zero_key_handler = subprocess.Popen(["./events.py", "zero_key_handler"])
permissions_change_handler = subprocess.Popen(["./events.py", "permissions_change_handler"])
redis_handler = subprocess.Popen(["./events.py", "redis_handler"])
zero_key_handler.wait()
permissions_change_handler.wait()
redis_handler.wait()
exit(0)
moderated_mic = ModeratedMic()
if sys.argv[1] == "zero_key_handler":
moderated_mic.run_as_zero_key_handler()
elif sys.argv[1] == "permissions_change_handler":
moderated_mic.run_as_permissions_change_handler()
elif sys.argv[1] == "redis_handler":
moderated_mic.run_as_redis_handler()
else:
print("invalid first argument")
exit(0)
Supports Markdown
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