Ejemplo n.º 1
0
 def get_user(self, user_name):
     user = session.query(User).get(user_name)
     if user is not None:
         return UserObj(user_name=user.username,
                        password=user.password_hash)
     else:
         return None
Ejemplo n.º 2
0
 def delete_message(self, user_name, message):
     ret_message = session.query(Message).filter(
         (or_(Message.sender == user_name, Message.receiver == user_name))).filter(Message.message == message.get_message()).first()
     if ret_message is not None:
         session.delete(ret_message)
         return True
     else:
         return False
Ejemplo n.º 3
0
 def validate_user(self, user: UserObj):
     user_q = session.query(User).get(user.get_username())
     if user_q is None:
         return False
     elif (user_q.username == user.get_username()) and (user.check_password(
             user_q.password_hash)):
         return True
     else:
         return False
Ejemplo n.º 4
0
 def edit_message_is_read(self, message_id):
     session.query(Message) \
         .filter(Message.id == message_id) \
         .update({Message.is_read: True})
Ejemplo n.º 5
0
 def get_message(self, user_name):
     message = session.query(Message).filter(Message.receiver == user_name).first()
     if message is not None:
         return self.create_message_obj(message=message)
     else:
         return None
Ejemplo n.º 6
0
 def get_all_unread_messages(self, user_name):
     messages = session.query(Message).filter(and_(Message.is_read == False, Message.receiver == user_name)).all()
     messages_list = []
     for message in messages:
         messages_list.append(self.create_message_obj(message).serialize())
     return messages_list
Ejemplo n.º 7
0
 def is_username_exist(self, user_name):
     user = session.query(User).get(user_name)
     if user is None:
         return False
     else:
         return True