Example #1
0
 def hashExist(self, hash):
     i = 0
     for h in MessageDAO().hashtagList()[0]:
         print(h)
         if hash == h:
             print(MessageDAO().hashtagList()[1][i])
             return MessageDAO().hashtagList()[1][i]
         i+=1
     return None
Example #2
0
 def getmessagelikes(self, mid):
     dao = MessageDAO().messageLikes(mid)
     if not dao:
         return jsonify(Error="NOT FOUND"), 404
     result = []
     for l in dao:
         result.append(self.maplikes(l))
     return jsonify(LikesInMessage=result)
Example #3
0
 def getMessageReplies(self, mid):
     messages = MessageDAO().messageReply(mid)
     if not messages:
         return jsonify(Error="NOT FOUND"), 404
     result = []
     for m in messages:
         result.append(self.mapreply(m))
     return jsonify(MessageReplies=result)
Example #4
0
 def getalldislikes(self):
     dao = MessageDAO().getDislikes()
     if not dao:
         return jsonify(Error="NOT FOUND"), 404
     result = []
     for l in dao:
         result.append(self.mapdislikesall(l))
     return jsonify(AllDislikes=result)
Example #5
0
 def getMessagesFromUser(self, uid):
     messages = MessageDAO().messagesFromUser(uid)
     if not messages:
         return jsonify(Error="NOT FOUND"), 404
     result = []
     for m in messages:
         result.append(self.mapUserMessage(m))
     return jsonify(MessagesFromUser=result)
Example #6
0
 def getMessagesFromChat(self, cid):
     messages = MessageDAO().messagesFromChat(cid)
     if not messages:
         return jsonify(Error="NOT FOUND"), 404
     result = []
     for m in messages:
         result.append(self.mapChatMessage(m))
     return jsonify(MessagesFromChat=result)
Example #7
0
 def getAllMessages(self):
     messages = MessageDAO().allMessages()
     if not messages:
         return jsonify(Error="NOT FOUND"), 404
     result = []
     for m in messages:
         result.append(self.maptoDicMessage(m))
     return jsonify(AllMessages=result)
Example #8
0
 def getMessageById(self, mid):
     messages = MessageDAO().messageById(mid)
     if not messages:
         return jsonify(Error="NOT FOUND"), 404
     result = []
     for m in messages:
         result.append(self.maptoDicMessage(m))
         return jsonify(Message=result)
Example #9
0
 def searchmsgwithhashinchat(self, cid, hashname):
     searchresult = MessageDAO().searchHashInChatmsg(cid, hashname)
     if not searchresult:
         return jsonify(Error="NOT FOUND"), 404
     result = []
     for l in searchresult:
         result.append(self.searchDic(l))
     return jsonify(SearchHash=result)
Example #10
0
 def postmessageh(self, msginfo):
     uid = msginfo['uid']
     cid = msginfo['cid']
     text = msginfo['text']
     reply = msginfo['reply']
     m = MessageDAO().postmessage(cid, uid, text)
     pieces = text.split(" ")
     hashtag = []
     for txt in pieces:
         if txt[0] == "#":
             hash = txt[1:]
             print(hash)
             chk = self.hashExist(hash)
             print(chk)
             if chk == None:
                 hid = MessageDAO().postHashtag(hash)
             else:
                 hid = chk
             done = MessageDAO().insertHasHash(m, hid)
     if reply != None:
         t = MessageDAO().insertreply(reply, m)
     result = {'mid': m}
     return jsonify(result), 201
Example #11
0
 def getMessageRepliesCount(self, mid):
     messages = MessageDAO().countRepliesMessage(mid)
     if messages==None:
         return jsonify(Error="NOT FOUND"), 404
     return jsonify(MessageReplies=messages)
Example #12
0
 def disliked(self, dislikeinfo):
     uid = dislikeinfo['uid']
     mid = dislikeinfo['mid']
     r = MessageDAO().insertdislike(uid, mid)
     return jsonify(Result=r), 200
Example #13
0
 def getmessagelikesCount(self, mid):
     dao = MessageDAO().countLikesMessage(mid)
     if dao == None:
         return jsonify(Error="NOT FOUND"), 404
     return jsonify(LikesInMessage=dao)