示例#1
0
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})
示例#2
0
def user_details():

	con = dbConnector.connect()
	params = helpers.json_from_get(request)

	try:
		helpers.check_params(params, ["user"])
		userr = user.details(con, params["user"])
	except Exception as e:
		con.close()
		return json.dumps({"code": 1, "response": (e.message)})
	
	con.close()
	return json.dumps({"code": 0, "response": userr})
示例#3
0
def user_listFollowers():

	con = dbConnector.connect()

	params = helpers.json_from_get(request)

	optional = helpers.get_optional_params(params, ["limit", "order", "since_id"])

	try:
		helpers.check_params(params, ["user"])
		response = user.listFollowers(con, params["user"], optional)
	except Exception as e:
		con.close()
		return json.dumps({"code": 1, "response": (e.message)})
	con.close()
	return json.dumps({"code": 0, "response": response})
示例#4
0
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})
示例#5
0
def post_details():
	con = dbConnector.connect()
	params = helpers.json_from_get(request)
	required_data = ["post"]
	related = helpers.related_exists(params)
	try:
		helpers.check_params(params, required_data)
		response = post.details(con, params["post"], related)
	except Exception as e:
		con.close()
		return json.dumps({
			"code": 1,
			"response": (e.message)})
	con.close()
	return json.dumps({
		"code": 0,
		"response": response})
示例#6
0
def list_thread():
	con = dbConnector.connect()

	params = helpers.json_from_get(request)

	optional = helpers.get_optional_params(request=params, values=["since", "limit", "order"])

	try:
		response = thread.list(con=con, required=params, optional=optional, related=[])
	except Exception as e:
		con.close()
		return json.dumps({
			"code": 1,
			"response": (e.message)})

	con.close()
	return json.dumps({
		"code": 0,
		"response": response})

	return
示例#7
0
def details_thread():
	con = dbConnector.connect()
	params = helpers.json_from_get(request)
	required_data = ["thread"]
	related = helpers.related_exists(params)

	if 'thread' in related:
		con.close()
		return json.dumps({
			"code": 3,
			"response": "error"})
	try:
		helpers.check_params(params, required_data)
		response = thread.details(con, params["thread"], related)
	except Exception as e:
		con.close()
		return json.dumps({
			"code": 1,
			"response": (e.message)})
	con.close()
	return json.dumps({
		"code": 0,
		"response": response})