Beispiel #1
0
    def post(self, mid):
        is_shared = self.get_argument("is_shared", "off")
        is_shared = True if is_shared == "on" else False
        content = self.get_argument("content")
        source_mid = self.get_argument("source_mid")
        upper = Reply.getObjectByObjectId(mid)
        source = Topic.getObjectByObjectId(source_mid)
        if upper and source:
            reply = Reply.save_reply(source=source, content=content, owner=self.current_user, upper=upper)
            names_list = get_usernames(content)
            for username in names_list:
                send_mentions(sender=self.current_user, username=username, reply=reply)

            if is_shared:
                url = getattr(self.opts, "%s_update_url" %self.current_user.port)
                source_url = "%s/r/%s" %(self.prefix_url, reply.mid)
                status = "%s\n%s" %(content.replace("#%s" %self.current_user.port, ""), source_url)
                
                message_request(
                    url, 
                    self.current_user.port, 
                    self.current_user.access_token, 
                    status,
                    app_key=getattr(self.opts, "%s_key" %self.current_user.port),
                    openid=self.current_user.oauth_id,
                    client_ip=self.request.remote_ip)
      
            self.finishedMsg(status="success", info="post reply success", next=self.request.path)
        else:
            self.finishedMsg(status="error", info="topic not found")  
Beispiel #2
0
 def get(self, mid):
     reply = Reply.getObjectByObjectId(mid)
     if reply:
         reply.incr_views()
         self.render("page/reply.html", reply=reply)
     else:
         self.finishedMsg(status="error", info="reply is not found")