Пример #1
0
    def post(self):
        isajax = self.request.get('isajax')
        phone = self.request.get('phone')
        msg = self.request.get('msg')
        contact_name = self.request.get('contact_name')

        user = users.get_current_user()
        email = user.email().lower()
        q = Token.query(Token.email == email)
        token = q.get()
        status = 100
        hist=''
        logging.debug(email + ' ' + phone + ' ' + msg + ' ' + contact_name)
        if token:
            status = 101
            if len(phone) and len(msg):
                status = 200
                hist = History(email=email, msg=msg, phone=phone, contact_name = contact_name)
                hist.put()
                airship.push({
                    "android": {
                         "extra": {"msgid": str(hist.key.id()), "phone": phone, "msg":msg}
                    }
                }, apids=[token.apid])
                id = hist.key.id()
                hist = hist.to_dict()
                hist['created']=hist['created'].isoformat();
                hist['id'] = id
                hist['type'] = 'sms'        
        self.response.out.write(json.dumps({'status':status, 'msg':hist}))
Пример #2
0
 def get(self):
     contact_name = self.request.get('contact_name')    
     phone = self.request.get('phone')
     msg = self.request.get('msg')
     email = self.request.get("email",'').lower()
     hist = History(email=email, msg=msg, phone=phone, contact_name = contact_name, byme=False)
     hist.put()
     id = hist.key.id()
     hist = hist.to_dict()
     hist['created']=hist['created'].isoformat();
     hist['id'] = id
     hist['type'] = 'sms'  
     channel.send_message(email, json.dumps(hist))
     self.response.out.write(json.dumps({}))