def list_posts(): request_data = get_json(request) required_data = ["user"] optional = intersection(request=request_data, values=["limit", "order", "since"]) try: choose_required(data=request_data, required=required_data) posts_l = posts.posts_list(entity="user", params=optional, identifier=request_data["user"], related=[]) except Exception as e: return json.dumps({"code": 1, "response": (e.message)}) return json.dumps({"code": 0, "response": posts_l})
def list_posts(): content = get_json(request) required_data = ["thread"] entity = "thread" optional = intersection(request=content, values=["limit", "order", "since", "sort"]) # try: choose_required(data=content, required=required_data) p_list = posts.posts_list(entity=entity, params=optional, identifier=content["thread"], related=[]) # except Exception as e: # return json.dumps({"code": 1, "response": (e.message)}) return json.dumps({"code": 0, "response": p_list})
def list_posts(): content = get_json(request) required_data = ["forum"] related = related_exists(content) optional = intersection(request=content, values=["limit", "order", "since"]) try: choose_required(data=content, required=required_data) posts_l = posts.posts_list(entity="forum", params=optional, identifier=content["forum"], related=related) except Exception as e: return json.dumps({"code": 1, "response": (e.message)}) return json.dumps({"code": 0, "response": posts_l})
def post_list(): content = get_json(request) try: identifier = content["forum"] entity = "forum" except KeyError: try: identifier = content["thread"] entity = "thread" except Exception as e: return json.dumps({"code": 1, "response": (e.message)}) optional = intersection(request=content, values=["limit", "order", "since"]) try: p_list = posts.posts_list(entity=entity, params=optional, identifier=identifier, related=[]) except Exception as e: return json.dumps({"code": 1, "response": (e.message)}) return json.dumps({"code": 0, "response": p_list})