fetch the skype chat for the msg subject twisty
authorMark Hammond <mhammond@skippinet.com.au>
Mon, 23 Mar 2009 10:12:59 +1100
branchtwisty
changeset 111 b0340c2821da37ecd100912692f3876ed6fa1806
parent 110 20979788066de01860cf050a0d0c43498d640624
child 112 b2f2984dd6482fbd7d4f8b13f937aaf03288b198
push id1
push userroot
push dateWed, 08 Apr 2009 01:46:05 +0000
fetch the skype chat for the msg subject
server/python/junius/proto/skype.py
--- a/server/python/junius/proto/skype.py
+++ b/server/python/junius/proto/skype.py
@@ -197,19 +197,34 @@ class TwistySkype(object):
                     )
 
 
 # A 'converter' - takes a proto/skype-msg as input and creates a
 # 'message' as output (some other intermediate step might end up more
 # appopriate)
 class SkypeConverter(base.ConverterBase):
     def convert(self, doc):
+        # We need to open the 'chat' for this Message.  Clearly this is
+        # going to be inefficient...
+        chat_id = "skypechat-" + doc['skype_chatname'].encode('utf8') # hrmph!
+        return self.doc_model.open_document(chat_id
+                        ).addCallback(self.finish_convert, doc)
+
+    def finish_convert(self, chat_doc, doc):
+        if chat_doc is None:
+            subject = "<failed to fetch skype chat!>"
+        else:
+            subject = chat_doc['skype_friendlyname']
         return {'from': ['skype', doc['skype_from_handle']],
-                'subject': 'I gotta get this from the chat itself :(',
-                'body': doc['skype_body']}
+                'subject': subject,
+                'body': doc['skype_body'],
+                'body_preview': doc['skype_body'][:128],
+                'conversation_id': doc['skype_chatname'],
+                'timestamp': doc['skype_timestamp'], # skype's works ok here?
+                }
 
 
 class SkypeAccount(base.AccountBase):
   def __init__(self, db, details):
     self.db = db
     self.details = details
 
   def startSync(self, conductor, doc_model):