def searchMessagesByUserId(self, id): dao = MessageDAO() result = dao.searchMessagesByUserId(id) mapped_results = [] for r in result: mapped_results.append(self.medMsgToDict(r)) return jsonify(Messages=mapped_results)
def getRepliesForMessage(self, msgID): dao = MessageDAO() result = dao.getRepliesForMessage(msgID) mapped_results = [] for r in result: mapped_results.append(self.nameToDict(r)) return jsonify(Messages_Replied=mapped_results)
def searchMessagesByGroupId(self, id): # dao = MessageDAO() result = dao.searchMessagesByGroupId(id) mapped_result = [] for r in result: mapped_result.append(self.messagesDict(r)) return jsonify(Messages=mapped_result)
def searchMessagesOfUserFromGroup(self, uid, cid): # dao = MessageDAO() result = dao.searchMessagesOfUserFromGroup(uid, cid) mapped_results = [] for r in result: mapped_results.append(self.simpleMsgToDict(r)) return jsonify(Messages=mapped_results)
def getAllMessages(self): # dao = MessageDAO() results = dao.getAllMessages() mapped_results = [] for r in results: mapped_results.append(self.medMsgToDict(r)) return jsonify(Messages=mapped_results)
def getMessageByMsgId(self, msgID): dao = MessageDAO() result = dao.getMessageByMsgId(msgID) mapped_results = [] for r in result: mapped_results.append(self.msgToDict(r)) return jsonify(Message=mapped_results)
def getMessageThatReplied(self, msgID): dao = MessageDAO() result = dao.getMessageThatReplied(msgID) mapped_results = [] for r in result: mapped_results.append(self.msgToDict(r)) return jsonify(Replies_To=mapped_results)
def postMessage(self, userId, groupId, form2): if len(form2) != 3: return jsonify(Error="Malformed post request"), 400 else: newText = form2['newText'] replyValue = form2['replyValue'] replyId = form2['replyId'] if newText: dao = MessageDAO() result_list = dao.postMessage(userId, groupId, newText, replyValue, replyId) result = self.build_message_attributes(result_list) return jsonify(Message=result), 201 else: return jsonify( Error="Unexpected attributes in post request"), 400
def getReplyForDisplay(self, repID): dao = MessageDAO() result = dao.getRepliesRec(repID) mapped = {'replyString': result} return jsonify(ReplyMessage=mapped)