def getMessageByID(mID): # This method return the message requested by its ID row = dao.getMessageInfo(mID) if not row: return jsonify(Error="Message not found"), 404 message = Dic.build_message_dict(row) return jsonify(Message=message)
def getUserMessages(uID): result = dao.getAllUserMessages(uID) if not result: return jsonify(Error="No Messages Found") mapped_result = [] for r in result: mapped_result.append(Dic.build_message_dict(r)) return jsonify(UserMessages=mapped_result)
def getAllChatactiveMessages(cID): # This method will return the messages in a determined chat chat_messages = dao.getAllChatActiveMessages(cID, 'false') if not chat_messages: return jsonify(Error="No Messages Found") result_messages = [] for row in chat_messages: result = Dic.build_message_dict(row) result_messages.append(result) return jsonify(Messages=result_messages)
def getAllUserMessagesInChat(uID,cID): # This method will return the messages in a determined chat chat_messages = dao.getAllUserMessagesInChat(uID,cID) if not chat_messages: return jsonify(Error="No Messages Found") result_messages = [] for row in chat_messages: result = Dic.build_message_dict(row) result_messages.append(result) return jsonify(Messages=result_messages)
def getMessageByUserID(uID): # This method will return the messages of a determined user messages = dao.getAllUserMessages(uID) if not messages: return jsonify(Error="User does not have any messages sent."), 404 result_list = [] for row in messages: result = Dic.build_message_dict(row) result_list.append(result) return jsonify(Messages=result_list)