diff libervia.tac @ 266:cc778206b7ae

bridge: added inviteMUC + modify joinMUC to make it accept room_jid = ""
author souliane <souliane@mailoo.org>
date Sun, 17 Nov 2013 17:47:39 +0100
parents 3df0c3634c29
children 79970bf6af93
line wrap: on
line diff
--- a/libervia.tac	Sun Nov 17 17:43:31 2013 +0100
+++ b/libervia.tac	Sun Nov 17 17:47:39 2013 +0100
@@ -318,14 +318,30 @@
         return d
 
     def jsonrpc_joinMUC(self, room_jid, nick):
-        """Join a Multi-User Chat room"""
+        """Join a Multi-User Chat room
+        @room_jid: leave empty string to generate a unique name
+        """
         profile = ISATSession(self.session).profile
         try:
-            room_jid = JID(room_jid)
+            if room_jid != "":
+                room_jid = JID(room_jid).userhost()
         except:
             warning('Invalid room jid')
             return
-        self.sat_host.bridge.joinMUC(room_jid.userhost(), nick, {}, profile)
+        d = self.asyncBridgeCall("joinMUC", room_jid, nick, {}, profile)
+        return d
+
+    def jsonrpc_inviteMUC(self, contact_jid, room_jid):
+        """Invite a user to a Multi-User Chat room"""
+        profile = ISATSession(self.session).profile
+        try:
+            room_jid = JID(room_jid).userhost()
+        except:
+            warning('Invalid room jid')
+            return
+        room_id = room_jid.split("@")[0]
+        service = room_jid.split("@")[1]
+        self.sat_host.bridge.inviteMUC(contact_jid, service, room_id, {}, profile)
 
     def jsonrpc_mucLeave(self, room_jid):
         """Quit a Multi-User Chat room"""