diff libervia.tac @ 201:aa76793da353

server + browser: message warning level/sending refactoring: - widgets now manage themselves warning level - widgets now manage themselves text entered (if they are selectable, onTextEntered must be present) - Unibox now default to selected widget/status bar, except if a hook syntax is used (e.g. "@@: public microblog") - warning message is now GROUP (in blue with default theme) when sending a message to a MUC room (instead of green before) - "@.*: " syntaxes are now fully managed by browser, no more by server
author Goffi <goffi@goffi.org>
date Sun, 07 Apr 2013 22:33:55 +0200
parents 8475a29d7214
children 2bc6cf004e61
line wrap: on
line diff
--- a/libervia.tac	Mon Mar 25 14:09:10 2013 +0100
+++ b/libervia.tac	Sun Apr 07 22:33:55 2013 +0200
@@ -185,28 +185,28 @@
         self.sat_host.bridge.setPresence('', '', 0, {'':status}, profile)
 
     
-    def jsonrpc_sendMessage(self, to_jid, msg, subject, type):
+    def jsonrpc_sendMessage(self, to_jid, msg, subject, _type):
         """send message"""
         profile = ISATSession(self.session).profile
-        return self.sat_host.bridge.sendMessage(to_jid, msg, subject, type, profile)
+        return self.sat_host.bridge.sendMessage(to_jid, msg, subject, _type, profile)
 
-    def jsonrpc_sendMblog(self, raw_text):
-        """Parse raw_text of the microblog box, and send message consequently"""
+    def jsonrpc_sendMblog(self, _type, dest, text):
+        """ Send microblog message
+        @param _type: one of "PUBLIC", "GROUP"
+        @param dest: destinees (list of groups, ignored for "PUBLIC")
+        @param text: microblog's text
+        """
         profile = ISATSession(self.session).profile
-        match = re.match(r'@(.+?): *(.*$)', raw_text)
-        if match:
-            recip = match.group(1)
-            text = match.group(2)
-            #if recip == '@' and text:
-            #    #This text if for the public microblog
-            #    return self.sat_host.bridge.sendPersonalEvent("MICROBLOG", {'content':text}, profile)
-            if recip == '@' and text:
+        if _type in ("PUBLIC", "GROUP") and text:
+            if _type == "PUBLIC":
                 #This text if for the public microblog
                 print "sending public blog"
                 return self.sat_host.bridge.sendGroupBlog("PUBLIC", [], text, profile)
             else:
                 print "sending group blog"
-                return self.sat_host.bridge.sendGroupBlog("GROUP", [recip], text, profile)
+                return self.sat_host.bridge.sendGroupBlog("GROUP", [dest], text, profile)
+        else:
+            raise Exception("Invalid data") 
     
     def jsonrpc_getLastMblogs(self, publisher_jid, max_item):
         """Get last microblogs posted by a contact