def post_list(): con = dbConnector.connect() content = helpers.json_from_get(request) try: identifier = content["forum"] entity = "forum" except KeyError: try: identifier = content["thread"] entity = "thread" except Exception as e: con.close() return json.dumps({ "code": 1, "response": (e.message)}) optional = helpers.get_optional_params(request=content, values=["limit", "order", "since"]) try: p_list = post.posts_list(con=con, entity=entity, params=optional, identifier=identifier, related=[]) except Exception as e: con.close() return json.dumps({ "code": 1, "response": (e.message)}) con.close() return json.dumps({ "code": 0, "response": p_list})
def user_listPosts(): con = dbConnector.connect() params = helpers.json_from_get(request) optional = helpers.get_optional_params(params, ["limit", "order", "since"]) try: helpers.check_params(params, ["user"]) response = post.posts_list(con=con, entity="user", params=optional, identifier=params["user"], related=[]) except Exception as e: con.close() return json.dumps({"code": 1, "response": (e.message)}) con.close() return json.dumps({"code": 0, "response": response})