From da23936687d21999541611b0480385b412ee6a00 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 13 Mar 2021 14:26:23 +0100 Subject: unblock route working --- api/social/destroy_relation.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'api') diff --git a/api/social/destroy_relation.py b/api/social/destroy_relation.py index aac6360..09b42f0 100644 --- a/api/social/destroy_relation.py +++ b/api/social/destroy_relation.py @@ -28,5 +28,29 @@ def index(): remove_relation(user_2_id, user_1_id) return "", 200 -dynamic_route = ["/social", remove] +unblock = Blueprint('unblock', __name__) + +@unblock.route('/unblock', methods = ['POST']) +def index(): + data = request.get_json() + + user_2_id = data.get("id") or "" + token = request.cookies.get("token") or "" + + if not token: return "", 401 + user_1_id = token_login(token) or "" + + if not user_1_id or \ + not user_2_id: + return "", 403 + + if get_relation_to(user_1_id, user_2_id) != "blocked": return "", 403 + + remove_relation(user_1_id, user_2_id) + return "", 200 + +dynamic_routes = [ + ["/social", remove], + ["/social", unblock] + ] -- cgit v1.2.3