Fix the SSO Jabber group handling to actually work, and reduce uneeded calls to the XMLRPC api

This commit is contained in:
2011-05-13 11:36:17 +01:00
parent 588e5ad14d
commit 08cbd72045
2 changed files with 9 additions and 5 deletions

View File

@@ -108,13 +108,15 @@ class JabberService(BaseService):
valid_groups = []
for group in groups:
groupname = group.name.lower().replace(' ', '-')
self.exec_xmlrpc('srg_create', group=groupname, host=server, name=group.name, description='', display='')
self.exec_xmlrpc('srg_user_add', user=username, host=server, group=groupname, grouphost=server)
valid_groups.append(groupname)
if not group.name in current_groups:
groupname = group.name.lower().replace(' ', '-').replace('.', '')
self.exec_xmlrpc('srg_create', group=groupname, host=server, name=group.name, description='', display='')
self.exec_xmlrpc('srg_user_add', user=username, host=server, group=groupname, grouphost=server)
if not groupname in current_groups: current_groups.append(groupname)
if not groupname in valid_groups: valid_groups.append(groupname)
for group in (set(current_groups) - set(valid_groups)):
self.exec_xmlrpc('srg_user_del', user=username, host=server, group=groupname, grouphost=server)
self.exec_xmlrpc('srg_user_del', user=username, host=server, group=group, grouphost=server)
def send_message(self, jid, msg):
# send_stanza_c2s user host resource stanza

View File

@@ -89,7 +89,9 @@ def update_service_groups(user_id):
for service in ServiceAccount.objects.filter(user=user_id, active=True).select_related('service__api'):
api = service.service.api_class
try:
print "Updating %s" % service
api.update_groups(service.service_uid, service.user.groups.all(), service.character)
print "Done"
except:
print "Error updating %s %s" % (service.service, service.service_uid)
pass