def list_threads(): 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) threads_l = threads.thread_list(entity="forum", identifier=content["forum"], related=related, params=optional) except Exception as e: return json.dumps({"code": 1, "response": (e.message)}) return json.dumps({"code": 0, "response": threads_l})
def thread_list(): content = get_json(request) try: identifier = content["forum"] entity = "forum" except KeyError: try: identifier = content["user"] entity = "user" except KeyError: return json.dumps({"code": 1, "response": "Any methods?"}) optional = intersection(request=content, values=["limit", "order", "since"]) try: t_list = threads.thread_list(entity=entity, identifier=identifier, related=[], params=optional) except Exception as e: return json.dumps({"code": 1, "response": (e.message)}) return json.dumps({"code": 0, "response": t_list})