Ejemplo n.º 1
0
def run(gid,after_postid):
    params={'gid':gid}
    params['postid__gt']=after_postid
    posts=GroupPost.objects(**params).order_by("-postid").limit(100)
    allpost=[]
    for one in posts:
        allpost.append(one.toJson())
    return Res({"posts":allpost})
Ejemplo n.º 2
0
def run(gid,before_postid=None,count=20):
    query=dict(gid=gid)
    if before_postid:
        query['postid__lt']=before_postid
    posts=[]
    for one in GroupPost.objects(**query).order_by("-postid").limit(count):
        posts.append(one.toJson())
    return Res({"posts":posts})
Ejemplo n.º 3
0
def run(postid,content):
    newpost=GroupPost.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(),"gid":newpost.gid,'postid':newpost.postid})
    BackEndEnvData.queue_producer.publish(body=json_msg,delivery_mode=2,
                                        routing_key="group.change",headers={"type":"group.newreply"},
                                        compression='gzip')

    return Res({"post":newreply.toJson()})
Ejemplo n.º 4
0
def run(postid):
    post=GroupPost.objects(postid=postid).first()
    if post is None:
        return Res(errno=3,error="post not exists")
    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,"gid":post.gid})
    BackEndEnvData.queue_producer.publish(body=json_msg,
                                        headers={"uid":post.uid,"type":"group.post.newlike"},
                                        delivery_mode=2,
                                        routing_key='sys.push_to_user',
                                        compression='gzip')
    return Res({'like':newlike.toJson()})