diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-25 11:03:27 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-25 11:03:27 +0100 |
commit | 644e0ee607c026831341b1991d1180ef05a0adc5 (patch) | |
tree | 7e96712e0097eb86d4d331feccd25f0458d3d076 /api/social/destroy_relation.py | |
parent | e2466a6e4cda8ade7d755beae2d74e13454e91fa (diff) |
two_person_endpoint function decorator
Diffstat (limited to 'api/social/destroy_relation.py')
-rw-r--r-- | api/social/destroy_relation.py | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/api/social/destroy_relation.py b/api/social/destroy_relation.py index a08175f..4b61ecd 100644 --- a/api/social/destroy_relation.py +++ b/api/social/destroy_relation.py @@ -1,7 +1,6 @@ from flask import Blueprint, request from db import cursor -from auth.login_token import token_login -from social.create_relation import remove_relation +from social.create_relation import remove_relation, two_person_endpoint from user.info import get_relation_to from socket_io import io import time @@ -9,19 +8,8 @@ import time remove = Blueprint('remove', __name__) @remove.route('/remove', 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 - +@two_person_endpoint +def index(user_1_id, user_2_id): relation = get_relation_to(user_1_id, user_2_id) if relation == "none": return "", 403 @@ -36,19 +24,8 @@ def index(): 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 - +@two_person_endpoint +def index(user_1_id, user_2_id): if get_relation_to(user_1_id, user_2_id) != "blocked": return "", 403 remove_relation(user_1_id, user_2_id) |