aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornico <nico@magicbroccoli.de>2020-11-18 17:50:29 +0100
committernico <nico@magicbroccoli.de>2020-11-25 00:03:44 +0100
commit811dd3a5ea8eeae251da3ed5f80940b699f3ff9d (patch)
tree9d8fb092c1024ff3ddacac77bae7da68d5649399
parentac0ea074d5684ac4f22b7787ce3b95f77f25e3e6 (diff)
fix: different muc hosts failureghetto_muc_fix
+ add muc room list parser * update fetch_muc method to utilize room list parser This method scales lineraly. Therefore this is only a temporary fix until we find a better solution.
-rw-r--r--calls.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/calls.py b/calls.py
index d4c8f2c..b76e389 100644
--- a/calls.py
+++ b/calls.py
@@ -58,6 +58,16 @@ class EjabberdApiCalls(EjabberdApi):
return None
+ # ghetto method until we have a better solution
+ @staticmethod
+ def _parse_muc_count(vhost, data: (list, dict)) -> int:
+ tmp = 0
+
+ for el in list(map(lambda x: x.split(sep="@"), data)):
+ if vhost in el[1]:
+ tmp += 1
+ return tmp
+
def fetch_onlineuser(self):
tmp = self.cmd("connected_users_info", {})
if "connected_users_info" not in tmp:
@@ -125,12 +135,13 @@ class EjabberdApiCalls(EjabberdApi):
def fetch_muc_count(self, vhost=None, muc_host="conference"):
host = "global"
- if vhost is not None:
- if self.verstring.major >= 19:
- host = ".".join([muc_host, vhost])
- else:
- host = vhost
result = self.cmd("muc_online_rooms", {"host": host})
+ if vhost is not None:
+ # if self.verstring.major >= 19:
+ # host = ".".join([muc_host, vhost])
+ # else:
+ # host = vhost
+ return self._parse_muc_count(vhost, result)
if "rooms" in result:
return len(result["rooms"])
return len(result)