Esempio n. 1
0
 def post(self):
   '''show 可以是 away、dnd(忙碌)或空(在线)'''
   jid, resource = self.request.get('from').split('/', 1)
   status = self.request.get('status')
   show = self.request.get('show')
   logging.debug(u'%s 的状态: %s (%s)' % (jid, status, show))
   try:
     show = gaetalk.STATUS_CODE[show]
   except KeyError:
     logging.error('%s has sent an incorrect show code %s' % (jid, show))
     return
   try:
     gaetalk.send_status(self.request.get('from'))
   except xmpp.Error:
     logging.error('Error while sending presence to %s' % jid)
     return
   u = gaetalk.get_user_by_jid(jid)
   if u is not None:
     modified = False
     if resource not in u.resources:
       u.resources.append(resource)
       modified = True
     if u.avail != show:
       if u.avail == gaetalk.OFFLINE:
         u.last_online_date = datetime.datetime.now()
       u.avail = show
       modified = True
     if modified:
       gaetalk.log_onoff(u, show, resource)
       u.put()
     if config.warnGtalk105 and resource.startswith('Talk.v105'):
       xmpp.send_message(jid, u'您的客户端使用明文传输数据,为了大家的安全,请使用Gtalk英文版或者其它使用SSL加密的客户端。')
   else:
     gaetalk.try_add_user(jid, show, resource)
Esempio n. 2
0
 def post(self):
   jid = self.request.get('jid')
   resource = self.request.get('resource')
   u = gaetalk.get_user_by_jid(jid)
   if u is not None:
     if resource in u.resources:
       u.resources.remove(resource)
       if not u.resources:
         u.avail = gaetalk.OFFLINE
         u.last_offline_date = datetime.datetime.now()
       u.put()
     gaetalk.log_onoff(u, gaetalk.OFFLINE, resource)