Skip to content

Commit

Permalink
Remove need_user_refressh flag
Browse files Browse the repository at this point in the history
This flag is not really needed as the cache is synced if there is new users in ejabberd.
This fix an issue where users are not listed when added from another hypervisor.
  • Loading branch information
CyrilPeponnet committed Jun 18, 2015
1 parent baf8f27 commit 3d8af8c
Showing 1 changed file with 3 additions and 14 deletions.
Expand Up @@ -60,7 +60,6 @@ def __init__(self, configuration, entity, entry_point_group):

self.users = []
self.user_page_size = 50
self.need_user_refresh = True
self.entities_types_cache = {}
self.xmpp_server = entity.jid.getDomain()

Expand Down Expand Up @@ -289,7 +288,6 @@ def _fetch_users(self, xmppserver, callback, args=None):
@param args: optional kwards of the callback
"""
self.users = []
self.need_user_refresh = False

def on_receive_users_num(conn, iq):
if iq.getType() != "result":
Expand Down Expand Up @@ -801,10 +799,7 @@ def send_number(base_reply):
n = n + 1
base_reply.setQueryPayload([xmpp.Node("users", attrs={"total": n})])
self.entity.xmppclient.send(base_reply)
if self.need_user_refresh:
self._fetch_users(self.entity.jid.getDomain(), send_number, {"base_reply": base_reply})
else:
send_number(base_reply)
self._fetch_users(self.entity.jid.getDomain(), send_number, {"base_reply": base_reply})

def iq_users_list(self, iq):
"""
Expand Down Expand Up @@ -844,10 +839,7 @@ def send_users(base_reply):
base_reply.setQueryPayload(nodes[bound_begin:bound_end])
self.entity.xmppclient.send(base_reply)

if self.need_user_refresh:
self._fetch_users(self.entity.jid.getDomain(), send_users, {"base_reply": base_reply})
else:
send_users(base_reply)
self._fetch_users(self.entity.jid.getDomain(), send_users, {"base_reply": base_reply})

def iq_users_filter(self, iq):
"""
Expand Down Expand Up @@ -884,10 +876,7 @@ def send_filtered_users(base_reply):
else:
self.entity.xmppclient.send(base_reply)

if self.need_user_refresh:
self._fetch_users(self.entity.jid.getDomain(), send_filtered_users, {"base_reply": base_reply})
else:
send_filtered_users(base_reply)
self._fetch_users(self.entity.jid.getDomain(), send_filtered_users, {"base_reply": base_reply})

def iq_users_change_password(self, iq):
"""
Expand Down

0 comments on commit 3d8af8c

Please sign in to comment.