Esempio n. 1
0
def run(cid, after_postid):
    params = {"cid": cid}
    params["postid__gt"] = after_postid
    posts = CirclePost.objects(**params).order_by("-postid").limit(100)
    allpost = []
    for one in posts:
        allpost.append(one.toJson())
    return Res({"posts": allpost})
Esempio n. 2
0
def run(cid,before_postid=None,count=20):
    params={'cid':cid}
    if before_postid:
        params['postid__lt']=before_postid
    posts=CirclePost.objects(**params).order_by("-postid").limit(count)
    allpost=[]
    for one in posts:
        allpost.append(one.toJson())
    return Res({"posts":allpost})
Esempio n. 3
0
def run(postid,content):
    newpost=CirclePost.objects(postid=postid).first()
    newreply=ReplyRecord()
    newreply.uid=BackEndEnvData.uid
    newreply.content=content
    newpost.replys.append(newreply)
    newpost.save()

    json_msg=DefJsonEncoder.encode({"reply":newreply.toJson(),
                                                        "postid":postid,
                                                        "cid":newpost.cid})
    BackEndEnvData.queue_producer.publish(body=json_msg,delivery_mode=2,
                                        routing_key="sys.circle_new_board",headers={"type":"circle.newreply"},
                                        compression='gzip')
    return Res({"post":newreply.toJson()})
Esempio n. 4
0
def run(postid):
    post=CirclePost.objects(postid=postid).first()
    for one in post.likes:
        if one.uid==BackEndEnvData.uid:
            return Res({'like':one.toJson()})
    newlike=LikeRecord()
    newlike.uid=BackEndEnvData.uid
    post.likes.append(newlike)
    post.save()

    json_msg=DefJsonEncoder.encode({"like":newlike.toJson(),"postid":post.postid,"cid":post.cid})
    BackEndEnvData.queue_producer.publish(body=json_msg,
                                        headers={"uid":post.uid,"type":"circle.post.newlike"},
                                        delivery_mode=2,
                                        routing_key='sys.push_to_user',
                                        compression='gzip')

    return Res({'like':newlike.toJson()})