Esempio n. 1
0
 def post(self):
     current_user = self.get_current_user()
     msg_uid = self.get_argument("message", None)
     if msg_uid:
         message = Message(db.message.find_one({"uid": int(msg_uid)}))
         if message.receiver == current_user['uid']:
             message.set_reject()
             message.put()
         elif message.sender == current_user['uid']:
             message.drop()
         self.finish(json.dumps([True, msg_uid]))
     else:
         pass
Esempio n. 2
0
 def post(self):
     current_user = self.get_current_user()
     msg_uid = self.get_argument("message", None)
     if msg_uid:
         message = Message(db.message.find_one({"uid": int(msg_uid)}))
         if message.receiver == current_user['uid']:
             message.set_reject()
             message.put()
         elif message.sender == current_user['uid']:
             message.drop()
         self.finish(json.dumps([True, msg_uid]))
     else:
         pass
Esempio n. 3
0
 def post(self, she):
     # Ajax call: receive and store message
     m = self.current_user_entity() # Message Sender 
     r = self.user_entity(uid=int(she))
     msg = self.get_argument("message", None) # Message
     message = Message() # initialize a message object
     try:
         message.set_sender(m.uid) # Use ID as identifier
         message.set_receiver(r.uid) # Message Receiver
         message.set_body(msg) 
         r.add_contacter(m.uid)
         m.add_contacter(r.uid)
         r.put()
         m.put()
         message.put()
         self.finish(json.dumps(True))
     except TypeError:
         pass
     except ValueError:
         pass
     self.finish(json.dumps(False)) # If error happens, this will end request
Esempio n. 4
0
 def post(self, she):
     # Ajax call: receive and store message
     m = self.current_user_entity()  # Message Sender
     r = self.user_entity(uid=int(she))
     msg = self.get_argument("message", None)  # Message
     message = Message()  # initialize a message object
     try:
         message.set_sender(m.uid)  # Use ID as identifier
         message.set_receiver(r.uid)  # Message Receiver
         message.set_body(msg)
         r.add_contacter(m.uid)
         m.add_contacter(r.uid)
         r.put()
         m.put()
         message.put()
         self.finish(json.dumps(True))
     except TypeError:
         pass
     except ValueError:
         pass
     self.finish(
         json.dumps(False))  # If error happens, this will end request